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

RFC: Architecting a sensor subsystem #62223

Open
yperess opened this issue Sep 1, 2023 · 5 comments
Open

RFC: Architecting a sensor subsystem #62223

yperess opened this issue Sep 1, 2023 · 5 comments
Assignees
Labels
Architecture Review Discussion in the Architecture WG required area: Sensor Subsystem area: Sensors Sensors RFC Request For Comments: want input from the community

Comments

@yperess
Copy link
Collaborator

yperess commented Sep 1, 2023

Introduction

Sensor improvements are underway for kernel level drivers. But they assume a single consumer. A sensor subsystem has been proposed in #36963 and has been under development under subsys/sensing. The goals of the subsystem is to provide higher level functionality:

  • Demuxing data into multiple consumers
  • Arbitration of consumer configuration requests

Problem description

The current path of the implementation does not appear to be in the best interest of Zephyr as a whole. The implementation:

  • Duplicates APIs
  • Creates a "driver" node per type (this leads to synchronization issues when both type poke the same physical device)
  • Highly dependent on the scheduler

Proposed change

I'm proposing we stick to the engineering principle of Single Responsibility Principal (as much as possible).

The single-responsibility principle (SRP) is a computer programming principle that states that "A module should be responsible to one, and only one, actor."[1] The term actor refers to a group (consisting of one or more stakeholders or users) that requires a change in the module.

Taken from SRP

What this boils down to is that we should finish the work that's ongoing for updating the sensor driver API structs. These structs will be used both in the kernel level drivers AND in the subsystem's virtual sensors. It will be a single API for "sensors". Regardless of how the sensor gets the data.

Next, the subsystem should be responsible for the fanout. This means sending data to consumers and arbitrating configurations. Most likely, sending the data will leverage the zbus subsystem.

Links:

Related issues/PRs

@yperess yperess added RFC Request For Comments: want input from the community Architecture Review Discussion in the Architecture WG required labels Sep 1, 2023
@rodrigopex
Copy link
Contributor

@yperess have you guys consider using ZBus to share the data and control sensor subsystem? I can help with that.

@yperess
Copy link
Collaborator Author

yperess commented Sep 12, 2023

@yperess have you guys consider using ZBus to share the data and control sensor subsystem? I can help with that.

Yes, most likely the internal implementation will end up using zbus. Also, yes please, I'll be happy to get any help you can offer on that

@rodrigopex
Copy link
Contributor

Yes, most likely the internal implementation will end up using zbus. Also, yes please, I'll be happy to get any help you can offer on that

@yperess How would you like to proceed?

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Sep 12, 2023

Architecture WG notes:

  • @yperess: <overview of the current requirements from Google and shortcomings of the currently proposed approach, Google sensor subsystem pitch>
    • key points: the sensing api duplicates the sensor api functionalities, as well as the subsystem APIs, issues with coordinating multiple sensors
    • presents a proposed plan of next steps
  • @KeHIntel: <overview of the sensning proposal Sensing Subsystem design considerations and response to raised concerns>
    • Addressing points from the first presentation (slides 5 to 14)
  • @henrikbrixandersen asks for clarificataion about developer experience clarification
  • @KeHIntel: the virtual sensor concept is meant to help data scientist work with this, abstracting from the specific device interface, datasheet details
  • @yperess the existing API already does that
  • @henrikbrixandersen <comments on the devicetre slide, page 8> the current devicetree design is not limiting dynamic configuration options
  • @bjarki-trackunit the new API builds on top of the current API (set attribute fetch attribute) does not seem to be usable for implementing fifo, is the idea to extend that
  • @yperess yes, there's work in progress to support senso fifos, asyncronous read and data timestamped on the interrupt and separated decoder APIs, sensor subsystem would build on top of it
  • @MaureenHelm question about the vertical decoder proposal: why is it a dependency
  • @MaureenHelm question about the propose changes to the sensor driver apis, trying to understand how the api would look like after the change
    • @KeHIntel: <back to slide 7> the API restructuring would remove the duplication against sensor
  • Wojciech Macek (Google): asks both presenters how to handle sensor data rate change and resampling, seems like the current API is just decimating the data, which is making the data useless for some type of sensors
    • @KeHIntel: sensing provides the data at the requested frequency
    • @yperess the driver would get notified when the rate changes and provide a library for decimation of resampling, but the data reprocessing responsability is on the application
  • @teburd does not see the subsystem implementing detailed data processing primitives (resampling, filtering...)
  • @henrikbrixandersen / @MaureenHelm / @bjarki-trackunit: few more comments about difficulties in implementing arbitration with arbitrary parameters in an effective way

  • Followup:
    • [both authors] create an RFC with more details about how the sensor API should be extended
    • @yperess post the proposal for unified device structure as a PR

@nashif nashif moved this from Todo to Done in Architecture Review Sep 19, 2023
@teburd teburd added this to the v3.6.0 milestone Oct 23, 2023
@teburd teburd moved this to In Progress in Sensor Working Group Oct 23, 2023
@henrikbrixandersen henrikbrixandersen removed this from the v3.6.0 milestone Feb 5, 2024
@OgnjenX
Copy link

OgnjenX commented Nov 10, 2024

I'm trying to better understand if this proposal has been implemented since all PRs that I found to be related seem to be merged. If so, could you let me know since which release version it is included?
Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture Review Discussion in the Architecture WG required area: Sensor Subsystem area: Sensors Sensors RFC Request For Comments: want input from the community
Projects
Status: Done
Status: No status
Status: In Progress
Development

No branches or pull requests

7 participants