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

send_event: move to new WQ and uORB::Subscription #12176

Closed
wants to merge 2 commits into from

Conversation

dagar
Copy link
Member

@dagar dagar commented Jun 4, 2019

No description provided.

* @class SubscriberHandler
* Contains a list of uORB subscriptions and maintains their update state.
*/
class SubscriberHandler
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the original idea of the SubscriberHandler was to save memory by not having all event tasks subscribe to the same uorb topics. But I don't know what the quantitative difference for this approach is.

potaito
potaito previously approved these changes Jun 5, 2019
Copy link
Contributor

@potaito potaito left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @dagar

}

ret = wait_until_running();
SendEvent *send_event = new SendEvent();
Copy link
Member

Choose a reason for hiding this comment

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

This runs now in a different task, which can lead to problems.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's why it's also moving to uORB::Subscription in the same PR. Other than file descriptors what problems are you thinking of?

Copy link
Member

Choose a reason for hiding this comment

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

Yes fd's being the main point, and it's more in general, since orb_subscribe can still be used and tasks might open actual files, pipes, etc. It's just a better design doing it in the same context and it's a typical source of error that is difficult to debug.
I'm also thinking of task-based accounting of resources.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a design decision to make the PX4 WQ as simple as possible for the majority of drivers and modules that do not (and should not) open actual files, pipes, etc. Unless you see an exception here we need to keep going. We're very close to not needing HPWORK and LPWORK (2 entire tasks with relatively large stacks).

I'm also trying to get to module-based resource accounting. With current modules and traditional orb usage too much is hidden (the size of the allocation of the main object, true cost of all these orb subscriptions, other dynamic allocations, etc).

Copy link
Member

Choose a reason for hiding this comment

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

Serial drivers, such as distance sensors are already one exception we have. Existing drivers work around the problem, but I still see people making mistakes w/o being able to figure out what the issue is.
While I don't question it's simpler without that requirement, it's also a step back.

Copy link
Member Author

Choose a reason for hiding this comment

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

The distance sensors are a large inconsistent mess that needs structure (only 1 uses ModuleBase) and serial in general is likely going to need to be abstracted both to handle port deconfliction PX4 side and the possibility of porting to another platform (much longer discussion). Virtually all of these drivers evolved via copy and paste because hardly anyone actually understands how to create a module from scratch.

We need a good interface for handling this case (2 phase init, etc), implement it in every driver we actually care about, and then provide a well documented template.

What do you want to do here?

Copy link
Member

Choose a reason for hiding this comment

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

Yes exactly. Without having looked at the details, an idea would be to add a helper method that calls a provided callback on the wq (which does the initialization), and the helper method waits for that to finish, so it can keep the required WorkItem on the stack.

The resulting effect of a more serialized startup would also help with orb instance and driver class instance race conditions (even more important when splitting gyro topics). Currently when multiple drivers initialize separate PX4Accelerometer instances concurrently, there is no guarantee to get consistent instances.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about this again, each WorkItem could really be a small state machine (extending _task_should_exit).

  • initializing
  • running
  • waiting
  • stopping
  • etc

Those could correspond to different methods we optionally fill in as needed for specific states or transitions.

@mcsauder
Copy link
Contributor

mcsauder commented Jun 8, 2019

Test flown on a 250 quad, pixhawk 4 mini, RC transmitter powered off part way through the flight.
Log here: https://review.px4.io/plot_app?log=4b385d24-d21e-4d9a-9ff9-35d079083b15

@stale
Copy link

stale bot commented Nov 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Nov 30, 2019
@dagar dagar closed this Jan 22, 2020
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