This example shows how to use the
/turtlebot_move action with a Turtlebot robot. The
/turtlebot_move action takes a location in the robot environment and attempts to move the robot to that location.
To run the Turtlebot ROS action server, this command is used on the ROS distribution.
roslaunch turtlebot_actions server_turtlebot_move.launch
Connect to a ROS network. You must have an ROS action server setup on this network. Change
ipaddress to the address of your ROS network.
ipaddress = '192.168.203.129'; rosinit(ipaddress,11311);
Initializing global node /matlab_global_node_84488 with NodeURI http://192.168.203.1:50304/
View the ROS actions available on the network. You should see
Create a simple action client to connect to the action server. Specify the action name.
goalMsg is the goal message for you to specify goal parameters.
[client,goalMsg] = rosactionclient('/turtlebot_move'); waitForServer(client)
Set the parameters for the goal. The
goalMsg contains properties for both the forward and turn distances. Specify how far forward and what angle you would like the robot to turn. This example moves the robot forward 2 meters.
goalMsg.ForwardDistance = 2; goalMsg.TurnDistance = 0;
Set the feedback function to empty to have nothing output during the goal execution. Leave
FeedbackFcn as the default value to get a print out of the feedback information on the goal execution.
client.FeedbackFcn = ;
Send the goal message to the server. Wait for it to execute and get the result message.
[resultMsg,~,~] = sendGoalAndWait(client,goalMsg)
resultMsg = ROS TurtlebotMoveResult message with properties: MessageType: 'turtlebot_actions/TurtlebotMoveResult' TurnDistance: 0 ForwardDistance: 2.0070 Use showdetails to show the contents of the message
Disconnect from the ROS network.
Shutting down global node /matlab_global_node_84488 with NodeURI http://192.168.203.1:50304/