Add Channels 5-8 to Joystick Controls
I would like to perform gain tuning and other general actions with a joystick in SIL (Taranis x9d+ as joystick on channel 5-8). What is the best way to do this? New mavlink msg or mavlink override RC?
From the SDL library, the taranis is seen as a 8-axis joystick with channels 9-32 as buttons, but channels 5-8 are not being seen in QGC as shown from Joystick.cc L547 where roll, pitch, yaw, and throttle are mapped to the joystick axes and 9-32 are passed as buttonPressedBits.
Joystick.cc : L547
emit manualControl(roll, -pitch, yaw, throttle, buttonPressedBits, _activeVehicle->joystickMode());`
The commands use the mavlink message 69 and sent in UAS.c L1020
UAS.cc : L1020
// Send the MANUAL_COMMAND message
mavlink_msg_manual_control_pack_chan(mavlink->getSystemId(),
mavlink->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
&message,
this->uasId,
newPitchCommand, newRollCommand, newThrustCommand, newYawCommand, buttons);
I could create changes to override RC channels by creating a mavlink_msg_rc_channels_override_pack_chan function using the RC_CHANNELS_OVERRIDE mavlink message something like this...
// Send the RC_CHANNELS_OVERRIDE message
mavlink_msg_rc_channels_override_pack_chan(mavlink->getSystemId(),
mavlink->getComponentId(),
_vehicle->priorityLink()->mavlinkChannel(),
&message,
this->uasId,
newChannel5Command, newChannel6Command, newChannel7Command, newChannel8Command);
OR
I could extend the MANUAL_CONTROL mavlink message and change the mavlink_msg_manual_control_pack_chan function to include the extra channels
MAVLINK common.xml : L3495
<message id="69" name="MANUAL_CONTROL">
<description>This message provides an API for manually controlling the vehicle using standard joystick axes nomenclature, along with a joystick-like input device. Unused axes can be disabled an buttons are also transmit as boolean values of their </description>
<field type="uint8_t" name="target">The system to be controlled.</field>
<field type="int16_t" name="x">X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.</field>
<field type="int16_t" name="y">Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.</field>
<field type="int16_t" name="z">Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.</field>
<field type="int16_t" name="r">R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.</field>
<field type="uint16_t" name="buttons">A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.</field>
<extensions/>
<field type="int16_t" name="chan5">axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Corresponds to movement on joystick channel 5</field>
<field type="int16_t" name="chan6">axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Corresponds to movement on joystick channel 6</field>
<field type="int16_t" name="chan7">axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Corresponds to movement on joystick channel 7</field>
<field type="int16_t" name="chan8">axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Corresponds to movement on joystick channel 8</field>
</message>
Adding the extension to the MAVLINK message 69 might be the best way and then updating QGC and PX4/firmware, but wanted to post this for discussion.
Addtional info:
- GCS OS: Ubuntu 18.04 LTS
- QGC version: source commit d905745d282ee1a5a3025ca374ec25d03c7638f3
- Autopilot board: Pixhawk4
- Autopilot firmware: PX4 (custom based on v1.8.2)
This needs RC_OVERRIDE joystick which is not currently supported in QGC.
Any update?