ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

AP_Scripting: applet for Plane follow on a switch

Open timtuxworth opened this issue 1 year ago • 4 comments

DRAFT for comment. This builds on the existing plane_guided_follow.lua example. It adds speedup/slowdown so the following vehicle can "catch up" with the target and prevents guided mode from attempting to loiter around the target vehicle when it gets close. Also adds FOLL_ACT_FN so that an RC switch can be used to trigger/exit the follow.

Note the change to GCS_Mavlink.cpp, without this one line in handle_command_int_do_reposition to set plane.guided_state.target_heading_type = GUIDED_HEADING_NONE, nothing works. With this line, like magic - follow!

Updated, but still draft. Re-written to use the new MAVLink/Lua interface in #27365

Includes a Lua module for a "PI" controller. This is basically just extracted as is from the plane_aerobatics.lua and generalized so it can be used without copying. Ideally "D" would be added.

timtuxworth avatar May 22 '24 17:05 timtuxworth

This is a draft for comm

this needs a GCS text announcing that its been loaded, like we do in other applets

Done

timtuxworth avatar May 25 '24 16:05 timtuxworth

libraries/AP_Scripting/applets/plane_follow.lua:152:21: value assigned to variable target_offsets is overwritten on line 153 before use

I have to call two methods on AP_Follow to get all the values I need and both of them return target_offsets. Do you think I should refactor the code in AP_Follow so I can call a single method?

timtuxworth avatar May 25 '24 16:05 timtuxworth

The scripting checks are also reporting:

How can I run these checks myself?

timtuxworth avatar May 25 '24 18:05 timtuxworth

How can I run these checks myself?

This should work:

apt install lua-check
./Tools/scripts/run_luacheck.sh 

You can also run the new checks with:

python ./Tools/scripts/run_lua_language_check.py 

IamPete1 avatar May 25 '24 21:05 IamPete1