Send goal message and wait for result
resultMsg = sendGoalAndWait(client,goalMsg)
resultMsg = sendGoalAndWait(client,goalMsg,timeout)
[resultMsg,state,status] = sendGoalAndWait(___)
Send and cancel goals for ROS actions. First, setup 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 using
rosactionclient. Specify the action name. Wait for the client to be connected to the server.
rosinit('192.168.154.131') [actClient,goalMsg] = rosactionclient('/fibonacci'); waitForServer(actClient);
Initializing global node /matlab_global_node_40739 with NodeURI http://192.168.154.1:57343/
Send a goal message with modified parameters. Wait for the goal to finish executing.
goalMsg.Order = 4; sendGoalAndWait(actClient,goalMsg)
Goal active Feedback: Sequence : [0, 1, 1] Feedback: Sequence : [0, 1, 1, 2] Feedback: Sequence : [0, 1, 1, 2, 3] Feedback: Sequence : [0, 1, 1, 2, 3, 5] ans = ROS FibonacciResult message with properties: MessageType: 'actionlib_tutorials/FibonacciResult' Sequence: [6×1 int32] Use showdetails to show the contents of the message
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_40739 with NodeURI http://192.168.154.1:57343/
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.
goalMsg— ROS action goal message
ROS action goal message, specified as a
handle. Update this message with your goal details and send it to
the ROS action client using
timeout— Timeout period
Timeout period for receiving a result message, specified as a scalar in seconds. If the client does not receive a new result message in that time period, an error is displayed.
resultMsg— Result message
Result message, returned as a ROS
The result message contains the result data sent by the action server.
This data depends on the action type.
state— Final goal state
Final goal state, returned as one of the following:
'pending' — Goal was received,
but has not yet been accepted or rejected.
'active' — Goal was accepted
and is running on the server.
'succeeded' — Goal executed
'preempted' — An action
client canceled the goal before it finished executing.
'aborted' — The goal was
aborted before it finished executing. The action server typically
aborts a goal.
'rejected' — The goal was
not accepted after being in the
The action server typically triggers this status.
'recalled' — A client canceled
the goal while it was in the
'lost' — An internal error
occurred in the action client.
status— Status text
Status text that the server associated with the final goal state, returned as a character vector.