The code below is the ros2 doc's example callback that's executed in an ActionServer, it returns that the goal was suceeded.
But I want to create something that returns to the client that I'm executing or that's possible just by feedbacks?
def execute_callback(self, goal_handle):
self.get_logger().info('Executing goal...')
feedback_msg = Fibonacci.Feedback()
feedback_msg.partial_sequence = [0, 1]
for i in range(1, goal_handle.request.order):
feedback_msg.partial_sequence.append(
feedback_msg.partial_sequence[i] + feedback_msg.partial_sequence[i-1])
self.get_logger().info('Feedback: {0}'.format(feedback_msg.partial_sequence))
goal_handle.publish_feedback(feedback_msg)
time.sleep(1)
goal_handle.succeed()
result = Fibonacci.Result()
result.sequence = feedback_msg.partial_sequence
return result
I tried to find a method in the goal_handle that says that the task is just executing but I coudn't find, I found just succeded, abort and canceled.