Skip to content

Commit

Permalink
content: usage: joystick updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ES-Alexander committed Jan 7, 2025
1 parent 9fed42f commit 84e1948
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
83 changes: 61 additions & 22 deletions content/usage/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -663,21 +663,55 @@ various [protocol functions](#joystick-protocols), which can send inputs and com
interface events. Once a function mapping is configured it is possible to export it to the computer and/or the
vehicle, which can then be imported later to new Cockpit instances/devices.

{{ easy_image(src="../getting-started/joystick-config", width=600, center=true) }}
Known joysticks have an interactive diagram for mapping button and axis functions visually:
{{ easy_image(src="joystick-button-mapping", width=600, center=true) }}

Button presses and axis movements should be mirrored on the diagram, and clicking on a button
element in the diagram allows remapping its mapped function.

{% note() %}
Axes currently must have unique functions, so mapping an axis to an Action that is already in
use will result in that Action being unmapped from whichever axis was using it previously.
{% end %}

There is also a table view, which is available for both known and new joystick types:
{{ easy_image(src="joystick-table", width=600, center=true) }}

Buttons can be remapped to different Actions using the edit pencil at the far right of the corresponding row.

{% note() %}
Support is built in for simultaneous input from multiple sources, including multiple joysticks, and by
default each joystick can provide up to 8 axis ranges and 32 buttons.
default each joystick can provide up to 32 axis ranges and 32 buttons.
{% end %}

#### Joystick Protocols

When mapping the functionality of a joystick button or axis, there are multiple protocols to choose from:

{{ easy_image(src="joystick-button-mapping", width=500, center=true) }}
{{ easy_image(src="joystick-protocols", width=500, center=true) }}
{{ easy_image(src="joystick-axis-mapping", width=500, center=true) }}


##### MAVLink `MANUAL_CONTROL` Messages

[`MANUAL_CONTROL`](https://mavlink.io/en/messages/common.html#MANUAL_CONTROL) MAVLink messages are
automatically sent to the vehicle at 25Hz, which is not currently configurable.
automatically transmitted at 25Hz, which is not currently configurable.

{% note() %}
While it is generally expected for there to be a vehicle connected, Cockpit is capable of sending
MAVLink Messages to a MAVLink system more generally, even without a vehicle included.
{% end %}

{% warning() %}
If the browser tab is changed away from Cockpit, or the Cockpit application window is minimised,
Cockpit loses access to the joystick inputs, and normally stops sending `MANUAL_CONTROL` messages
to reflect the loss of input. This can trigger an autopilot failsafe, which may not be desirable,
so an option is provided in the top right of the joystick page to tell Cockpit to repeatedly send
the last joystick input it received before losing access to the joystick.
>
>It is important to **always be conscious of where your vehicle is**, and what kind of hazards it
is operating near.
{% end %}

Button functions are determined by the autopilot firmware - e.g. in ArduSub they correspond to
[`BTNn_FUNCTION`](https://docs.bluerobotics.com/ardusub-zola/software/autopilot/ArduSub-4.1/developers/parameters/#btnn-function-function-for-button)
Expand Down Expand Up @@ -708,19 +742,8 @@ is raised to notify that the configured mapping is not fully as designed.
##### Cockpit Actions

Joystick buttons can also be configured to run more general functionalities, like modifying the interface or
sending a single MAVLink message. The current default Actions are:

- `go_to_next_view`
- `go_to_previous_view`
- `toggle_bottom_bar`
- `toggle_full_screen`
- `hold_to_confirm`
- `start_recording_all_streams`
- `stop_recording_all_streams`
- `mavlink_arm`
- `mavlink_disarm`

It is also possible to define your own [custom Actions](#custom-actions), or import them from files.
sending a single MAVLink message. These options can be provided (or defined) using
[Cockpit's Action system](#cockpit-actions-1).

##### Modifier Keys

Expand All @@ -735,7 +758,7 @@ functionality slots.

##### Other

Currently only used for the "No Function" option.
Currently only used for the "No Function" option, which is used when a button or axis input is unmapped.

#### Custom Joysticks

Expand Down Expand Up @@ -842,12 +865,26 @@ If you want a similar feature for joystick button functions, consider assigning
can be triggered.
{% end %}

### Custom Actions
### Cockpit Actions

Cockpit's Action system provides a set of functionalities that can be triggered from any of Cockpit's
supported input sources (e.g. joystick buttons, interface elements, other Actions, etc). There are
some predefined ones, but it is also possible to define (and export or import) custom Actions with a
few different approaches:
supported input sources (e.g. joystick buttons, interface elements, other Actions, etc).

#### Default Actions
There are some predefined Actions built into Cockpit for convenience, including:

- `go_to_next_view`
- `go_to_previous_view`
- `toggle_bottom_bar`
- `toggle_full_screen`
- `hold_to_confirm`
- `start_recording_all_streams`
- `stop_recording_all_streams`
- `mavlink_arm`
- `mavlink_disarm`

#### Custom Actions
It is also possible to define (and export or import) your own custom Actions, with a few different approaches:

{{ easy_image(src="custom-actions-config", width=500) }}

Expand All @@ -859,6 +896,8 @@ few different approaches:
- **HTTP Request Actions** can send arbitrary HTTP requests, including custom URL parameters, headers,
and a JSON body
- These are best for basic communication with arbitrary APIs
- Parameters that are defined using [Input Widgets](#input-widgets) can be easily modified during
operation
{{ easy_image(src="custom-http-action", width=400, center=true) }}
- **JavaScript Actions** are a blank canvas, with all the possibilities (but also the complexities) of
programming your own functionalities
Expand Down
Binary file added content/usage/advanced/joystick-axis-mapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/usage/advanced/joystick-protocols.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/usage/getting-started/joystick-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 84e1948

Please sign in to comment.