Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaying ROS2 bag file on real robot #452

Open
ToncyChen opened this issue Aug 15, 2024 · 8 comments
Open

Replaying ROS2 bag file on real robot #452

ToncyChen opened this issue Aug 15, 2024 · 8 comments

Comments

@ToncyChen
Copy link

I have recorded a ROS2 bag file with the Webots https://github.com/MASKOR/webots_ros2_spot using nav2, and I want to replay the bag file on the real robot (BD Spot) using ROS2 interface of your repo. Could you please guide me on how to achieve this?

@khughes-bdai
Copy link
Collaborator

Hello,
What information or topics in the bag file do you want to replay on the robot?

@ToncyChen
Copy link
Author

Hello,

I remember I recorded the topics: "cmd_vel", "tf", "/Spot/odometry", "/Spot/imu" in my bag file.

@khughes-bdai
Copy link
Collaborator

khughes-bdai commented Aug 15, 2024

cmd_vel should be relatively straightforward to replay on the robot. When you start the driver, there is a cmd_vel topic, when you publish to it it will move the robot. You may just have to remap the name of the topic to make sure that it matches the name of the topic from the bag.
There is currently not a way to replay tf, odometry, or imu data on the robot from a bag.

@ToncyChen
Copy link
Author

Hello,
I want to record another ros2 bag file for the robotic arm with Webots https://github.com/MASKOR/webots_ros2_spot/tree/main?tab=readme-ov-file using Moveit2.
Is it possible for me to also replay this bag file with the real robot (BD Spot) using ROS2 interface of your repo?
If so, which topic should I record with ros2 bag file?

@khughes-bdai
Copy link
Collaborator

There is not currently a built in way to do this with the ROS driver. A way to do this could be

  1. record joint states topic in your bag file
  2. create a node that subscribes to joint states, and use this to construct a robot command protobuf with BD's robot command builder (filling in the arm joint angles)
trajectory_point = RobotCommandBuilder.create_arm_joint_trajectory_point(
            sh0=...,
            sh1=...,
            el0=...,
            el1=...,
            wr0=...,
            wr1=...,
 )
robot_command = robot_command_pb2.RobotCommand()
arm_command = robot_command.synchronized_command.arm_command
arm_command.arm_joint_move_command.trajectory.points.append(trajectory_point)
  1. Convert the protobuf to a robot command ROS message using from bosdyn_api_msgs.conversions import convert
  2. Send this command to the robot either using the robot_command action or the robot_command service brought up by the ROS driver

@khughes-bdai
Copy link
Collaborator

khughes-bdai commented Sep 17, 2024

There is a better way to replay Spot's arm joint angles on the robot now -- record the joint states topic, and replay it onto the topic /arm_joint_commands (added in #474) @ToncyChen

@ToncyChen
Copy link
Author

Hello,
So, in this case, I don not need to create a node to subscribe joint states and convert the message into ros message, I just have to create another ros2 bag file recording the topic /joint_states and replay onto the topic /arm_joint_command, is that right?

@khughes-bdai
Copy link
Collaborator

khughes-bdai commented Sep 18, 2024

Yes, this should work! Please let me know if there are any issues using this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants