[3/9/24]

Teleoperation

https://articulatedrobotics.xyz/tutorials/mobile-robot/applications/teleop/

  • Teleoperation usually consist of two parts:
    • A way to send command signals (typically velocities) TO the robot
    • A way to receive sensor data FROM the robot (this may be optional if you are physically present with the robot)

picture 2

Connecting to Joysticks/Gamepads in ROS

picture 0

  • Display the controllers that ROS can see
ros2 run joy joy_enumerate_devices
ID : GUID                             : GamePad : Mapped : Joystick Device Name
-------------------------------------------------------------------------------
 0 : 03000000d62000003520000067010000 :    true :  false : Generic X-Box pad
  • Run joy_node
ros2 run joy joy_node # <-- Run in first terminal
  • Check messages coming in through /joy
ros2 topic echo /joy # <-- Run in second terminal

Joystick Tester GUI

  • Optionally install joy_tester, a GUI program that displays button/axis numbers for testing joysticks in ROS

    • sensor_msgs/Joy messages are displayed in a more user-friendly format than using topic echo
  • Clone the repo and build the package

git clone https://github.com/joshnewans/joy_tester.git
cd ..
colcon build 
  • Run joy_tester
source install/setup.bash
ros2 run joy_tester test_joy

picture 1

Create launch file

  • Create joystick.launch.py in the launch directory This specifies the path to a params file, declares a joy node that uses the params file, and launches the joy node

joystick.launch.py

Create params file

joystick.yaml

  • Rebuild to add the new files and launch
# cd workspace
colcon build --symlink-install
source install/setup.bash
ros2 launch articubot_one joystick.launch.py

Convert Joy to Twist

  • Convert raw joystick data coming through on /joy to a Twist message using teleop_twist_joy package
    • Add teleop_node to launch file
    teleop_node = Node(
            package='teleop_twist_joy',
            executable='teleop_node',
            name = 'teleop_node',
            parameters=[joy_params],
            # remappings=[('/cmd_vel', '/diff_cont/cmd_vel_unstamped')]
            )
  • Set the Twist parameters
    • This allows you to specify:
      • Which joystick axis to use
      • Max speed in regular mode
      • Max speed in turbo mode
# ... below the joy parameters
 
teleop_node:
  ros__parameters:
    
    axis_linear:  # Left thumb stick vertical
      x: 1
    scale_linear:
      x: 0.5
    scale_linear_turbo:
      x: 1.0
 
    axis_angular:  # Left thumb stick horizontal
      yaw: 0
    scale_angular:
      yaw: 0.5
    scale_angular_turbo:
      yaw: 1.0
 
    require_enable_button: true
    enable_button: 6  # Left shoulder button
    enable_turbo_button: 7  # Right shoulder button
  • rerun the launch file

  • See the values in another terminal

    • When we move the sticks by themselves there should be nothing, when we hold the regular speed button down, we should get those regular speeds, and likewise the higher speeds with the turbo button.
ros2 topic echo /cmd_vel