ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

return value in action server

asked 2015-02-19 06:40:31 -0600

rcj1986 gravatar image

Hi, I'm following this tutorial , and my question is,

The server can return a value to the client? How can I do?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-02-20 01:37:39 -0600

BennyRe gravatar image

There's a short snippet sn section 5 of the page you linked:

# Define the goal
uint32 dishwasher_id  # Specify which dishwasher we want to use
# Define the result
uint32 total_dishes_cleaned
# Define a feedback message
float32 percent_complete

See the line with # Define the result? The return type of this action is uint32 and the name of the return value is total_dishes_cleaned.

To set this return value have a look at the setSucceeded() signature found here:

void actionlib::SimpleActionServer< ActionSpec >::setSucceeded(const Result &   result = Result(),
    const std::string &     
    text = std::string("") 

You can call setSucceeded() with a result as parameter. In this result object you can set the return members.

In Python it works the same.

edit flag offensive delete link more


Thank you for your reply.

Do you know if it's possible declare the result like a geometry_msgs::Pose or only the "normal" type of variables (float, int, etc)?

rcj1986 gravatar image rcj1986  ( 2015-02-20 04:06:51 -0600 )edit

Yes this works. Just do package_name/MessageName

BennyRe gravatar image BennyRe  ( 2015-02-20 04:31:05 -0600 )edit

Question Tools

1 follower


Asked: 2015-02-19 06:40:31 -0600

Seen: 896 times

Last updated: Feb 20 '15