Create Teesy Sensors Interface
Closed this issue · 3 comments
MrZebulon commented
The assignee shall create a base class for the interface between the sensors (BNO, BMP, GNSS) drivers and the rest of the avionics modules.
Objectives
-
The base class shall make use of the zephyr implementation of the DRIVERS/COMMON/I2C_Interface. The I2C interface should not be imported directly into arch. Instead, the use of a template is recommended.
-
The base class shall include methods to perform the following
- Initializing the drivers (equivalent to arduino's setup)
- Ticking (equivalent to arduino's loop)
- Computing and cahcing calibration data such as means and variances of each sensor (cf. TL GNC: Reza)
- Setting and storing the polling rate of each sensor
- Using the aforementioned calibration to correct raw incoming sensors data (cf. TL GNC: Reza)
- ...
Notes
- Methods should be pure virtuals unless they can already be implemented.
- The DRIVERS/COMMON/I2C_Interface shall only be used through pointers to an instance (to allow for polymorphism).
- The use of templates as placeholder for each sensors's driver is allowed (see with Sam if direction is explored).
- The sensors are to be though of as a serviced for the GNC team, the assignee should coordinate with the GNC lead.
phamelink commented
A few questions:
- What would be the name of the class ? teensy_sensors_interface.hpp ?
- This is what I understand so far, correct me if I'm wrong
- I have to implement an interface (so an hpp file, not cpp), which is the point of contact for other avionic modules to communicate with the sensors.
- The I2C is the interface that allows me to communicate with the general circuit (reading input and writing output).
- I also have instances of the different drivers: BMP (barometric pressure sensor) and BNO (a Inertial Measurement Unit sensor which is basically a gyroscope).
- I can assume these are given by dependency injection by the use of templates (as mentioned in the issue).
- I need to coordinate with the GNC lead to know what methods he will need of this interface
- When you say The DRIVERS/COMMON/I2C_Interface shall only be used through pointers to an instance (to allow for polymorphism), this means that I will have a pointer to an instance at initialization, meaning I can have a property that is that pointer. This would be given in the constructor in the implemented class.
- The general flow diagram would be the following
flowchart TD
A("GNC")
B("Teensy Sensors Interface")
C("I2C interface")
D("Sensors")
A --- C
B --- C
D --- B
sequenceDiagram
participant GNC
participant TSI
participant I2C
participant SENS
GNC ->> I2C: Makes a request to read sensor data
I2C ->> TSI: Transfers request
TSI ->> SENS: Makes request to read sensor data
SENS ->> TSI: Replies with data, TSI stores/caches
TSI ->> I2C: Reply with data
I2C ->> GNC: Transfers data
- So the I2C interface acts as an intermediary for the GNC and teensy interface to communicate, however the teensy sensor interface is responsible to communicate with the sensors directly.
Let me know if I'm on the right track on understanding what's going on, we can always have a call later to discuss!
MrZebulon commented
- Use the telemetry as ref
- In order:
a. Yep
b. It is the communication protocol for the sensors (and sensors only)
c. Yep
d. You can proceed that way indeed
e. The methods i've listed you should be enough, but i still want you to confirm
f. You either have a private member in your class which is a pointer to I2C_Interface (drivers/common) or you can pass a pointer as parameter to each method. I'd recommend the 1st approach.
g. No. GNC has nothing to do with what you do (yet). You should rather "expose" the sensors data (see get() in SystemClass) as well as a method to "require" data from the sensors and a method to generate the data used for calibration (this you should see with GNC. The GNC interface will later make use of the data you expose to feed the algorithms.
phamelink commented
I was wondering, what should the class extend ? Does it also extend the BaseDataChannel because it needs to receive and write bytes?