Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Scripting: applet for Plane follow on a switch #27137

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timtuxworth
Copy link
Contributor

@timtuxworth timtuxworth commented May 22, 2024

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 timtuxworth marked this pull request as draft May 22, 2024 17:10
Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripting checks are also reporting:

    libraries/AP_Scripting/applets/plane_follow.lua:20:7: unused variable ALT_FRAME_ABSOLUTE
    libraries/AP_Scripting/applets/plane_follow.lua:75:7: unused variable have_target
    libraries/AP_Scripting/applets/plane_follow.lua:118:7: empty if branch
    libraries/AP_Scripting/applets/plane_follow.lua:132:10: unused variable target_sysid
    libraries/AP_Scripting/applets/plane_follow.lua:145:10: unused variable vehicle_location
    libraries/AP_Scripting/applets/plane_follow.lua:152:21: value assigned to variable target_offsets is overwritten on line 153 before use

ArduPlane/ArduPlane.cpp Outdated Show resolved Hide resolved
ArduPlane/ArduPlane.cpp Outdated Show resolved Hide resolved
ArduPlane/ArduPlane.cpp Outdated Show resolved Hide resolved
ArduPlane/navigation.cpp Outdated Show resolved Hide resolved
libraries/AP_Scripting/generator/description/bindings.desc Outdated Show resolved Hide resolved
libraries/AP_Scripting/docs/docs.lua Outdated Show resolved Hide resolved
libraries/AP_Scripting/docs/docs.lua Outdated Show resolved Hide resolved
Copy link
Collaborator

@Hwurzburg Hwurzburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@timtuxworth
Copy link
Contributor Author

This is a draft for comm

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

Done

@timtuxworth
Copy link
Contributor Author

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
Copy link
Contributor Author

The scripting checks are also reporting:

How can I run these checks myself?

@IamPete1
Copy link
Member

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 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants