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

LUA: Add a function to retrieve the landed state #27222

Conversation

muramura
Copy link
Contributor

@muramura muramura commented Jun 2, 2024

I want to get the value of LANDED_STATE to determine the landing status in LUA. I will add a method to retrieve the LANDED_STATE. This ticket is related to #27221 .

RESULT
Screenshot from 2024-06-02 15-32-46

LUA SCRIPT
Screenshot from 2024-06-02 17-21-16

Comment on lines 2390 to 2397
-- desc
---@return integer
function vehicle:get_landed_state() end
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 please.

You can enumerate the return states like this:

-- get throttle motor output
---@return integer
---| '0' # Shut down
---| '1' # Ground idle
---| '2' # Spooling up
---| '3' # Throttle unlimited
---| '4' # Spooling down
function motors:get_spool_state() end

@olliw42
Copy link
Contributor

olliw42 commented Jun 2, 2024

this is a bit strange. There is already a landed_state() in GCS_MAVlink which does exactly the same, so it's a good part code duplication. Also, why should only Copter get this lua.

Note that there had been this PR #25459, proposing to move em to the vehicle class, which should also adress this here.

@muramura
Copy link
Contributor Author

muramura commented Jun 3, 2024

@olliw42 san.
In my LUA script, I do not use GCS or MAVLink communication.
I want to know if the vehicle has landed.
I will change the name to GET_LANDED_STATE.

@olliw42
Copy link
Contributor

olliw42 commented Jun 3, 2024

you do not need to use either to call it in lua
the function you define newly here is exactly identical to the function I mentioned is already there. Whatever name you give it, it doesn't change that fact :)

@muramura muramura force-pushed the AP_Add_a_function_to_retrieve_the_LANDED_STATE branch from e7ef92c to 558f60c Compare June 3, 2024 17:33
@muramura muramura force-pushed the AP_Add_a_function_to_retrieve_the_LANDED_STATE branch from 558f60c to 2377f04 Compare June 3, 2024 17:50
@muramura
Copy link
Contributor Author

muramura commented Jun 3, 2024

I have implemented the process to determine the LAND state in the COPTER.
By doing this, multiple methods are no longer needed.
I have added a description of the return value to the LUA function.

@peterbarker
Copy link
Contributor

We have is_landing, is_taking_off and get_likely_flying already available to scripts - making this one entirely redundant.

Please re-open if you don't think that's the case.

@peterbarker peterbarker closed this Sep 4, 2024
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.

4 participants