Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a0cf714
Update README.md
ineskhou Sep 11, 2025
ed55f38
Create lmsd6dsoDriver component
asiemsen Sep 11, 2025
2436c8f
create ports for sensor reading output
asiemsen Sep 11, 2025
51ce94a
fix port naming issue
asiemsen Sep 11, 2025
1dad937
Use custom board definition
nateinaction Sep 7, 2025
7fd3d7b
Remove commented config
nateinaction Sep 8, 2025
bbf35a3
Moving prj.conf sensors to board definition
nateinaction Sep 12, 2025
57e4183
Add d board
nateinaction Sep 12, 2025
e98a434
Try referencing c definitions in d board
nateinaction Sep 12, 2025
a75b69f
Making a common v5 board definition
nateinaction Sep 13, 2025
649e44f
Fix readme
nateinaction Sep 13, 2025
fa0b360
Minor Makefile, Readme and cmake presets fixes
nateinaction Sep 13, 2025
e7d8e9c
change lsm6dso internal structs to carry F64 and added output ports t…
asiemsen Sep 16, 2025
958854f
removed lmsdso init from imu constructor
asiemsen Sep 17, 2025
ac46912
remove old sensor reading from imu
asiemsen Sep 17, 2025
8e1447a
add lms6dso driver to topology
asiemsen Sep 17, 2025
29bffee
change base id to allow for lis2mdl driver
asiemsen Sep 17, 2025
d7e1b35
remove line endings
Sep 17, 2025
bb1be34
add channel retrieval during sensor data
asiemsen Sep 17, 2025
d8d06de
Merge branch 'main' into board-definition
Mikefly123 Sep 18, 2025
31e3f8d
Ensure submodules are downloaded before venv is created
nateinaction Sep 18, 2025
f7f09fb
Fix infinit submodule make target recursion...
nateinaction Sep 18, 2025
1fcd2ce
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
ee86a88
Merge branch 'imu2' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
05fbdda
Merge branch 'board-definition' of github.com:Open-Source-Space-Found…
nateinaction Sep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
{
"binaryDir": "${sourceDir}/build-fprime-automatic-zephyr",
"cacheVariables": {
"BOARD": "teensy41",
"BOARD": "proves_flight_control_board_v5c/rp2350a/m33",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"description": "F\u00b4 release build using local fprime-venv",
"displayName": "F\u00b4 Zephyr (teensy41)",
"displayName": "F\u00b4 FPrime Zephyr PROVES",
"environment": {
"PATH": "$env{VIRTUAL_ENV}/bin:$penv{PATH}",
"VIRTUAL_ENV": "${fileDir}/fprime-venv"
},
"generator": "Ninja",
"name": "fprime-zephyr-teensy41",
"name": "fprime-zephyr-proves",
"toolchainFile": "${fileDir}/lib/fprime-zephyr/cmake/toolchain/zephyr.cmake"
}
],
Expand Down
1 change: 1 addition & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Imu/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlDriver/")
60 changes: 4 additions & 56 deletions FprimeZephyrReference/Components/Imu/Imu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ namespace Components {
// Component construction and destruction
// ----------------------------------------------------------------------

Imu ::Imu(const char* const compName) : ImuComponentBase(compName) {
// Initialize the LSM6DSO sensor
lsm6dso = DEVICE_DT_GET_ONE(st_lsm6dso);
FW_ASSERT(device_is_ready(lsm6dso));

// Configure the LSM6DSO sensor
struct sensor_value odr = {.val1 = 12, .val2 = 500000}; // 12.5 Hz
FW_ASSERT(sensor_attr_set(lsm6dso, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr) == 0);
FW_ASSERT(sensor_attr_set(lsm6dso, SENSOR_CHAN_GYRO_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr) == 0);
}
Imu ::Imu(const char* const compName) : ImuComponentBase(compName) {}

Imu ::~Imu() {}

Expand All @@ -31,53 +22,10 @@ Imu ::~Imu() {}
// ----------------------------------------------------------------------

void Imu ::run_handler(FwIndexType portNum, U32 context) {
// Fetch new data samples from the sensors
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_ACCEL_XYZ);
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_GYRO_XYZ);
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_DIE_TEMP);

// Output sensor values via telemetry
this->tlmWrite_Acceleration(this->get_acceleration());
this->tlmWrite_AngularVelocity(this->get_angular_velocity());
this->tlmWrite_Acceleration(this->readAcceleration_out(0));
this->tlmWrite_AngularVelocity(this->readAngularVelocity_out(0));
this->tlmWrite_MagneticField(this->readMagneticField_out(0));
this->tlmWrite_Temperature(this->get_temperature());
}

F64 Imu ::sensor_value_to_f64(const struct sensor_value& val) {
return val.val1 + val.val2 / 1000000.0f;
}

Components::Imu_Acceleration Imu ::get_acceleration() {
struct sensor_value x;
struct sensor_value y;
struct sensor_value z;

sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_X, &x);
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Y, &y);
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Z, &z);

return Components::Imu_Acceleration(this->sensor_value_to_f64(x), this->sensor_value_to_f64(y),
this->sensor_value_to_f64(z));
}

Components::Imu_AngularVelocity Imu ::get_angular_velocity() {
struct sensor_value x;
struct sensor_value y;
struct sensor_value z;

sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_X, &x);
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Y, &y);
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Z, &z);

return Components::Imu_AngularVelocity(this->sensor_value_to_f64(x), this->sensor_value_to_f64(y),
this->sensor_value_to_f64(z));
this->tlmWrite_Temperature(this->readTemperature_out(0));
}

F64 Imu ::get_temperature() {
struct sensor_value temp;

sensor_channel_get(lsm6dso, SENSOR_CHAN_DIE_TEMP, &temp);

return this->sensor_value_to_f64(temp);
}
} // namespace Components
23 changes: 6 additions & 17 deletions FprimeZephyrReference/Components/Imu/Imu.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,20 @@ module Components {
passive component Imu {
sync input port run: Svc.Sched

output port readAcceleration: AccelerationRead
output port readAngularVelocity: AngularVelocityRead
output port readMagneticField: MagneticFieldRead
output port readTemperature: TemperatureRead

@ Acceleration reading in m/s^2
struct Acceleration {
x: F64
y: F64
z: F64
}
@Telemetry channel for angular velocity
telemetry AngularVelocity: AngularVelocity

@ Telemetry channel for acceleration
@ Telemetry channel for Acceleration
telemetry Acceleration: Acceleration

@ Telemetry channel for magnetic field
telemetry MagneticField: MagneticField

@ Angular velocity reading in rad/s
struct AngularVelocity {
x: F64
y: F64
z: F64
}

@ Telemetry channel for angular velocity
telemetry AngularVelocity: AngularVelocity

@ Telemetry channel for temperature in degrees Celsius
telemetry Temperature: F64

Expand Down
31 changes: 0 additions & 31 deletions FprimeZephyrReference/Components/Imu/Imu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

#include "FprimeZephyrReference/Components/Imu/ImuComponentAc.hpp"

#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>

namespace Components {

class Imu final : public ImuComponentBase {
Expand All @@ -35,33 +31,6 @@ class Imu final : public ImuComponentBase {
void run_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;

// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------

//! Convert a Zephyr sensor_value to an Fprime F64
F64 sensor_value_to_f64(const struct sensor_value& val);

// ----------------------------------------------------------------------
// IMU access methods
// ----------------------------------------------------------------------

//! Get the acceleration reading from the IMU
Components::Imu_Acceleration get_acceleration();

//! Get the angular velocity reading from the IMU
Components::Imu_AngularVelocity get_angular_velocity();

//! Get the temperature reading from the IMU
F64 get_temperature();

// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------

//! Zephyr device stores the initialized LSM6DSO sensor
const struct device* lsm6dso;
};

} // namespace Components
Expand Down
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/lms6dsoDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/lms6dsoDriver.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/lms6dsoDriverTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/lms6dsoDriverTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
66 changes: 66 additions & 0 deletions FprimeZephyrReference/Components/lms6dsoDriver/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Components::lms6dsoDriver

Initialize and control operation of the lms6dso device

## Usage Examples
Add usage examples here

### Diagrams
Add diagrams here

### Typical Usage
And the typical usage of the component here

## Class Diagram
Add a class diagram here

## Port Descriptions
| Name | Description |
|---|---|
|---|---|

## Component States
Add component states in the chart below
| Name | Description |
|---|---|
|---|---|

## Sequence Diagrams
Add sequence diagrams here

## Parameters
| Name | Description |
|---|---|
|---|---|

## Commands
| Name | Description |
|---|---|
|---|---|

## Events
| Name | Description |
|---|---|
|---|---|

## Telemetry
| Name | Description |
|---|---|
|---|---|

## Unit Tests
Add unit test descriptions in the chart below
| Name | Description | Output | Coverage |
|---|---|---|---|
|---|---|---|---|

## Requirements
Add requirements in the chart below
| Name | Description | Validation |
|---|---|---|
|---|---|---|

## Change Log
| Date | Description |
|---|---|
|---| Initial Draft |
71 changes: 71 additions & 0 deletions FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ======================================================================
// \title lms6dsoDriver.cpp
// \author aaron
// \brief cpp file for lms6dsoDriver component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/lms6dsoDriver/lms6dsoDriver.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

lms6dsoDriver ::lms6dsoDriver(const char* const compName) : lms6dsoDriverComponentBase(compName) {
// Initialize the LSM6DSO sensor
lsm6dso = DEVICE_DT_GET_ONE(st_lsm6dso);
FW_ASSERT(device_is_ready(lsm6dso));
// Configure the LSM6DSO sensor
struct sensor_value odr = {.val1 = 12, .val2 = 500000}; // 12.5 Hz
sensor_attr_set(lsm6dso, SENSOR_CHAN_ACCEL_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr);
sensor_attr_set(lsm6dso, SENSOR_CHAN_GYRO_XYZ, SENSOR_ATTR_SAMPLING_FREQUENCY, &odr);
}

lms6dsoDriver ::~lms6dsoDriver() {}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

Components::Acceleration lms6dsoDriver::getAcceleration_handler(FwIndexType portNum) {
struct sensor_value x;
struct sensor_value y;
struct sensor_value z;
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_ACCEL_XYZ);

sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_X, &x);
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Y, &y);
sensor_channel_get(lsm6dso, SENSOR_CHAN_ACCEL_Z, &z);

return Components::Acceleration(this->sensor_value_to_f64(x),this->sensor_value_to_f64(y), this->sensor_value_to_f64(z));
}

Components::AngularVelocity lms6dsoDriver::getAngularVelocity_handler(FwIndexType portNum) {
struct sensor_value x;
struct sensor_value y;
struct sensor_value z;
sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_GYRO_XYZ);

sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_X, &x);
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Y, &y);
sensor_channel_get(lsm6dso, SENSOR_CHAN_GYRO_Z, &z);

return Components::AngularVelocity(this->sensor_value_to_f64(x),this->sensor_value_to_f64(y), this->sensor_value_to_f64(z));
}


F64 lms6dsoDriver::getTemperature_handler(FwIndexType portNum) {
struct sensor_value temp;

sensor_sample_fetch_chan(lsm6dso, SENSOR_CHAN_DIE_TEMP);
sensor_channel_get(lsm6dso, SENSOR_CHAN_DIE_TEMP, &temp);

return this->sensor_value_to_f64(temp);
}

F64 lms6dsoDriver::sensor_value_to_f64(const struct sensor_value& val) {
return val.val1 + val.val2 / 1000000.0f;
}

} // namespace Components
Loading
Loading