uwrobotics / uwrt_mars_rover

Ros Metapackage for UWRT Mars Rover
MIT License
18 stars 7 forks source link

COMMS: Emergency Stop Node #229

Open keyonjerome opened 1 year ago

keyonjerome commented 1 year ago

Task Description: Create a ROS2 node that acts as a software-based emergency stop.

We've recently made the decision to drive our motors directly from the Jetson via its CAN bus controllers. ROS2 can only be "soft" real-time, or not real-time at all, so this is not ideal from our end. We need a node that can emergency stop, or "disable" the robot given a specific input.

This input can either be from a ROS-based GUI, like done in rqt_estop in ROS1, or it can be from the joystick package we've been developing.

Essentially, we'll subscribe to a published button value from either the GUI you create or from a joystick. If that button value ever reads "true" (after a debounce), the e-stop node should immediately publish a velocity of 0.0 to all of our robot's velocity controllers. In order to do this we'll actually need to set up the e-stop node as an "interceptor" of all of the robot's velocity traffic.

Let me explain the "interceptor" of velocity traffic" bit. Right now, in order to move the robot, you publish, to, for example differential_drive_controller/cmd_vel. Our joystick node publishes to this. Then the differential_drivetrain_controller subscribes to that and tells the robot to move at that velocity. We can't just have your e-stop publish to the differential_drive_controller/cmd_vel topic as well as the joystick because then if the e-stop is pressed the joystick would still be publishing to the velocity controller as well. Instead, we'll have the joystick publish to differential_drive_controller_estop/cmd_vel, and your e-stop node will subscribe to that. It will forward the values it receives to differential_drive_controller/cmd_vel. If the e-stop is pressed, the node should ignore any publishes to differential_drive_controller_estop/cmd_vel and instead publish 0.0 to differential_drive_controller/cmd_vel until the e-stop is disabled.

Task breakdown:

  1. Create a branch off https://github.com/uwrobotics/uwrt_mars_rover/tree/user/soumya-khanna/220/drivetrain-xbox, user/[github-username/229/disable-node.
  2. Within uwrt_mars_rover_utilities, create a package called uwrt_mars_rover_estop.
  3. Create a node within that package which:
    • Subscribes to an array of geometry_msgs/Twist topics defined in the .h file (start with differential_drive_controller_estop/cmd_vel)
    • Forwards those Twist messages to the non-estop version of that topic.
    • If the estop is pressed, stops forwarding those Twist messages and instead publishes all 0s to the non-estop version of that topic. For now, assume that the e-stop is pressed when a published topic, such as emergency_stop (which would just be a boolean value), publishes true. We'll tie it in with the joystick controller later.