# how to publish a map frame to base_link directly.

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 close merge delete

Sort by » oldest newest most voted

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){
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));
}

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 .

( 2021-09-09 05:08:06 -0500 )edit