0
$\begingroup$

Rosanswers logo

Hi,

I want to get the Position (x, y) and the orientation from my robot. The position should be relative to the map TF. Therefore I used a TransformListener:

tf::StampedTransform transform_bot;
tf::TransformListener listener;

listener.lookupTransform("/map", "/base_footprint", ros::Time(0), transform_bot);

bot_x = transform_bot.getOrigin().x();
bot_y = transform_bot.getOrigin().y();

double roll, pitch, yaw;
transform_bot.getBasis().getRPY(roll, pitch, yaw);

bot_dir = yaw * 180.0 / PI;

ROS_INFO("Bot X: %f", bot_x);
ROS_INFO("Bot Y: %f", bot_y);
ROS_INFO("Bot Z: %f", bot_dir);

So far I was not able to get good result with this solution...

Do you have any ideas, how to solve the problem?

Thank you, Sebastian


Originally posted by SeanAda on ROS Answers with karma: 3 on 2016-08-10

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I'm not sure that getBasis does what you think, I could be wrong though. I would try using getRotation which returns a quaternion, then grabbing the yaw from that.

tf::Quaternion q = transform_bot.getRotation(); 
double yaw = tf::getYaw(q); 

Here is the getYaw documentation.

If that doesn't solve things could you edit your answer and describe what results you're observing with your current code?


Originally posted by Airuno2L with karma: 3460 on 2016-08-11

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.