Cancel all goals on action server
This example shows how to send and cancel goals for ROS actions. Action types must be setup beforehand with an action server running.
You must have set up the
'/fibonacci' action type. To run this action server, use the following command on the ROS system:
rosrun actionlib_tutorials fibonacci_server
First, set up a ROS action client. Then, send a goal message with modified parameters. Finally, cancel your goal and all goals on the action server.
Connect to a ROS network with a specified IP address. Create a ROS action client connected to the ROS network using
rosactionclient. Specify the action name. Wait for the client to be connected to the server.
Initializing global node /matlab_global_node_59254 with NodeURI http://192.168.17.1:59729/
[actClient,goalMsg] = rosactionclient('/fibonacci'); waitForServer(actClient);
Send a goal message with modified parameters. Wait for the goal to finish executing.
goalMsg.Order = 4; [resultMsg,resultState] = sendGoalAndWait(actClient,goalMsg)
resultMsg = ROS FibonacciResult message with properties: MessageType: 'actionlib_tutorials/FibonacciResult' Sequence: [6×1 int32] Use showdetails to show the contents of the message
resultState = 'succeeded'
Sequence : [0, 1, 1, 2, 3, 5]
Send a new goal message without waiting.
goalMsg.Order = 5; sendGoal(actClient,goalMsg)
Cancel the goal on the ROS action client,
Cancel all the goals on the action server that
actClient is connected to.
Delete the action client.
Disconnect from the ROS network.
Shutting down global node /matlab_global_node_59254 with NodeURI http://192.168.17.1:59729/
client— ROS action client
ROS action client, specified as a
handle. This simple action client enables you to track a single goal
at a time.