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 bindings to load fence #15598

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

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Oct 18, 2020

This adds a manual binding to allow one to load fences directly from scripting.

image

Required some small changes to the generator to allow nested userdata and userdata enums. There a bit of a pita to work with in lua (see comments in example), but they do work.

I attempted to use the lua buffer as with the logging binding but it was garbling the data by the time fence got it, not really sure why, so this ends up with out. Probably a bigger buffer than logging uses, but this will be a once before flight rather than a constant rate.

#15550

@IamPete1
Copy link
Member Author

Would be nice to add a fence notify function to trigger the GCS to reload.

@IamPete1
Copy link
Member Author

IamPete1 commented Oct 18, 2020

It might also be possible to take the table as a argument directly rather than using unpack, but I could not work that out.

class AC_PolyFenceItem new_items[args];

for (uint8_t i=0; i<args; i++) {
AC_PolyFenceItem *item = check_AC_PolyFenceItem(L,i-args);
Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea why we have to use negative stack index here where as in the logger binding there positive. But this does seem to work as expected. We start at larger negative number and work up to -1 in order to get the fence to come out in the expected order.

@IamPete1
Copy link
Member Author

This was writing the fence backwards, now its not.

@IamPete1
Copy link
Member Author

This now allows to broadcast the fence back to the GCS with a second binding.

https://youtu.be/WakSwFTCeV8

@davidbuzz
Copy link
Collaborator

looks to me like a nice clean implementation, which clearly works well. lgtm.

mission_type: MAV_MISSION_TYPE_FENCE
};

gcs().send_to_active_channels(MAVLINK_MSG_ID_MISSION_ITEM_INT, (const char *)&ret_packet);
Copy link
Contributor

Choose a reason for hiding this comment

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

this won't handle pkt loss, or running out of uart buffer space

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.

4 participants