Ask Your Question
0

How to get the info from a goal with more than one type in a goalCB?

asked 2013-03-12 03:46:38 -0500

DIDI gravatar image

updated 2014-01-28 17:15:38 -0500

ngrennan gravatar image

Hey, I encountered the following problem: My goal definition in my action file has two types and I only know how to get one of this values from the acceptNewGoal().

My goal definition is:

#goal definition

float32 linear

float32 angular

---

and my goalCB:

void goalCB()

{

goal_.linear = as_.acceptNewGoal()->linear;

steer_.linear = goal_.linear*15/2;  
steer_.angular = goal_.angular*45/2; 
steer_pub_.publish(steer_);

}

As you can see I can only manage to get one value, not both. Anyone an idea how to do it? Or is it even possible? Thanks in advance!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-03-12 04:37:42 -0500

tbh gravatar image

updated 2013-03-12 05:02:33 -0500

You need to save the entire goal to a variable, rather than just the linear portion of the goal.

EDIT: acceptNewGoal() returns a boost ConstPtr, so you'll need to change the type of goal_. For example if your declaration was car_joy::Velocity goal_;, you'd need to change it to car_joy::Velocity::ConstPtr goal_ and then use -> operators instead of . operators.

Try this:

void goalCB()
{
    //where goal_ is some kind of ConstPtr
    goal_ = as_.acceptNewGoal();
    steer_.linear = goal_->linear*15/2;  
    steer_.angular = goal_->angular*45/2; 
    steer_pub_.publish(steer_);
}
edit flag offensive delete link more

Comments

I tried it before, it gives me an error. Like: no correspondence for »operator=«. And I tried with goal_ as car_joy::SteerCarGoal goal_; and car_joy::Velocity goal_; (Velocity is a custom msg with linear and angular float types.

DIDI gravatar imageDIDI ( 2013-03-12 04:50:33 -0500 )edit
1

answered 2013-03-12 05:38:11 -0500

DIDI gravatar image

It works now! Thanks a lot! But it did not work with

car_joy::Velocity::ConstPtr goal_

,it seems goal_ have to be ConstPtr type from the SteerCarGoal.h.

So it worked with:

car_joy::SteerCarGoal::ConstPtr goal_;
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

Stats

Asked: 2013-03-12 03:46:38 -0500

Seen: 83 times

Last updated: Mar 12 '13