www.gusucode.com > ros 工具箱 matlab源码程序 > ros/rosactionclient.m
function [client, goalmsg] = rosactionclient(actionName, varargin) %ROSACTIONCLIENT Create a ROS action client % CLIENT = ROSACTIONCLIENT('ACTIONNAME') creates a CLIENT for the ROS % action with name ACTIONNAME. If an action with this name is available % in the ROS network, the client determines the action type automatically. % If the action is not available, this function displays an error. CLIENT % is a simple action client and allows you to track a single goal at a % time. % % CLIENT = ROSACTIONCLIENT('ACTIONNAME', 'ACTIONTYPE') creates an action % client for the ROS action with name ACTIONNAME and type ACTIONTYPE. If % no action with this name is available in the ROS network, it is % created. If an action with the same name is available, but its % type does not match ACTIONTYPE, the function displays an error. % % [CLIENT,GOALMSG] = ROSACTIONCLIENT(___) returns a goal message GOALMSG % that you can send with the action client CLIENT. The goal message is % initialized with default values. % % % Use ROSACTIONCLIENT to connect to an action server and request the % execution of action goals. You can get feedback on the execution % progress and cancel the goal at any time. % % % Example: % % Create action client for TurtleBot movement % % The turtlebot_move action server needs to be running % [tbot, goalmsg] = ROSACTIONCLIENT('/turtlebot_move', 'turtlebot_actions/TurtlebotMove') % % % Wait for the action server to start up % waitForServer(tbot) % % % Request forward movement and wait until the TurtleBot is done % goalmsg.ForwardDistance = 1.0; % resultmsg = sendGoalAndWait(tbot, goalmsg); % % % Display the actual distance moved by the robot and the final goal state % resultmsg.ForwardDistance % tbot.GoalState % % See also robotics.ros.SimpleActionClient, rosaction. % Copyright 2016 The MathWorks, Inc. narginchk(1,2); try % Create and return action client object using the global node client = robotics.ros.SimpleActionClient([], actionName, varargin{:}); % Create goal message, if requested by user if nargout == 2 goalmsg = rosmessage(client); end catch ex % Save stack traces and exception causes internally, but do not % print them to the console rosex = robotics.ros.internal.ROSException.fromException(ex); throwAsCaller(rosex); end end