joystick: add "reverse" mode and "gain" functionality#2477
joystick: add "reverse" mode and "gain" functionality#2477ES-Alexander wants to merge 5 commits into
Conversation
612edcb to
1672a31
Compare
1672a31 to
945c25b
Compare
|
I've just raised #2480, and realised this is probably the ideal place to implement that, because then both can be made available simultaneously (and these definitions will likely be hard/annoying to migrate for users once they already have them). Implementing both gain and reversing in a single compound variable would also be marginally more performant, because then the output messages only need to pull in one "scale" variable value. |
945c25b to
00b7ed1
Compare
- Avoids reversing the vertical or yaw axes, as we typically intuit those as world-frame. - Only applies gain to translation axes by default - Users can edit the compound variables if they want to add it to rotations as well
00b7ed1 to
810ef8f
Compare
|
Noting that ideally gain steps (and range?) should be configurable from the joystick config. While the JS_GAIN params still exist in ArduSub, it may be necessary for Cockpit to set the From some discussion with the product experience team, we likely want to have announcements when the Cockpit gain changes (or it goes in/out of reverse mode), so I'll need to add those as well. |
| registerActionCallback(availableCockpitActions.reduce_pilot_gain, () => { | ||
| const gain = Number(getDataLakeVariableData(gainVariableId)) | ||
| const steps = Number(getDataLakeVariableData(gainStepsVariableId)) | ||
| setDataLakeVariableData(gainVariableId, Math.max(0, gain - 1 / steps)) |
There was a problem hiding this comment.
| setDataLakeVariableData(gainVariableId, Math.max(0, gain - 1 / steps)) | |
| // Do not allow stepping below the step size | |
| setDataLakeVariableData(gainVariableId, Math.max(1 / steps, gain - 1 / steps)) |
It would likely be painful to try to enforce a minimum gain variable (and subject to race conditions), so this seems like a reasonable preventer of 0 gain for users who aren't explicitly setting the value.
Based over #24761 and #2478 (the first two commits) - I figured it would be easier to review them separately and rebase this over master before it gets reviewed. If not, we can just review and merge this one instead of those 🤷♂️
Fixes #2221, by adding a base
reversedata-lake variable (which can be used to trigger additional related functionality), then splitting that into per-axis compound variables*. The base variable can be directly (momentarily) controlled by a joystick button, or statefully controlled with the provided Actions.Fixes #2480, with a base
gaindata-lake variable, and applying it by default to only translation axes (a suggestion from @Williangalvani) for each vehicle type, falling back to a gain of 1 for rotation / undefined axes. The base variable can be directly controlled with range input widgets (like a slider), or incremented and decremented with the provided Actions. Unlike the reversing state, the gain state and number of steps are persistent across reboots.Footnotes
If you've been testing joystick: migrate MANUAL_CONTROL axes to data lake #2476, you'll need to delete the
Axis * Outputcompound variables before this one will work, since it doesn't currently include a migration. ↩