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: quadplane terrain avoidance with "can't make that climb" #28625

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

timtuxworth
Copy link
Contributor

@timtuxworth timtuxworth commented Nov 15, 2024

This is a Lua script that runs continually while a quadplane is in AUTO mode (typically running a mission) and monitors LIDAR readings for dangerously close terrain. If the terrain gets too close, the script will take over the quadplane performing one of three avoidance maneouvers:

  1. "Pitching" the plane will pitch up at the maximum rate/speed possible (subject to TECS limits)
  2. "Quading" the plane will switch to QLOITER mode and use the VTOL motors to gain altitude as quickly as possible
  3. "Can't make that Climb" - the plane will circle left or right up to a safe altitude above approaching terrain.

This has been extensively tested in the wilds of northern Canada.

Here's a video of a RealFlight demo which demonstrates each kind of avoidance https://youtu.be/wbSNbGx1tDM

@timtuxworth
Copy link
Contributor Author

Hi @IamPete1 and @peterbarker - I wonder if you could take a look at this. It's mostly a Lua script with some added bindings.
Is there anyone else who could/should review it?

@@ -3043,7 +3043,6 @@ function terrain:status() end
---@return boolean
function terrain:enabled() end


Copy link
Member

Choose a reason for hiding this comment

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

Left over white space change.

return true
end

return MAVLink
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return MAVLink
return MAVLink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that a standard/recommended style? I like it like this if I don't have to change it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, standard to have a blank line at the end of the file. You will notice guthub puts a little stop sign there to warn you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I thought you were talking about the blank line before the return. No worries. I'll fix it.

Comment on lines +71 to +75
local now = millis():tofloat() * 0.001
if not _last_t then
_last_t = now
end
local dt = now - _last_t
Copy link
Member

Choose a reason for hiding this comment

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

Do the DT first and then convert to float. That prevent lose of precision at millis get larger.

-- I = calculated Integral component
-- Total = calculated new Airspeed
-- Add - passed in as 0
logger.write(name,'Targ,Curr,P,I,Total,Add','ffffff',_target,_current,_P,_I,_total,add_total)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.write(name,'Targ,Curr,P,I,Total,Add','ffffff',_target,_current,_P,_I,_total,add_total)
logger:write(name,'Targ,Curr,P,I,Total,Add','ffffff',_target,_current,_P,_I,_total,add_total)

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Dec 16, 2024
@timtuxworth timtuxworth requested a review from Ryanf55 December 16, 2024 22:26
@CraigElder CraigElder changed the title AP_Scripting: quadplane terrain avoidance with can't make that climb AP_Scripting: quadplane terrain avoidance with "can't make that climb" Dec 16, 2024
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.

4 participants