-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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 bindings for fence #25446
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, but can we get the example in AP_Scripting/examples for others to build on?
Could you not add some other useful fence bindings at the same time? Love to have (at least): enabled() |
@timtuxworth most of those are available via the parameter bindings, so adding them would just take up flash for no gain |
9587255
to
3e735c3
Compare
Tidied up and added the example, Thanks. @timtuxworth As Tridge says we only add bindings for things that not accessible via params. A few of the things you listed you can pull from params. As a rule of thumb we only add stuff when someone has a need, I'm sure we could come up with situations where users might want a binding for every function in AP, but the more we add costs us flash, memory and performance. This PR adds the bindings I need for my use-case of triggering actions on fence breach. I did originally also want |
Must be a definition of the word "most" that I'm not aware of. (3/9?) |
Yes - "a few" - could you also please add at least present() - bonus points for get_return_rally() and maybe get_return_altitude(). |
enabled() = I make it 7 / 9, which is most in anyones definition IMHO. |
I'm specifically interested because of this PR which is a lua script for fence based pre/arm checks. I understand if you don't want to merge it, but right now I can't use it myself because I need some fence bindings - I think mostly present() and AP_Mission method get_landing_sequence_start uint16_t. |
fair enough ... :-) (ok now at 6/9, but only because of shall we say ambiguous comments in AC_Fence.h) but really? _poly_loader.total_fence_count() > 0 can come from a parameter? It seems a bit convoluted to me; if I try to trace the code, it doesn't seem like it's that simple. I get the 'flash cost' argument - but this would mean duplicating some reasonably complex logic from cpp into lua. Is that really a good idea? |
Also the cpp comment for get_return_rally says "returns whether returning to fence return point or rally point" - not the same thing as FENCE_RET_RALLY - unless the comment is wrong. Oh - looking at the code I guess the comment is wrong. I'm assuming the same thing would apply to get_return_altitude() - i.e. its the "actual in flight return altitude" - but the comment looks like it suffers from a copy/paste. |
Yes, the value should be the same. In lua the present function would look some thing like this:
|
In both cases there directly returning the parameter variable. |
Yes I see that the comment in AC_Fence.h was - shall we say "ambiguous" |
This adds bindings allowing fence failsafe actions to be taken by scripting. A simple example: