Files
sunnypilot/tools/joystick
jp-solutionz e769f4d11a joystickd: add controller mapping (#25986)
* Correct default controller mapping.

Current config maps steering to right trigger (ABS_RZ) when using a default xinput controller: https://inputs.readthedocs.io/en/latest/user/hardwaresupport.html

This results in default full left steering angle (1) requiring right trigger to return to centre (0) or right (-1).

It appears the intended mapping for steering is right thumbstick (ABS_RX).

Cancel button is also non-existent on default xinput controller. May be X button (BTN_NORTH) or Right Trigger (ABS_RZ).

Tested on Xbox One Controller via USB Cable, Logitech F710 and GameSir T4 Pro.

* Update joystickd.py

Fixed comment

* gamepad configuration

* gamepad arg

Co-authored-by: Cameron Clough <cameronjclough@gmail.com>
old-commit-hash: 1d8fc4d21c
2022-10-12 20:48:22 -07:00
..
2021-06-11 14:33:17 -07:00
2022-05-12 13:40:05 +02:00

Joystick

Hardware needed: device running openpilot, laptop, joystick (optional)

With joystickd, you can connect your laptop to your comma device over the network and debug controls using a joystick or keyboard. joystickd uses inputs which supports many common gamepads and joysticks.

Usage

The car must be off, and openpilot must be offroad before starting joystickd.

Using a keyboard

SSH into your comma device and start joystickd with the following command:

tools/joystick/joystickd.py --keyboard

The available buttons and axes will print showing their key mappings. In general, the WASD keys control gas and brakes and steering torque in 5% increments.

Joystick on your comma three

Plug the joystick into your comma three aux USB-C port. Then, SSH into the device and start joystickd.py.

Joystick on your laptop

In order to use a joystick over the network, we need to run joystickd locally from your laptop and have it send testJoystick packets over the network to the comma device.

  1. Connect a joystick to your PC.
  2. Connect your laptop to your comma device's hotspot and open a new SSH shell. Since joystickd is being run on your laptop, we need to write a parameter to let controlsd know to start in joystick debug mode:
    # on your comma device
    echo -n "1" > /data/params/d/JoystickDebugMode
    
  3. Run bridge with your laptop's IP address. This republishes the testJoystick packets sent from your laptop so that openpilot can receive them:
    # on your comma device
    cereal/messaging/bridge {LAPTOP_IP} testJoystick
    
  4. Start joystickd on your laptop in ZMQ mode.
    # on your laptop
    export ZMQ=1
    tools/joystick/joystickd.py
    

Web joystick on your mobile device

A browser-based virtual joystick designed for touch screens. Starts automatically when installed on comma body (non-car robotics platform). For cars, start the web joystick service manually via SSH before starting the car.

tools/joystick/web.py

After starting the car/body, open the web joystick app at this URL: http://[comma three IP address]:5000


Now start your car and openpilot should go into joystick mode with an alert on startup! The status of the axes will display on the alert, while button statuses print in the shell.

Make sure the conditions are met in the panda to allow controls (e.g. cruise control engaged). You can also make a modification to the panda code to always allow controls.