Ask Your Question

Using a action's result - Pt. 2

asked 2018-12-10 06:31:16 -0600

waltejon gravatar image

updated 2018-12-10 07:59:05 -0600

Hello together,

I already had a problem using the result of an action.

After implementing the solution of @mgruhler, another problem occurred.

This time I have another problem: The result is defined in the action file and consists of several float values:

  • translationx
  • translationy
  • translationz

I would like to see the result by using ROS_INFO("X value: %f", result.translationx).

Unfortunately the compiler says: DetectionResult has no member named 'translationx'.


The full action file is:

#goal definition
float64 ObjectID

#result definition
float64 translationx
float64 translationy
float64 translationz

bool isProcessing

In the following you see the C++ source code within the main function:

bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0));

if (finished_before_timeout){
    actionlib::SimpleClientGoalState state = ac.getState();
    manipulator::DetectionResultConstPtr result = ac.getResult();
    ROS_INFO("Action finished: %s", state.toString().c_str());
    ROS_INFO("X Value: %f", result.translationx);

    ROS_INFO("Action did not finish before the time out.");

ac is the action client.

edit retag flag offensive close merge delete


can you please show your full action definition? This seems to be a non-standard ROS action. This will help in debugging.

Please don't edit anything (except for maybe removing comments).

mgruhler gravatar image mgruhler  ( 2018-12-10 06:53:40 -0600 )edit

Can you post your full source (or at least all of this that's relevant) we can't help you much from a single line. The same goes for the compiler error, the full error text is far more useful.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-12-10 07:08:03 -0600 )edit

The full action definition is added to question above. The design in the comment section is suitable, so I edited my original question.

waltejon gravatar image waltejon  ( 2018-12-10 07:40:41 -0600 )edit

Thanks for the update. But your c++ source is more important in this case, sorry if I wasn't clear.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-12-10 07:51:49 -0600 )edit

Now I added the source code too.

waltejon gravatar image waltejon  ( 2018-12-10 07:59:29 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-12-10 08:39:51 -0600

mgruhler gravatar image

updated 2018-12-10 08:40:26 -0600

result is a manipulator::DetectionResultConstPtr. Note the ConstPtr part. Thus, it should be result->translationx, most probably.

I'm a bit confused about the compiler error, though. Thus, I'm basically seconding @PeteBlackerThe3rd :-) Copying the compiler error with relevant context (and not typing) helps here...

edit flag offensive delete link more


Thanks again for your support! Now it works.

waltejon gravatar image waltejon  ( 2018-12-12 03:24:58 -0600 )edit

answered 2018-12-10 08:37:37 -0600

I'm far from 100% sure on this but try:

ROS_INFO("X Value: %f", result.result.translationx);

I think the result object may contain additional header and goal information with the result that you've defined within the action in a separate result property.

Let us know if it works.

edit flag offensive delete link more

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


Asked: 2018-12-10 06:31:16 -0600

Seen: 305 times

Last updated: Dec 10 '18