hcrlab / stretch_web_interface

Prototype web interface that enables remote teleoperation of the Stretch RE1 mobile manipulator from Hello Robot Inc.
Other
7 stars 3 forks source link

ROS Bag Recording #40

Open kavidey opened 2 years ago

kavidey commented 2 years ago

Brainstorming

Recording Protocol

  1. Record Button is Pressed
  2. Operator sends record message to the server (protocol: socketio, includes room name and session id)
  3. Server runs a bash script to record the topics we want
  4. Stop button is pressed
  5. Operator sends a stop message to the server (protocol: socketio, includes room name and session id)
  6. rosbag is stopped, renamed to [session id].bag and put in a bags/ folder

Playback Protocol

  1. User selects specific session from dropdown list (can query the Model for which sessions exist)
  2. Operator sends request to Robot to see if that bag file exists (protocol: responserequest, might need to go to server instead of we can't read files from the robot browser)
  3. If it does, then Operator sends a start playback message to the server (protocol: socketio, includes room name and session id)
  4. Server plays the selected ROS bag (do we need to replay user actions on the operator side too? if so how to sync the times?)
  5. Server sends message to operator when playback is finished (protocol: socketio)
  6. At any time operator can send message to server to cancel the playback (protocol: socketio)

Note: We could avoid communication directly with the server via socketio, if we added a listener on the server so the robot could send it bash commands to run. That way all the important communication is between the Robot and the Operator.

Other Options Reading a rosbag from the robot browser (https://github.com/cruise-automation/rosbag.js/). I think this would be more complicated than just doing everything with bash scripts. We would still need to record the bag with a bash script, only the playback would be in-browser. We would also need to write a second version of robot.ts that read its data from rosbag.js which would introduce extra complexity.

Make a custom ROS node that we interact with to start/stop recording rosbags There is a python/c++ api, that can be used to read and write files. We would need to manually take every topic we wanted to save and write it into the bag programmatically. The advantage to this is that we can start/stop recording without having to talk to the node server. It seems like most people just run a script to start / stop the recording (ex: https://answers.ros.org/question/10714/start-and-stop-rosbag-within-a-python-script/, https://gist.github.com/marco-tranzatto/8be49b81b1ab371dcb5d4e350365398a)

Not using rosbag and recording everything ourselves We could save a file for each video/datastream we read from ros in robot.ts. That would remove the need to interact with the server, since we wouldn't be running any scripts. But we would need to build our own playback system, and like if we were reading the rosbag in the browser, we would need to build a 2nd version of robot.ts that read data from our custom playback system instead of from ros.