We have an application where we want to run Cockpit without a joystick and instead control the lights and camera tilt through pushbuttons within Cockpit.
So far, I have tried adding MAVLink actions which generate ManualControl messages for the associated button presses. I can then associate those with input widgets in the interface, and it “works” with some undesirable behavior. Tilt up/down goes all the way to the extents with a single press, while the lights can only be incremented by one “step” up or down, then does not increment any further.
I’m mostly convinced this is consistent with the button never being “unpressed” – the ManualControl messages stop when you release the widget, but a ManualControl message with “no button pressed” is never sent.
Is there a smarter way to do this? Reading around a bit, maybe I can get more sophisticated behavior with a Javascript action?
Indeed. This approach would be more effective if you added a “stop” button that sends a MANUAL_CONTROL message with all the buttons un-pressed.
That said, MAVLink is not confined to joystick-related messages (in fact, we’re largely trying to move away from dependence on the autopilot interpreting button inputs), and there are almost certainly better ways of achieving what you’re after
If your camera tilt servo has its output assigned to the MountTilt function, camera tilt control should be possible in a similar way using MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW messages, though it may also be required to specify the mode (like we do in BlueOS).
EDIT: We have confirmed that it works to use MAV_CMD_DO_MOUNT_CONTROL, with param1 set to the angle you want (e.g. using a data-lake variable), and param7 set to RC_TARGETING (3)
@EliotBR Thanks for all the help. I was able to get this working yesterday. Before I saw your update, I set up the pitch motor to be controlled with MAV_CMD_DO_SET_SERVO, I can confirm this works as well.
A couple of brief notes for the record:
I found I needed to use the full path for variables (e.g. user/compound/light1pwm rather than light1pwm)
For mount control, I needed to set param7 to MAV_MOUNT_MODE_MAVLINK_TARGETING I’m sure this is a minor difference in backend Ardupilot configuration.