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!

6 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