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 10 commits 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.

Upated, but still draft. The speed adjustment still needs work when the following plane gets very close to the target. (suggestions appreciated).

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
@@ -203,6 +203,7 @@ void Plane::calc_airspeed_errors()
target_airspeed_cm = constrain_float(MAX(guided_state.target_airspeed_cm, target_airspeed_cm), aparm.airspeed_min *100, aparm.airspeed_max *100);
}

//GCS_SEND_TEXT(MAV_SEVERITY_INFO, "navigation guided - airspeed target cm: %d", target_airspeed_cm);
Copy link
Member

Choose a reason for hiding this comment

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

remove all debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

libraries/AP_Scripting/generator/description/bindings.desc Outdated Show resolved Hide resolved
libraries/AP_Scripting/docs/docs.lua Outdated Show resolved Hide resolved
@@ -2349,6 +2349,12 @@ function vehicle:nav_scripting_enable(param1) end
---@return boolean
function vehicle:set_desired_speed(param1) end

-- desc
Copy link
Member

Choose a reason for hiding this comment

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

Full descriptions now please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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?

@@ -3309,7 +3321,12 @@ function follow:get_last_update_ms() end
function follow:have_target() end

-- desc
scripting = {}
Copy link
Member

Choose a reason for hiding this comment

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

need this still.

@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants