Skip to content

Commit 55eeb0a

Browse files
committed
Improve documentation
1 parent 4caa93c commit 55eeb0a

File tree

4 files changed

+109
-57
lines changed

4 files changed

+109
-57
lines changed

FprimeZephyrReference/Components/Imu/Imu.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ======================================================================
22
// \title Imu.cpp
3-
// \author aychar
43
// \brief cpp file for Imu component implementation class
54
// ======================================================================
65

@@ -36,13 +35,13 @@ Imu ::~Imu() {}
3635
// ----------------------------------------------------------------------
3736

3837
void Imu ::run_handler(FwIndexType portNum, U32 context) {
39-
// Fetch new data sample
38+
// Fetch new data samples from the sensors
4039
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_ACCEL_XYZ);
4140
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_GYRO_XYZ);
4241
sensor_sample_fetch_chan(lis2mdl, SENSOR_CHAN_MAGN_XYZ);
4342
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_DIE_TEMP);
4443

45-
// Output the magnetic field values via telemetry
44+
// Output sensor values via telemetry
4645
this->tlmWrite_Acceleration(this->get_acceleration());
4746
this->tlmWrite_AngularVelocity(this->get_angular_velocity());
4847
this->tlmWrite_MagneticField(this->get_magnetic_field());
@@ -57,6 +56,7 @@ Components::Imu_Acceleration Imu ::get_acceleration() {
5756
struct sensor_value x;
5857
struct sensor_value y;
5958
struct sensor_value z;
59+
6060
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_X, &x);
6161
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Y, &y);
6262
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Z, &z);
@@ -69,6 +69,7 @@ Components::Imu_AngularVelocity Imu ::get_angular_velocity() {
6969
struct sensor_value x;
7070
struct sensor_value y;
7171
struct sensor_value z;
72+
7273
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_X, &x);
7374
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Y, &y);
7475
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Z, &z);
@@ -81,6 +82,7 @@ Components::Imu_MagneticField Imu ::get_magnetic_field() {
8182
struct sensor_value x;
8283
struct sensor_value y;
8384
struct sensor_value z;
85+
8486
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_X, &x);
8587
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_Y, &y);
8688
sensor_channel_get(lis2mdl, SENSOR_CHAN_MAGN_Z, &z);
@@ -91,7 +93,9 @@ Components::Imu_MagneticField Imu ::get_magnetic_field() {
9193

9294
F64 Imu ::get_temperature() {
9395
struct sensor_value temp;
96+
9497
sensor_channel_get(lsm6dso, SENSOR_CHAN_DIE_TEMP, &temp);
98+
9599
return this->sensor_value_to_f64(temp);
96100
}
97101
} // namespace Components
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
module Components {
2-
@ Component for F Prime FSW framework.
2+
@ IMU Component for F Prime FSW framework.
33
passive component Imu {
44
sync input port run: Svc.Sched
55

6-
struct MagneticField {
6+
@ Acceleration reading in m/s^2
7+
struct Acceleration {
78
x: F64
89
y: F64
910
z: F64
1011
}
11-
telemetry MagneticField: MagneticField
1212

13-
struct Acceleration {
13+
@ Telemetry channel for acceleration
14+
telemetry Acceleration: Acceleration
15+
16+
@ Angular velocity reading in rad/s
17+
struct AngularVelocity {
1418
x: F64
1519
y: F64
1620
z: F64
1721
}
18-
telemetry Acceleration: Acceleration
1922

20-
struct AngularVelocity {
23+
@ Telemetry channel for angular velocity
24+
telemetry AngularVelocity: AngularVelocity
25+
26+
@ Magnetic field reading in gauss
27+
struct MagneticField {
2128
x: F64
2229
y: F64
2330
z: F64
2431
}
25-
telemetry AngularVelocity: AngularVelocity
2632

33+
@ Telemetry channel for magnetic field
34+
telemetry MagneticField: MagneticField
35+
36+
@ Telemetry channel for temperature in degrees Celsius
2737
telemetry Temperature: F64
2838

2939
###############################################################################
@@ -32,20 +42,7 @@ module Components {
3242
@ Port for requesting the current time
3343
time get port timeCaller
3444

35-
@ Port for sending textual representation of events
36-
text event port logTextOut
37-
38-
@ Port for sending events to downlink
39-
event port logOut
40-
4145
@ Port for sending telemetry channels to downlink
4246
telemetry port tlmOut
43-
44-
@ Port to return the value of a parameter
45-
param get port prmGetOut
46-
47-
@Port to set the value of a parameter
48-
param set port prmSetOut
49-
5047
}
5148
}

FprimeZephyrReference/Components/Imu/Imu.hpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ======================================================================
22
// \title Imu.hpp
3-
// \author aychar
43
// \brief hpp file for Imu component implementation class
54
// ======================================================================
65

@@ -22,8 +21,7 @@ class Imu final : public ImuComponentBase {
2221
// ----------------------------------------------------------------------
2322

2423
//! Construct Imu object
25-
Imu(const char* const compName //!< The component name
26-
);
24+
Imu(const char* const compName);
2725

2826
//! Destroy Imu object
2927
~Imu();
@@ -33,21 +31,42 @@ class Imu final : public ImuComponentBase {
3331
// Handler implementations for typed input ports
3432
// ----------------------------------------------------------------------
3533

36-
//! Handler implementation for TODO
37-
//!
38-
//! TODO
34+
//! Handler implementation
3935
void run_handler(FwIndexType portNum, //!< The port number
4036
U32 context //!< The call order
4137
) override;
4238

39+
// ----------------------------------------------------------------------
40+
// Helper methods
41+
// ----------------------------------------------------------------------
42+
43+
//! Convert a Zephyr sensor_value to an Fprime F64
4344
F64 sensor_value_to_f64(const struct sensor_value& val);
4445

46+
// ----------------------------------------------------------------------
47+
// IMU access methods
48+
// ----------------------------------------------------------------------
49+
50+
//! Get the acceleration reading from the IMU
4551
Components::Imu_Acceleration get_acceleration();
52+
53+
//! Get the angular velocity reading from the IMU
4654
Components::Imu_AngularVelocity get_angular_velocity();
55+
56+
//! Get the magnetic field reading from the IMU
4757
Components::Imu_MagneticField get_magnetic_field();
58+
59+
//! Get the temperature reading from the IMU
4860
F64 get_temperature();
4961

62+
// ----------------------------------------------------------------------
63+
// Member variables
64+
// ----------------------------------------------------------------------
65+
66+
//! Zephyr device stores the initialized LIS2MDL sensor
5067
const struct device* lis2mdl;
68+
69+
//! Zephyr device stores the initialized LSM6DSO sensor
5170
const struct device* lsm6dso;
5271
};
5372

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,81 @@
11
# Components::Imu
22

3-
Component for F Prime FSW framework.
3+
The IMU (Inertial Measurement Unit) component provides sensor data related to motion and orientation of the craft. It interfaces with two sensors: the LIS2MDL magnetometer and the LSM6DSO accelerometer/gyroscope to provide acceleration, angular velocity, magnetic field, and temperature measurements.
44

55
## Usage Examples
6-
Add usage examples here
6+
7+
The IMU component is designed to be scheduled periodically to collect sensor data and output telemetry. It operates as a passive component that responds to scheduler calls.
78

89
### Diagrams
9-
Add diagrams here
10+
11+
```mermaid
12+
sequenceDiagram
13+
participant Scheduler
14+
participant IMU
15+
participant Telemetry
16+
17+
Scheduler->>IMU: run
18+
IMU->>Telemetry: Output sensor data
19+
```
1020

1121
### Typical Usage
12-
And the typical usage of the component here
22+
23+
1. The component is instantiated and initialized during system startup
24+
2. The scheduler calls the `run` port at regular intervals (configured at 12.5 Hz)
25+
3. On each run call, the component:
26+
- Fetches fresh sensor samples from both IMU sensors
27+
- Converts sensor data to F Prime data structures
28+
- Outputs telemetry for acceleration, angular velocity, magnetic field, and temperature
1329

1430
## Class Diagram
15-
Add a class diagram here
31+
32+
```mermaid
33+
classDiagram
34+
namespace Components {
35+
class ImuComponentBase {
36+
<<Auto-generated>>
37+
}
38+
class Imu {
39+
- lis2mdl: device*
40+
- lsm6dso: device*
41+
+ Imu(char* compName)
42+
+ ~Imu()
43+
- run_handler(FwIndexType portNum, U32 context)
44+
- sensor_value_to_f64(sensor_value* val): F64
45+
- get_acceleration(): Imu_Acceleration
46+
- get_angular_velocity(): Imu_AngularVelocity
47+
- get_magnetic_field(): Imu_MagneticField
48+
- get_temperature(): F64
49+
}
50+
}
51+
ImuComponentBase <|-- Imu : inherits
52+
```
53+
1654

1755
## Port Descriptions
18-
| Name | Description |
19-
|---|---|
20-
|---|---|
56+
| Name | Type | Description |
57+
|---|---|---|
58+
| run | sync input | Scheduler port that triggers sensor data collection and telemetry output |
59+
| timeCaller | time get | Port for requesting current system time |
60+
| tlmOut | telemetry | Port for sending telemetry data to downlink |
2161

2262
## Component States
23-
Add component states in the chart below
2463
| Name | Description |
2564
|---|---|
26-
|---|---|
65+
| Initialized | Component has been constructed and both IMU sensors are ready |
66+
| Running | Component is actively collecting sensor data when scheduled |
67+
| Error | One or both sensors failed initialization (assertion failure) |
2768

2869
## Sequence Diagrams
2970
Add sequence diagrams here
3071

31-
## Parameters
32-
| Name | Description |
33-
|---|---|
34-
|---|---|
35-
36-
## Commands
37-
| Name | Description |
38-
|---|---|
39-
|---|---|
40-
41-
## Events
42-
| Name | Description |
43-
|---|---|
44-
|---|---|
45-
4672
## Telemetry
4773
| Name | Description |
4874
|---|---|
49-
|---|---|
75+
| Acceleration | Telemetry channel for acceleration in m/s^2 |
76+
| AngularVelocity | Telemetry channel for angular velocity in rad/s |
77+
| MagneticField | Telemetry channel for magnetic field in gauss |
78+
| Temperature | Telemetry channel for temperature in degrees Celsius |
5079

5180
## Unit Tests
5281
Add unit test descriptions in the chart below
@@ -58,9 +87,12 @@ Add unit test descriptions in the chart below
5887
Add requirements in the chart below
5988
| Name | Description | Validation |
6089
|---|---|---|
61-
|---|---|---|
90+
| AccelerationTelemetry | The component shall provide acceleration telemetry in m/s^2 | Verify telemetry output matches expected values from sensor datasheet |
91+
| AngularVelocityTelemetry | The component shall provide angular velocity telemetry in rad/s | Verify telemetry output matches expected values from sensor datasheet |
92+
| MagneticFieldTelemetry | The component shall provide magnetic field telemetry in gauss | Verify telemetry output matches expected values from sensor datasheet |
93+
| TemperatureTelemetry | The component shall provide temperature telemetry in degrees Celsius | Verify telemetry output matches expected values from sensor datasheet |
6294

6395
## Change Log
6496
| Date | Description |
6597
|---|---|
66-
|---| Initial Draft |
98+
| 2025-9-9 | Initial IMU component |

0 commit comments

Comments
 (0)