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:Add disarm on low copter flipping LUA example #29081

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

Conversation

Hwurzburg
Copy link
Collaborator

Contribution from a user who wanted to share it

-- Check roll and pitch
local roll = ahrs:get_roll() * 57.2958 -- Convert radians to degrees
local pitch = ahrs:get_pitch() * 57.2958 -- Convert radians to degrees

Copy link
Contributor

Choose a reason for hiding this comment

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

no big deal but maybe we could remove these extra blank lines


if math.abs(roll) > ANGLE_THRESH or math.abs(pitch) > ANGLE_THRESH then
-- Disarm the drone
arming:disarm() --
Copy link
Contributor

Choose a reason for hiding this comment

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

extra "--" at the end of this line that can probably be deleted

local rotation_downward = 25
local ALT_THRESH = 250 -- Altitude in which in centimeters
local ANGLE_THRESH = 80 -- Roll/Pitch angle threshold in degrees

Copy link
Contributor

@rmackay9 rmackay9 Jan 16, 2025

Choose a reason for hiding this comment

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

Not a blocker but normally we print a message to tell the user that the script has been loaded.

gcs:send_text(1, "copter-disarm-on-flip script loaded")

end
end
else
gcs:send_text(1, "No valid data from downward rangefinder!")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to spam the user at 100hz so perhaps add a "return update(), 1000" to slow it down

@rmackay9
Copy link
Contributor

thanks for adding this. I've made a couple of comments but it's pretty close to merge-able. Could we rename it to start with "copter-"? I think the script is only valid for Copter so having the vehicle at the front makes it more likely that users who can use it will find it and others can quickly ignore it

@Hwurzburg
Copy link
Collaborator Author

@rmackay9 I dont think this actually works, right? unless somehow the RF is updating so slowly that it still shows close to ground as it rotates toward the sky to get the attitude limits evoked...
perhaps, we could make a slowly updating (at least on alt increase, fast on decrease) baro tracking var that is updated via RF so that the alt limit is still active if the attitude is not pointing down any more?

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

Successfully merging this pull request may close these issues.

3 participants