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

How to play a /joint_state bag file

asked 2012-06-26 01:52:31 -0600

mamoun gravatar image

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?

edit retag flag offensive close merge delete

Comments

2

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?

Lorenz gravatar image Lorenz  ( 2012-06-26 02:12:28 -0600 )edit

to execute the same trajectory

mamoun gravatar image mamoun  ( 2012-06-26 22:30:54 -0600 )edit

4 Answers

Sort by » oldest newest most voted
3

answered 2012-06-27 03:17:03 -0600

Lorenz gravatar image

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.

edit flag offensive delete link more
1

answered 2012-06-27 00:51:34 -0600

Miquel Massot gravatar image

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.

edit flag offensive delete link more

Comments

I don't think this is a good idea since the joint_state topic is not meant for controlling joints but for publishing the current positions/velocities/efforts of joints.

Lorenz gravatar image Lorenz  ( 2012-06-27 02:32:37 -0600 )edit

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.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2012-06-27 03:08:22 -0600 )edit
0

answered 2012-06-27 23:30:08 -0600

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).

edit flag offensive delete link more
0

answered 2012-06-27 05:05:54 -0600

mamoun gravatar image

OK, thank you for your answers

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-06-26 01:52:31 -0600

Seen: 1,469 times

Last updated: Jun 27 '12