Ask Your Question
1

return value in action server

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

rcj1986 gravatar image

Hi, I'm following this tutorial http://wiki.ros.org/actionlib , and my question is,

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

thanks!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

Comments

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 imagercj1986 ( 2015-02-20 04:06:51 -0600 )edit

Yes this works. Just do package_name/MessageName

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 378 times

Last updated: Feb 20 '15