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?
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.
OK, thank you for your answers
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).
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2012-06-26 01:52:31 -0600
Seen: 743 times
Last updated: Jun 27 '12
robot_localization output sample
problem with building a map from a bag file
How to include the ROS_NAMESPACE in the default attribute in a launch file?
having trouble launching a launch file from another launch file
ubuntu 16.04 boot from launch file
How to test SLAM algorithms on a .bag file?
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