Ask Your Question
0

Using a action's result - Pt. 2

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

waltejon gravatar image

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

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'.


EDIT

The full action file is:

#goal definition
float64 ObjectID

---
#result definition
float64 translationx
float64 translationy
float64 translationz

---
#feedback
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);
}
else{

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

ac is the action client.

edit retag flag offensive close merge delete

Comments

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 imagemgruhler ( 2018-12-10 06:53:40 -0500 )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 imagePeteBlackerThe3rd ( 2018-12-10 07:08:03 -0500 )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 imagewaltejon ( 2018-12-10 07:40:41 -0500 )edit

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

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2018-12-10 07:51:49 -0500 )edit

Now I added the source code too.

waltejon gravatar imagewaltejon ( 2018-12-10 07:59:29 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

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

mgruhler gravatar image

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

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

Comments

Thanks again for your support! Now it works.

waltejon gravatar imagewaltejon ( 2018-12-12 03:24:58 -0500 )edit
1

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

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

Stats

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

Seen: 82 times

Last updated: Dec 10 '18