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

commander force offboard control update when first entering mode #12242

Merged
merged 3 commits into from
Jun 13, 2019

Conversation

dagar
Copy link
Member

@dagar dagar commented Jun 11, 2019

Working on a fix for #12241.

@dagar dagar added the bug label Jun 11, 2019
@dagar dagar requested a review from julianoes June 11, 2019 15:14
@dagar dagar self-assigned this Jun 11, 2019
@dagar
Copy link
Member Author

dagar commented Jun 11, 2019

@julianoes the current theory (untested) is that the offboard subscription within commander isn't updating the first time through before hitting the timeout. This is an optimization in uORB::Subscription to prevent subscriptions from creating every single uORB::DeviceNode (publication) that may never actually be published.

@dagar dagar force-pushed the pr-commander_offboard branch from e0e0fda to dc5e25d Compare June 11, 2019 15:16
@julianoes
Copy link
Contributor

@dagar this is hard to review. You did a refactor and presumably a functional change.

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

This fixes the test but it worries me that this force init is required.

@dagar
Copy link
Member Author

dagar commented Jun 12, 2019

This fixes the test but it worries me that this force init is required.

Background:
When you subscribe with orb_subscribe it actually creates the uORB::DeviceNode (the internal data structure for each orb publication). As a result typical systems have several kilobytes worth of unused publications (take a look in /obj in stable vs master). One of the ways the updated uORB::Subscription saves memory is by only "subscribing" to topics that actually exist. Unfortunately the orb existence check is relatively expensive, so I spaced it out after 1000 attempts.

https://github.com/PX4/Firmware/blob/79d4c09d59759efbc228f413dda992562004e29e/src/modules/uORB/Subscription.cpp#L77-L82

What all of this means is that an orb publication that advertises and publishes late at runtime (eg mavlink offboard) won't be subscribed to immediately.

Now back in commander when switching to OFFBOARD mode we know an offboard_control_mode message is required. The change in this PR simply forces that initial subscription attempt immediately when first going into OFFBOARD. If the offboard timeout were slightly longer we would probably get away with it as is.

Does that make sense?

@dagar
Copy link
Member Author

dagar commented Jun 12, 2019

@dagar this is hard to review. You did a refactor and presumably a functional change.

It was originally more of a refactor to enable the change, but it ended up simpler. I'll split it into multiple commits.

@dagar dagar force-pushed the pr-commander_offboard branch from dc5e25d to 9820632 Compare June 12, 2019 14:26
@dagar dagar changed the title [WIP]: commander force offboard control update when first entering mode commander force offboard control update when first entering mode Jun 12, 2019
@dagar dagar marked this pull request as ready for review June 12, 2019 14:47
@dagar dagar force-pushed the pr-commander_offboard branch from 9820632 to abc2fc7 Compare June 12, 2019 14:48
@julianoes
Copy link
Contributor

Does that make sense?

Ok I suppose that makes sense.

Unfortunately the orb existence check is relatively expensive

That's the strcmp, right? And if so could we make that more efficient?

@dagar
Copy link
Member Author

dagar commented Jun 12, 2019

Unfortunately the orb existence check is relatively expensive

That's the strcmp, right? And if so could we make that more efficient?

Yes, iterating a linked list of all publications and strcmp. https://github.com/PX4/Firmware/blob/ae6fed4f2915def3df6adadb850c559b050055fd/src/modules/uORB/uORBDeviceMaster.cpp#L444-L447

What I'd like to do is generate an ordinal number for each orb topic and then have a simple bitset of published topics, but we'll need to be careful on platforms like Snappy where those things need to be in sync.

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

Yes good to go from my side. Thanks!

@julianoes
Copy link
Contributor

platforms like Snappy where those things need to be in sync.

Right, that's annoying.

@julianoes
Copy link
Contributor

Squash or rebase?

@dagar dagar merged commit 6816f2a into PX4:master Jun 13, 2019
@dagar dagar deleted the pr-commander_offboard branch June 13, 2019 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants