I have a boat based on the ardupilot 4.6.1, blueos 1.5.beta8. The GS (a Windows-based notebook) is connected to the boat via a ZeroTier network. The radiomaster tx16s is configured as a joystick:
RC1 - rudder
RC3 - throttle
Several switches as buttons for controlling relays
Everything works well via the mission planner on the GS
I’ve decided to try the cockpit. It detects my boat well. But I have trouble with configuring tx16 as a joystick. I went to the joystick settings and tried the boat functions mapping as well as mav functions mapping. The cockpit detects axes as well as buttons. I assigned RC_CHANNEL/chan1_raw to axis 0. I closed the form (by clicking the cross ) and the joystick indicator became white… and nothing - the rudder didn’t react to stick movement
Which version of Cockpit are you using? If the option RC_CHANNEL/chan1_raw is showing to you in the joystick mapping, I believe you’re probably running the last stable (1.15.2) or one of the oldest 1.16.0 betas, because this option was actually not meant to be shown there, as this is actually a variable we receive from the vehicle, and not a variable that we send to the vehicle.
In the vehicle side I understand you have already configured the RC1/RC3 values to control your rudder and throttle servos?
Yes, you’re right. I use RC1/RC3 to control rudder and throttle servos… Plus several switches for controlling relays. In the mission planner, I configured buttons (switches on TX16) with “do_set_relay“ and “do_set_servo“.
I’ve open a PR to allow for axes to be used in the data lake. I will merge it on Monday and make a beta12 release with it for you to test.
What you will need to do is to create two data lake variables, link the axes to them, create two mavlink actions to send those to the vehicle and enable auto-trigger on those actions.
The two variables will hold the values that will be sent to those RC channels and the actions with their values will be sent to the vehicle to control those channels. The actions will be sent whenever the axes values change. The actions will be of type COMMAND_LONG with the command types MAV_CMD_DO_SET_RELAY and MAV_CMD_DO_SET_SERVO. You can map min and max for the axes values as needed in the joystick axis config.
@rafael.lehmkuhl I’d like to clarify if button actions work now for surface boat profile? Should I create corresponding variables in data like and assign mavlink commands to them?
I’ve tried unsuccessfully the next: I set up my tx16s as a joystick, and one of 3 pos switches as a normal 3 pos button (ind: 1,2,3). The cockpit detected such buttons without issues. I assigned mavlink protocol: “Custom 1“, “Custom 2“, and “Custom 3“ to them, respectively. I consider that the cockpit should send MAVLink commands such as USER etc. But my Lua script in my FC has never caught anything… May I have missed something? Cockpit -1.16-beta.11.
Can you clarify how your TX16S is connected to your control station computer, running Cockpit?
Do you have it going through a USB adapter to be treated as a standard gamepad controller by the computer, so moving the joystick axes and pressing the buttons light up the corresponding elements in Cockpit’s joystick configuration interface?
If so, and assuming you have a wifi/MAVLink connection to your vehicle, Cockpit’s Actions (including custom MAVLink message ones) and data lake variables should work fine as button functions
Alternatively, do you have it in a more standard GCS ↔ telemetry radio ↔ vehicle ↔ radio controller, where the telemetry radio is connected via a serial link to the control station computer to allow MAVLink telemetry to pass around?
I configured TX16s as a joystick and map two sticks (ruder / throttle) to axis… As well as some switches to buttons. I’ve checked in cockpit’s joystick settings - they detected without issues.
Question. If I want to prevent reactions to switches without arming, what is the best option: 1) scripting on the cockpit level, 2) scripting on the ardupilot level (Lua, e.g. handling some custom mavlink commands, assigned to buttons in cockpit). E.g. I want to switch a gearbox but only when a vehicle is armed
I’d be inclined to avoid sending the message if not armed (e.g. implement it in Cockpit), but you could do either (or both) depending on your requirements.
For the Cockpit approach, you could:
Add a data-lake variable to represent the switch state (e.g. “switch”)
Add a compound data-lake variable for the armed state (e.g. “armed”)
This is then re-usable - if you’re only using it once you can merge it into the next step
Add a compound data-lake variable for the conditional switch state (e.g. “switch if armed”)
{{ armed }} ? {{ switch }} : false
look up the javascript ternary operator to understand how that expression works
Create a custom Action which makes use of the {{ switch-if-armed }} variable (or a compound variable that converts the 0/1 switch values into values that are more meaningful to your function, like PWM values), and gets auto-triggered when that variable changes.
may be worth referring to as examples, but feel free to follow up if something isn’t clear / working as expected
@rafael.lehmkuhl@EliotBR Important question. The throttle doesn’t work . Rudder works (RC1, axis 0 with assigned axis Y, (strange - in tx16s settings it is X)). throttle - in tx16s - RC3, axisY. In cockpit is detected as axis 1. I tried to assign different axes X, Z, etc - nothing. In mission planner - Ok
What did I miss?
I’m not sure which settings you’re referring to, but the convention for axis naming between software is not guaranteed to be consistent.
Cockpit uses the axis inputs as part of MAVLink’s Manual Control protocol, which sends messages to be handled by the connected autopilot. ArduRover’s implementation apparently treats Axis Y as steering input, and Axis Z as the throttle.
If that’s not working correctly then perhaps there’s some other issue with your setup/parameters, or Mission Planner could be using RC channel overrides (which may be handled differently), or there could be an issue with your hardware/configuration (e.g. if you haven’t checked mission planner since you found this problem while trying Cockpit).