Ask Your Question

how to publish a map frame to base_link directly.

asked 2020-08-30 12:27:44 -0500

Ivan_sun gravatar image

hi, there! I am a new master in ROS. I want to plot the trajectory of the feet of my robot in Rviz. But the error shows there is no map frame. The original frame is the base_link. So the robot is keep walking in place (origin point). how can I publish a map frame to connect to the base_link. For my task (plot the trajectory of the robot). I don't think I need odom frame.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-08-31 13:18:31 -0500

dtyugin gravatar image

You need some localization module that can provide information about position of your robot on the map. This information can be used to produce a transform. Usually this transform message goes to /tf_static topic for static transforms (like position of some sensor on your robot relative to base_link, wich btw does not change with time) and to /tf topic for dynamic transforms like position of your robot on map which changes with time since your robot moves. Rviz need this transform information to produce trajectory coordinates in map frame. Does your robot able to to produce coordinates on the map by some senor like gps reciever? If so you can use this information directly by tf broadcaster. If not you have to use some sensor like LIDAR or camera and SLAM techniques.

How to produce transform if you know position of your robot on the map (geometry_msgs::PoseStamped posr)

void generateTF(const geometry_msgs::PoseStamped& pose){
    static tf::TransformBroadcaster br;
    tf::Transform transform;
    // Send TF "/base_link" to "/map"
    transform.setOrigin(tf::Vector3(pose.pose.position.x, pose.pose.position.y, pose.pose.position.z));
    transform.setRotation(tf::Quaternion(pose.pose.orientation.x,pose.pose.orientation.y, pose.pose.orientation.z, pose.pose.orientation.w));
    br.sendTransform(tf::StampedTransform(transform, pose.header.stamp, "/map", "/base_link"));
edit flag offensive delete link more


suppose i have odometry information , which transform the base_link position w.r.t to a fixed frame in "odom" frame , Then how to relate this odom frame with map frame. If we know this transformation , we can easily translate the robot pose w.r.t map frame. Gmapping generate a map in map frame and i want to relate a tranform in between odom and map .

Badal gravatar image Badal  ( 2021-09-09 05:08:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-08-30 12:27:44 -0500

Seen: 516 times

Last updated: Aug 31 '20