How to play a /joint_state bag file
I recorded a joint_state bag file and I want to replay the same motion as the one recorded. Is it possible? and how would you do that?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I don't know of any way to re-play a trajectory that has been recorded out of the box. That problem is actually highly robot-specific anyway since at least on the PR2, the joint_state topic contains basically all encoder values of the robot. This includes the position of both arms, the head and the wheels.
However, it should be doable with a little bit of work. First, do a rosbag record /joint_states
. Then, I would use the rosbag C++ or Python API to read the data and generate goals for the different robot controllers. For the arms, you can generate joint_trajectory action goals and send them to the corresonding arm controllers. See this tutorial. For the head, you probably have to define your own joint_trajectory_controller that just controls the pan and tilt joints. After building up the joint_trajectory_messages, just send the goals at the same time to the action servers. Subsequent calls do the different action client's send_goal methods should be fine there.
If you rosbag play the bagfile you recorded, the trajectory will be slightly different from the real one. That's because hardware is not perfect. To execute the same trajectory from the bagfiles make the joint servomotors listen to the joint_state topic played from the bagfile.
If the reference signal that is driving your controller is exposed as a ros topic, you should probably record that to the bag, and not joint_states.
If you used actions to initiate the motion, you can also record the action goal topic (for example, something like joint_trajectory_action/goal
for a robot arm). Then you can either do it the clean way and implement an action client that sends that goal, or just use rosbag to play back the action goal. However, your joints have to be at the exact same starting position of the trajectory (probably you'll need to write a node that moves them there first).
OK, thank you for your answers
Asked: 2012-06-26 01:52:31 -0600
Seen: 1,469 times
Last updated: Jun 27 '12
What is the API to generate a registered point cloud from raw kinect streams
making sutable bag file that is compatible with hector SLAM [closed]
how to increase move_arm action speed ?
publishing file stream with ros
How to execute rgbdslam offline [closed]
displaying point cloud in rviz from .bag files, error
Save many ROIs with same time stamp inside a bag file
Processing of point clouds generated by ROS
What do you mean with replay? Do you just want to play back the bag (rosbag play) or do you want your robot to execute the same trajectory?
to execute the same trajectory