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

Getting error code "string" from ArmNavigationErrorCodes for MoveArm action

asked 2011-02-27 01:29:03 -0500

felix gravatar image

updated 2011-02-27 08:42:13 -0500

The MoveArm action returns an error_code in its result:

more MoveArmResult.msg
#An error code reflecting what went wrong
motion_planning_msgs/ArmNavigationErrorCodes error_code

which I can access then with:

result->error_code.val;

is there a way to get a string (which is more meaningful than an int) from this error code? something like the ENUM defined here:

/opt/ros/cturtle/stacks/motion_planning_common/motion_planning_msgs/msg/ArmNavigationErrorCodes.msg

# overall behavior
int32 PLANNING_FAILED=-1
int32 SUCCESS=1
int32 TIMED_OUT=-2

# start state errors
int32 START_STATE_IN_COLLISION=-3
int32 START_STATE_VIOLATES_PATH_CONSTRAINTS=-4

Thanks in advance,

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2011-02-28 03:09:48 -0500

Sachin Chitta gravatar image

updated 2011-02-28 03:11:02 -0500

If you are in unstable and using C++, there is a convenience function in motion_planning_msgs that does this for you:

#include <motion_planning_msgs/convert_messages.h>

....

std::string err_string = motion_planning_msgs::armNavigationErrorCodeToString(error_code);

....

edit flag offensive delete link more

Comments

Thanks. I guess I am not in unstable, it is not defined in my motion_planning_msgs/convert_messages.h . I am using the ubuntu virtual box appliance I grabbed from WG site a while ago (but I am up to date). Will this make it in the stable version sometime?
felix gravatar image felix  ( 2011-02-28 09:34:51 -0500 )edit
This will go into the release of the arm_navigation stacks against diamondback (which is essentially a copy of unstable).
Sachin Chitta gravatar image Sachin Chitta  ( 2011-03-01 02:43:02 -0500 )edit
1

answered 2011-12-17 14:57:32 -0500

Ibrahim gravatar image

updated 2011-12-17 14:58:36 -0500

I realize this is old, but this Python one liner will give you a dict mapping error codes to error strings. I realize it's ugly and possibly not Pythonic, but it works (assuming all error strings are the only uppercase attributes of ArmNavigationErrorCodes).

dict((getattr(ArmNavigationErrorCodes, key), key) for key in filter(lambda x: x==x.upper(), dir(ArmNavigationErrorCodes)))

Figured someone else out there might be using Python with the arm_navigation stack.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2011-02-27 01:29:03 -0500

Seen: 311 times

Last updated: Dec 17 '11