www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/CancelROSActionGoalsExample.m

    %% Send and Cancel ROS Action Goals
% 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);

%%
% Send a goal message with modified parameters. Wait for the goal to finish
% executing.
goalMsg.Order = 4;
sendGoalAndWait(actClient,goalMsg)

%%
% Send a new goal message without waiting.
goalMsg.Order = 5;
sendGoal(actClient,goalMsg)

%%
% Cancel the goal on the ROS action client, |actClient|.
cancelGoal(actClient)

%%
% Cancel all the goals on the action server that |actClient| is connected
% to.
cancelAllGoals(actClient)

%%
% Delete the action client.
delete(actClient)
%%
% Disconnect from the ROS network.
rosshutdown