Hi @Cnidaria_97,
Thanks for the well-structured post, and specifying what you’ve tried so far, as well as where and how that’s failed and been confusing! ![]()
Our documentation and examples are still somewhat limited for expansion use-cases like this, but this is actually very straightforward with Cockpit’s Custom Actions functionality, and doesn’t require custom scripting at all.
For each PWM value you want to set, you can
- Create a new Custom MAVLink Action
- Specify the message type as
COMMAND_LONG, with the command ID set toMAV_CMD_DO_SET_SERVO - Set the parameter 1 field to the the desired servo output pin[1] number (of the Navigator’s servo connector), and parameter 2 to the relevant µs pulse-duration (PWM value).
- Choose that Action in your joystick button function configuration, for the button you want to trigger it with
This is related to mapping dedicated joystick button functionalities in ArduSub to the servo output bus on the flight controller board it’s running on, and is a longstanding point of confusion that we’re actively working on improving (both in the firmware, and the documentation).
If you’re not using ArduSub’s built in button functions (e.g. if you’re using separate MAVLink messages, like described above) then all you need to think about is the pin numbers on your flight controller board.
For the curious:
If you want to use the servo_n_min/max/... button functions built into ArduSub then they currently correspond to n-8 for the Navigator pin numbers. This hearkens back to the Pixhawk flight controller board they were originally developed for which had its servo bus split into two groups, with 8 MAIN outputs that needed to be dis-counted when trying to control one of its 6 AUX outputs.
We’re working on refactoring the servo control functionality from using hardcoded values to reconfigurable Actuator outputs (in a similar way to the existing RELAYn_PIN functionality), but for now ArduSub includes default joystick button functions for just three servo outputs which are hardcoded to pins 9, 10, and 11.
Note that you’ll need the corresponding
SERVOn_FUNCTIONparameter in ArduSub configured asDisabled (0)so that you can set custom PWM values for it, instead of using one of ArduSub’s predefined functionalities. This is likely already the case, but worth noting in case it’s not working as expected / is already in use by a different subsystem of the autopilot. TheSERVOn_MINandMAXparameters will also need to be set outside the range of values you want to use (ideally as the limits of safe values for that device), otherwise the outputs will be undesirably clipped. ↩︎