Using LUA script to adjust the speed in Loiter mode

As the tittle, does anyone know if it is possible or not? In my case, I want to limit/reduce the speed in Loiter mode when working in Simple Avoidance mode. The drone needs to be slow down when pilots input the roll/pitch direction toward the obstacles. I will read the input of roll/pitch stick and compare it to the direction of obstacles, therefore calculating appropriate Loiter speed and override it to “Desired Speed” of the controller.

Is this thing possible? It would be nice if this catches you eyes.

Yes this is possible, you can read in distances from the rangefinders and change the loiter speed parameter.

Doesn’t Simple Avoidance already do this? This exact thing…
Do you want the same algorithm implemented in Lua?

1 Like

Yes it is. The current Copter 4.0.4 allows you to adjust, but the problem is, sometime we just want the copters to be slow down at longer distance from the obstacles. To be more specific, the large vehicle (>30kg) is really massive, the “jerky” state may cause crashing.

Thanks @iampete. In the past, I did that way but using Mavlink Message for live updating the LOIT_SPEED parameter. Everything seemed well so far but I am not sure if it has been the appropriate way or not. If yes, is it okay for doing the same with LUA script?