(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Send a Goal to Action Server without Action Client

Description: This tutorial shows ways of send a Goal to an Action Server without the need of create an Action Client.

Keywords: action_server, axclient

Tutorial Level: BEGINNER

Run the Nodes

To this tutorial we are going to use the turtle_actionlib package that is already installed with ROS. First let's initiate the turtlesim. Start the roscore in a new terminal

$ roscore

In another terminal, start the turtlesim

$ rosrun turtlesim turtlesim_node

After run the turtlesim, run the server in the turtle_actionlib package

$ rosrun turtle_actionlib shape_server

use another terminal to check if the action topics were created

$ rostopic list

If everything goes right, you should see the list similar to this:

/rosout
/rosout_agg
/turtle1/cmd_vel
/turtle1/color_sensor
/turtle1/pose
/turtle_shape/cancel
/turtle_shape/feedback
/turtle_shape/goal
/turtle_shape/result
/turtle_shape/status

As you can see, the topics with names /cancel, /feedback, /goal, /result and /status shows that the shape_server is running and has created the action topics. So, there is 2 ways to send a goal to the action_server without an action client.

Send a Goal to Action Server

Use the rostopic pub direct in a terminal

As the /goal topic is a normal topic, can be publish normally, so, in a new terminal:

$ rostopic pub /turtle_shape/goal turtle_actionlib/ShapeActionGoal "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
goal_id:
  stamp:
    secs: 0
    nsecs: 0
  id: ''
goal:
  edges: 0
  radius: 0.0" 

An easy way of use this approach is start typing and always press TAB, so the system completes the name and type of the topic and, also, the content of the msg. After the appears complete, change the values of the goal, like the example below:

$ rostopic pub /turtle_shape/goal turtle_actionlib/ShapeActionGoal "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
goal_id:
  stamp:
    secs: 0
    nsecs: 0
  id: ''
goal:
  edges: 3
  radius: 1.0" 

Sending this goal, the turtle at turtlesim should draw a triangle similar to this:

triangle_action.png

Use axclient from actionlib

The actionlib offers a graphical way to send goal to action server. To use this interface, run in a terminal

$ rosrun actionlib axclient.py /name_of_the_action

In our case:

$ rosrun actionlib axclient.py /turtle_shape

An window similar to this should open:

axclient.png

In this GUI, there is the areas ti the Goal, Feedback and Result. We can use this interface to send the goal with edges=4 and radius=2.0. Change the values at the Goal area and press the SEND GOAL button. After that, the turtle at turtlesim should draw a square. Sending the goal to the action server.

send_goal.png

In this image, the CANCEL GOAL button change to active, so the action can be preempted.

cancel_goal.png

After the action finished successfully, the GUI shows the Result.

finish_goal.png

And the turtle drew the square as spectated:

turtle_square.png

Wiki: actionlib_tutorials/Tutorials/Calling Action Server without Action Client (last edited 2020-05-14 14:15:19 by PedroAlcantara)