Do not add anything manually. TF does that for you. Just use /map -> /base_link instead of /odom -> /base_link to get the robot position.
Originally posted by dornhege with karma: 31395 on 2015-02-06
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by mree on 2015-03-05:
Sorry for late reply, but my odometry transform is from odom to base_link. How could achieve directly from /amp ->/base_link
Comment by mree on 2015-03-05:
my tf tree now is /map -> /odom -> base_link
is it what you means as below?
/map -> /base_link
/map -> /odom
Comment by dornhege on 2015-03-05:
tf tree looks good. Just use the map->base_link transform and you'll get your pose in the map.
Comment by mree on 2015-03-06:
Currently I am getting my robot position in map by this way:
odom.pose.pose.position.x = x_move;
odom.pose.pose.position.y = y_move;
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation = tf::createQuaternionMsgFromYaw(w_move);
Comment by mree on 2015-03-06:
do you mean i should use this lookuptransform instead of odom to get my robot pose? something like this:
try {
listener.lookupTransform("map", "base_link", ros::Time(0), transform_in_map);
} catch(tf::TransformException &exception) {
ROS_ERROR("%s", exception.what());
}
Comment by dornhege on 2015-03-06:
Yes! .
Comment by mree on 2015-03-10:
I have made this change:
odom.pose.pose.position.x = transform.getOrigin().x();
odom.pose.pose.position.y = transform.getOrigin().y();
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation.z =tf::getYaw(transform.getRotation());;
Comment by mree on 2015-03-10:
However, when the odom frames move, the robot remains stationary. The transform from map to odom published by gmapping and amcl is not send to the base_link
Comment by dornhege on 2015-03-10:
Do NOT change the odometry. The odometry is what it is. Run gmapping amcl or similar together with the odometry and use that output as your robot's accurate pose.
Comment by Zuhair95 on 2022-05-24:
@mree
Did you solve the problem ? I mean how to get the gmapping estimated position ?
Thanks in advance .
Comment by Zuhair95 on 2022-05-24:
Please, @dornhege
How to "use /map -> /base_link instead of /odom -> /base_link "