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

StampedTransform getting Position instead of Relative Position

asked 2015-01-30 11:43:26 -0600

choog gravatar image

HI, I am trying to log some data. The code works like intended except I am receiving the Relative Position instead of the Position.

tf::StampedTransform transformOdom;
current_time = ros::Time::now();

try {
        listener.waitForTransform( "odom","base_footprint", ros::Time(0), ros::Duration(10.0));
    listener.lookupTransform( "odom", "base_footprint",ros::Time(0), transformOdom);
    }
    catch (tf::TransformException &ex) {
        ROS_ERROR("%s",ex.what());
    }

//For debugging purposes
ROS_INFO_STREAM("X pose " <<  transformOdom.getOrigin().x() );
ROS_INFO_STREAM("Y pose " << transformOdom.getOrigin().y());

fileToWrite.open ("log.txt", ios_base::app);
fileToWrite << "X: " << transformOdom.getOrigin().x() << " Y: " << transformOdom.getOrigin().y()<< "\n";
fileToWrite.close();

Here is where you can see the two different positions from the visualization software

Does anyone know how to get the position of the robot instead of the relative position?

Thanks, choog

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-01-30 11:47:34 -0600

dornhege gravatar image

You need to choose a frame that you consider fixed, e.g., /map.

edit flag offensive delete link more

Comments

1

listener.waitForTransform( "map","base_footprint", ros::Time(0), ros::Duration(10.0)); listener.lookupTransform( "map", "base_footprint",ros::Time(0), transformOdom);

as such?

choog gravatar image choog  ( 2015-01-30 11:50:37 -0600 )edit

That worked. I figured that is what you meant and it tried. Thanks a lot.

choog gravatar image choog  ( 2015-01-30 11:55:42 -0600 )edit

Hi! I met the same problem just like you, I changed "odom" with "map", instead, I got this error "map" passed to lookupTransform argument target_frame does not exist. Can you tell me what should I do ? I don't even know what odom means. CuzI just started to learn ROS ;(,Thx anyway

Henschel.X gravatar image Henschel.X  ( 2016-03-21 20:48:08 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-01-30 11:43:26 -0600

Seen: 1,438 times

Last updated: Jan 30 '15