ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I had the same issue with my own URDF model and finally I could solve it. The robot_state_publisher needs basically only two information to run:
I found this information in the FAQ of tf
The important information I forgot first by sending out my /joint_state msg is the timestamp in the msg header! Without the time information the robot_state_publisher is not able to calculate the tf frames for the moving joints. Inside of the code this means the following for me:
// Setup the publisher for the /joint_states msg
ros::Publisher pub_js = nh.advertise<sensor_msgs::JointState>("/joint_states", 100);
sensor_msgs::JointState msg; // Create an object of the sensor_msgs::JointState
msg.name.push_back("My_Joint_Name"); // This must be the joint_name that is used inside of the URDF file
msg.position.push_back(0.0); // Set a value for this joint
msg.header.stamp = ros::Time::now(); // Stamp this message with the actual time
pub_js.publish(msg); // Publish the message
I hope this will solve your problem as well!