Cockpit slider to control light brightness

Hi, we are using the BR Navigator with the hd camera as a tether camera and need to add a slider to cockpit for controlling the light brightness. What is the easiest way to do this? We’ve fiddled with buttons and sliders in the input widget section, but without success. We are not using a joystick. We are using a Windows tablet for running cockpit standalone and need a big’ish slider for banana fingers as this will be used on a small boat.

1 Like

Hi @hendrikjvr, welcome to the forum :slight_smile:

We don’t yet have good documentation / guides for this kind of functionality at the moment, although that is something I’m actively working on.

I’ll try to put a walkthrough here for your specific use-case, to help me write more complete documentation afterwards, and improve our interface (since the process is currently somewhat convoluted):

  1. Check which Navigator pin the lights are connected to

  2. Enter Edit Mode through Cockpit’s sidebar menu, then add your range input of choice to the top or bottom bar, (or in a container widget if you want it somewhere in the main view), and create a variable with a relevant name via the section in the bottom right corner

    • I chose to add a slider (per your request) in a collapsible container, so you can make it wider than the default mini-widget width, and hide it away when it’s not in use
    • In the interests of having a nice interface I used a 0-100 scale, which matches how the Lights (1) level is reported in the very generic indicator preset
  3. Exit Edit Mode, then open Tools / Data-lake via the sidebar menu, and create a new compound variable (top right, “Add compound variable”), so we can convert the slider’s nice percentage input into PWM outputs the autopilot can use to control the lights

    • Note that Cockpit’s sliders generate decimal values, so rounding to an integer is required for the autopilot to accept the number
    • Compound variable creation could be skipped if you use a Dial input with the range already matching the output values (1100-1900), but that’s likely less intuitive and more challenging to use

  4. Close the data lake menu, then go to Settings / Actions in the sidebar menu, and create a new MAVLink Message Action

  5. Configure it as a COMMAND_LONG message with

    • ID: MAV_CMD_DO_SET_SERVO message
    • parameter 1: the pin you want to control, and
    • parameter 2: the variable you want to set its value from - curly brackets essential!

  6. Set up an automatic trigger for the Action by linking it to one of the relevant variables (e.g. the slider variable or the resulting compound variable), to send a new command each time the slider gets updated

    • A high update rate limit allows smoother control, but sends more messages while you’re moving the slider, which can cause performance issues (especially for more performance-heavy Actions)


  7. The slider should now work to control the Lights1 level output

    • If your lights pin changes, you’ll also need to update the Action
      • Ideally the autopilot would figure out which pin you want automatically, but that’s not the case at the moment unless you’re using ArduSub’s lights joystick button functions, which don’t provide the fidelity of a slider (they’re just fixed percentage increment/decrement buttons, and require using the full joystick control pipeline)

I am assuming here that you’re running ArduSub autopilot firmware on your Navigator.
If you’re not running an autopilot then there would be alternative solutions via a BlueOS Extension like NodeRED or OpenVSCode combined with a Cockpit HTTP request Action, but the rest of the process is similar. Alternatively you could run Navigator Web Assistant and embed an external widget in Cockpit for lights control, which is a very different process with a similar result.

If the vertical height of the slider is a problem, not just its width, then you could make a custom one via a DIY widget, although that seems like a lot of effort for limited gain.

7 Likes

@EliotBR Thank you very much! Exactly what we were looking for. Works great.

2 Likes

thanks @EliotBR this looks interesting! However I can’t see where the option to add input widgets is? I assume there should be a button near the regular/mini widgets, however there isnt one I can see (image below). I am using Blue OS 1.4.2 and Ardupilot 4.5.3. What am I missing here? Any ideas?

Thanks

ah nevermind, had to update Cockpit extension.

2 Likes