Loiter command, conditional on external input?

Hey everyone! First post here, apologies if this is the wrong place for this.

I have a boat running rover with a winch on it, the winch has a CTD payload that can cast to 300m depth. How this works is the boat navigates to a waypoint, it sends a PWM signal to my winch controller telling how deep to drop the payload, but then I need to have the boat loiter until it receives an aux signal back from my winch controller. Then the boat will move to the next waypoint and repeat the process. I have only been able to manually achieve this with timers, timing how long is takes the winch to drop and recover its payload. It’s a big pain because it requires that I know exactly how long it takes to drop a payload to a certain depth, so I have to time by-hand on land. And if I screw it up, the boat starts moving with the payload down!

The only thing that is missing here to enable these types of winch applications is some kind of “conditional on external input” loiter command, where it will loiter until it receives an external input. That sounds simple! I’d appreciate others thoughts on this.

I don’t have any experience with ardupilot development, so if anyone has any ideas on if it’s possible to hack something together, it would be a huge timesaver for me. Thanks guys!

Hi @eldin_br,

I think this could be done by setting up the PWM input as a “button” and then writing a Lua script to advance the waypoint if it is pushed.

The button setup is not-very-well-documented here on the GPIO wiki page but you can probably figure it out by looking at the BTN_ parameters. This button should be attached to the feedback from the winch.

The Lua script is a little more complicated because it will require a bit of programming. In particular it would required reading the state of the button and if it is pushed advancing the active mission item. We have example scripts for buttons and missions which could help.

To run Lua you’ll probably need a high-ish powered autopilot like a CubeOrange or Holybro Durandal or any other autopilot with an H7 processor. Lua can be made to run on slower autopilots but it is a bit of a pain.