Complete the code to define a ROS action client that sends a goal.
client = actionlib.SimpleActionClient('move', [1]) client.wait_for_server()
The client needs the action type, which is MoveAction, to communicate properly with the server.
Complete the code to send a goal and wait for the result.
goal = [1]()
goal.target_pose = pose
client.send_goal(goal)
client.wait_for_result()To send a goal, you create an instance of MoveGoal and fill its fields.
Fix the error in the server callback to handle preemption properly.
def execute_cb(self, goal): if self.server.is_preempt_requested(): self.server.[1]() return # perform long task
When a preempt request is detected, the server must call set_preempted() to stop the goal cleanly.
Fill both blanks to publish feedback and set the result after task completion.
feedback = [1]() feedback.progress = 50 self.server.publish_feedback(feedback) result = [2]() result.success = True self.server.set_succeeded(result)
Feedback uses MoveFeedback and the final result uses MoveResult.
Fill all three blanks to create a ROS action server with proper initialization and start.
self.server = actionlib.SimpleActionServer('[1]', [2], execute_cb=self.execute_cb, auto_start=[3]) self.server.start()
The server needs the action name 'move', the action type MoveAction, and auto_start=False to initialize properly before starting.
