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

Revision history [back]

click to hide/show revision 1
initial version

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