Skip to content

Joystick

A joystick can be used to manually steer the cars as opposed to an autonomous controller. Use the right trigger to accelerate, left trigger to reverse. The left joypad is used for the steering angle.

Documentation index — full table of contents.

Requirements

To run experiments with a joystick, you need to run CRS on a Linux machine, since only Linux supports passing USB devices into the container.

Tutorial

  1. Attach the joystick. Only USB was tested, but Bluetooth should also work.
  2. On your host machine, outside of docker, identify the joystick you want to use.
ls /dev/input/*

Usually, the joystick will show up as something like /dev/input/js0.

  1. Copy the following Git patch and change $YOUR_JOYSTICK according to the device you found.
diff --git a/.setup/ubuntu/docker-compose-ubuntu.yaml b/.setup/ubuntu/docker-compose-ubuntu.yaml
index 6d2d3a49..eb703c14 100644
--- a/.setup/ubuntu/docker-compose-ubuntu.yaml
+++ b/.setup/ubuntu/docker-compose-ubuntu.yaml
@@ -13,6 +13,7 @@ services:
       - /dev:/dev:rw
     devices:
       - /dev/dri:/dev/dri
+      - /dev/input/$YOUR_JOYSTICK:/dev/input/js0
     environment:
       - DISPLAY=$DISPLAY
       - QT_X11_NO_MITSHM=1
  1. In the root CRS folder, run git apply and then paste the patch from above.1
  2. Run the container, and inside the container, test if the joystick is present:
root@cfa7e4a6eb63# jstest /dev/input/joy
  1. Run with a joystick! If the joystick is not recognized by CRS, you might need to specify dev:=/dev/input/$YOUR_JOYSTICK_DEVICE.
root@cfa7e4a6eb63# roslaunch crs_launch joystick_car.launch

How does it work?

The joy_node interfaces with the joystick and publishes on /car/joy. The controller_node then reads the joystick buttons and publishes appropriate throttle/steer inputs.

Footnotes


  1. Why is the patch necessary? To attach the device through docker compose, the device needs to be available when running CRS, otherwise an error is generated. Not many people use joysticks, so you will have to manually add the device to the compose definition file.