donkeycar icon indicating copy to clipboard operation
donkeycar copied to clipboard

No throttle control when using XBox One gamepad in local control

Open TCIII opened this issue 4 years ago • 5 comments

SBC: NVIDIA Nano 4GB OS: Jetpack 4.5.1 DC: 4.10

The XBox One gamepad is paired and connected to the Nano OS and during "manage.py" drive button pushes on the gamepad show the expected response on the CLI.

I have set USE_JOYSTICK_AS_DEFAULT = True in "myconfig.py", however when running manage.py drive, there is no throttle output from the PCA9685, other than a constant 1,500 us PWM output, when I move the XBox One the right joystick forward or backwards.

A review of the "controller.py" part shows that is it missing hex keycodes for the right joystick horizontal and vertical, the left joystick vertical, and several other hex keycodes.

I have used the jstest program and all of the XBox One gamepad joysticks and buttons are fully functional.

TCIII avatar Jan 28 '21 15:01 TCIII

The right joystick is actually not used when using the XBox One Controller. We use the shoulder buttons instead. The right trigger is accelerator, and the left trigger is braking.

tikurahul avatar Jan 28 '21 18:01 tikurahul

@tikurahul,

I beg to differ with you. From the "controller.py" part:

"self.axis_trigger_map = { 'left_stick_horz': self.set_steering, 'right_stick_vert': self.set_throttle, # Forza Mode 'right_trigger': self.magnitude(), 'left_trigger': self.magnitude(reversed = True),

This also appears in the "manage.py drive" startup XBox One "Joystick Control" CLI output:

left_stick_horz | set_steering | | right_stick_vert | set_throttle | | right_trigger | set_magnitude | | left_trigger | set_magnitude

To not be consistent with the operation other gamepads will just lead to beginner heartburn.

TCIII avatar Jan 28 '21 19:01 TCIII

To not be consistent with the operation other gamepads will just lead to beginner heartburn.

Respectfully disagree. There is almost no overlap in users who use PS5 vs XBox and game pad conventions and expectations are very different. That being said - I wrote the Xbox controller this way, because this seemed a lot more intuitive to me when driving the car. You are welcome to write a configurable part that solves your use-case.

tikurahul avatar Jan 28 '21 22:01 tikurahul

I decided to reopen this issue after having further experimented with the present XBox One gamepad configuration and have found the following: Left joystick horz: IS: "Right/Left steering" Right joystick vert: IS: "Does nothing: Normally: "Forward/reverse throttle" Right trigger: IS: "Increase forward throttle" Left trigger: IS: "Increase reverse throttle" Left shoulder: IS: "E-stop"; S/B: "Decrease max throttle" Right shoulder: is "Does nothing"; S/B "Increase max throttle" A button: IS: "Mode control"; S/B "Mode control" B button: IS: "Recording: False"; S/B :Toggle manual recording" Y button: IS: "Deleted last 100 records"; S/B "Emergency stop" X button: IS: "Does nothing"; S/B: "Erase last N records" View button: IS: "Throttle scale down"; S/B: "Toggle constant throttle"? Menu button: IS: "Throttle scale up"; S/B: ?

I believe that what I have found will help other DC users to understand the present functionality of their XBox One gamepad when used for local control of their race car. Comments please.

TCIII avatar Jan 28 '21 22:01 TCIII

This looks correct. You can probably update the documentation with this keymap.

tikurahul avatar Jan 29 '21 19:01 tikurahul

I'm going to close this. We have a separate issue for refactoring the game controller system to allow all functions to be remapped. https://github.com/autorope/donkeycar/issues/1097

Ezward avatar Mar 04 '23 01:03 Ezward