Controlling external devices with Lua Scripts on Ardurover (BlueBoat Winch!)

Hi gang!

While on a recent trip to our R&D facilities in Victoria, Canada, I had the chance to dust off an old senior design group project that some of our engineers developed - a Winch! While we hope to develop this into a product eventually, the bit of work I did upgrading the control system to use the Navigator / BlueOS (vs. Arduino) may help many of you out there with your projects. Using only a simple lua script, we were able to demonstrate the vehicle going to waypoints and automatically lowering and raising a payload!

And before anyone asks, no we don’t have any timeline for when a winch product for the BlueBoat may be available — but it is on our minds!

We also experimented some with a towfish carrying the Cerulean Omniscan (seen at the start of the video), but that’s a topic for another post…

So how does it work?!?

A large brushless motor was connected to a Basic ESC500, and controlled from output #5 of the Navigator. It drives the winch via a planetary gear train, and we found speeds that worked well for the motor to handle the load - slower on the descent, and faster on the ascent to overcome the torque. Using an alternative ESC, like a VESC with position feedback from the motor would make this less necessary, and would also give you rotational feedback for control!

A limit switch fitted in the payload receiver (black cone) detects a steel ball clamped to the slim tether when it is in the retracted position. It is connected to the 6.6V ADC on the Navigator, with an appropriate resistor so the output signal fluctuates between ~0.5 and ~1.6V DC.

The Fathom tether is connected to a slip-ring, but this is not used with this project. The payload is a simple Celsius and Bar30 data logger, with a single 18650 powering a Raspberry Pi Zero. A USB charge control board is the only other component crammed into the smallest 2" locking enclosure available. Data can be downloaded via Wifi - but this device is a topic for another post…

But wait, that’s how the hardware works… what about the software?!?

Lua scripts are a very powerful way to create custom actions in conjunction with Ardupilot and BlueOS, and with ArduRover 4.5+ many things are possible! Using the File Browser, any .lua script file located in /ardupilot_logs/firmware/scripts is automatically run when the autopilot is started (you’ll need to restart the autopilot after putting a script there to activate it.)

We’re working on improving our documentation around Lua scripts, but hopefully the attached example gets you started!
winch.lua (4.5 KB)
This is a good Lua script example resource as well.

The winch.lua script monitors the state of the vehicle, and if in auto mode, triggers at all waypoints. It should be easy to modify to trigger at waypoints that match those on a list, or some other condition. Once at a waypoint and triggered, the vehicle enters loiter mode and waits a moment - this wasn’t done in the video, and seemed like it could help to have the vehicle stabilize position before dropping lines near the propellers! Once done with the lowering phase, it waits for a period, and then reverses the motor output, drawing the payload in until the sensor detects the return or the time limit is hit.
The only other setup required is setting the Servo5 function to “Winch” - that way the script automatically knows which channel to control!

The motor test script was used just to check the motor function on the bench, along with the adc_test script to check the signal from the proximity sensor. Once done with these, they were renamed with a .lua_disabled extension so as to not interfere with winch.lua, but still be on hand for easy testing!
adc_test.lua (502 Bytes)
motortest.lua (1.2 KB)

All the script functionality was verified before field testing with the SITL functions of BlueOS, but once again that’s a topic for another post as well…

I hope this post is helpful - please let me know if you want any additional details. You can see the default lights.lua script provides the blinking NavLight functionality with the BlueBoat - and is easy to modify to your preferences. Please share your own lua script adventures!

7 Likes

Awesome post @tony-white - thanks for sharing! :smiley:

Just commenting to add that for people who are interested, there is:

1 Like

3 posts were merged into an existing topic: BlueBoat NavLight LED shining without flashing

Cool design! I’m tinkering with a similar project right now, starting with electric anchor winches but their minimum radius is a bit small. Is your drum a custom design?

Hi @alloy55 -
Thanks! The drum is indeed a custom 3D printed component. Depending on the cable you use, a smaller drum might be ok!

Hi @alloy55 and @tony-white,

I really love this winch concept!
Have you had the opportunity to work on it any further since your last updates?

Also, would it be possible to share the hardware design files (e.g., drum and gear model, mechanical drawings, or any build notes) so that the community can experiment with and perhaps contribute to the design?

Thanks for the inspiration — I think this could be a great addition for many BlueBoat projects!

Hello @tony-white

I am also interested in creating a similar setup. I am wondering if you can provide any information on the components you have used? Thanks in advance.

Hi @tony-white

Is the script meant only for autonomous use? I would like to add a winch to my USV that has BR products for the navigation system. I have a winch that is run by a Digilent DMC 60 which is controlled by PWM inputs. Is this something that I could connect to the Navigator and run manually? I would like to be able to lower a SVP (Sound Velocity Profiler) manually with the winch at desired places where we are doing survey.

Thanks in advance.

Hi @SweUSV -
That script is meant for use in auto mode, switching to loiter mode and doing stuff with a winch via PWM output, which would be compatible with your ESC. If you’re looking to just manually control an output channel, to winch out and in, you could do that with a simple control in Cockpit… (manually)

Hi @tony-white -

I’m not quite sure I follow, could you please clarify? We are unfortunately not using Cockpit and do not have plans to change as the USV works as intended at the moment. Would it be possible to use BlueOS to program the use of a winch or would this only be possible in Cockpit?

Hi @SweUSV -
Apologies - I was jumping to the idea of you manually controlling your servo via the GCS software. This is also possible to do in QGC, but definitely more of a hassle.

If you want things to happen with the winch at waypoints, automatically, than the lua script related to winch control is the best starting point for your application. This would let you have a cast sequence occur at whatever desired waypoint(s) (odds, evens, a specific #, etc.)

In either case, you can indeed connect your servo ESC to one of the available outputs of the Navigator, and configure it to be used by mavlink message or lua script servo output control.

1 Like

Thanks for the clarification @tony-white .

The QGC solution definitely seems like it is a bit of a hassle but I already have someone in mind that may be able to figure it out for me.
Thanks for the input.