Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I found the answer to that in amcl code.

  1. First you convert map to base position into a transform.
  2. Then you get tf::Stamped<tf::pose> object of it
  3. Then you reverse it
  4. After that you transform the reverse to "odom" frame
  5. Then you make a temporary transform object from above result
  6. Reverse of transform is result and you broadcast it. Below is the code.

    tf::Stamped<tf::pose> map_to_base (map_position_transform.inverse(), msg->header.stamp, "base_footprint"); listener.transformPose("odom", map_to_base, odom_to_map);

    latest_tf_ = tf::Transform(tf::Quaternion(odom_to_map.getRotation()),
    tf::StampedTransform map_to_odom(latest_tf_.inverse(),
                                        "map", "odom");
    br.sendTransform(tf::StampedTransform(map_to_odom, ros::Time::now(), "map", "odom"));