|
Mod Library
Sun Devil Rocketry's hardware agnostic utility library
|
: Contains functions to interface between SDEC terminal commands and SDR sensor APIs More...
#include <string.h>#include <stdbool.h>#include <math.h>#include "sdr_pin_defines_A0002.h"#include "main.h"#include "imu.h"#include "baro.h"#include "timer.h"#include "usb.h"#include "sensor.h"#include "math_sdr.h"#include "mahony.h"#include "error_sdr.h"#include "debug_sdr.h"Macros | |
| #define | SENSOR_MAHONY_KP 1.0f |
| #define | SENSOR_MAHONY_KI 0.0f |
| #define | BARO_PRESS_ALPHA (0.7f) |
| #define | BARO_TEMP_ALPHA (0.7f) |
Functions | |
| SENSOR_STATUS | sensor_cmd_execute (uint8_t subcommand) |
| Executes a sensor subcommand and transmits the requested readings. | |
| SENSOR_STATUS | sensor_dump (SENSOR_DATA *sensor_data_ptr) |
| Reads the available sensors and fills the sensor data structure. | |
| SENSOR_STATUS | sensor_init (PRESET_DATA *preset_data) |
| Initializes sensor timing and resets velocity state. | |
| void | sensor_conv_imu (IMU_CONVERTED *imu_converted, IMU_RAW *imu_raw) |
| Converts raw IMU readings into calibrated, remapped sensor data. | |
| MOUNT_ORIENTATION | sensor_get_mount_orientation (void) |
| Get the mount orientation. | |
| void | sensor_set_mount_orientation (MOUNT_ORIENTATION orientation) |
| Set the mount orientation. | |
| SENSOR_STATUS | sensor_body_state (const IMU_CONVERTED *imu_converted, STATE_ESTIMATION *state_estimate) |
| Integrates gyro data to update the estimated body attitude and rate. | |
| void | sensor_axis_remap (float *x, float *y, float *z) |
| Remaps sensor axes according to the flight-computer mounting orientation. | |
| float | sensor_acc_conv (int16_t readout) |
| Converts a raw accelerometer reading to meters per second squared. | |
| float | sensor_gyro_conv (int16_t readout) |
| Converts a raw gyro reading to degrees per second. | |
| void | sensor_imu_velo (const IMU_CONVERTED *imu_converted, STATE_ESTIMATION *state_estimate) |
| Calculates velocity from converted accelerometer measurements. | |
| void | sensor_baro_alt (SENSOR_DATA *sen_data) |
| Calculates altitude from the current barometric pressure and temperature. | |
| void | sensor_reset_velo (void) |
| Resets accumulated velocity values to prevent drift. | |
Variables | |
| GPS_DATA | gps_data |
| IMU_OFFSET | imu_offset |
| uint64_t | imu_velo_tick = 0 |
| float | velo_x_prev = 0.0f |
| float | velo_y_prev = 0.0f |
| float | velo_z_prev = 0.0f |
| QUAT | attitude = { 1.0f, 0.0f, 0.0f, 0.0f } |
: Contains functions to interface between SDEC terminal commands and SDR sensor APIs
Copyright (c) 2025 Sun Devil Rocketry. All rights reserved.
This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is covered under the BSD-3-Clause.
| float sensor_acc_conv | ( | int16_t | readout | ) |
Converts a raw accelerometer reading to meters per second squared.
Converts accelerometer readouts to meters per second squared.
| readout | Raw accelerometer readout. |
Converts a raw accelerometer reading to meters per second squared.
| readout | Raw accelerometer readout. |
| void sensor_axis_remap | ( | float * | x, |
| float * | y, | ||
| float * | z ) |
Remaps sensor axes according to the flight-computer mounting orientation.
Remaps sensor axes for the flight configuration.
| x | X-axis value to remap. |
| y | Y-axis value to remap. |
| z | Z-axis value to remap. |
Remaps sensor axes according to the flight-computer mounting orientation.
| x | X-axis value to remap. |
| y | Y-axis value to remap. |
| z | Z-axis value to remap. |
| void sensor_baro_alt | ( | SENSOR_DATA * | sensor_data_ptr | ) |
Calculates altitude from the current barometric pressure and temperature.
Calculates altitude from pressure readings.
| sen_data | Sensor data structure to update. |
Calculates altitude from the current barometric pressure and temperature.
| sensor_data_ptr | Sensor data structure to update. |
| SENSOR_STATUS sensor_body_state | ( | const IMU_CONVERTED * | imu_converted, |
| STATE_ESTIMATION * | state_estimate ) |
Integrates gyro data to update the estimated body attitude and rate.
Performs sensor fusion on converted IMU data to get body rate.
| imu_converted | Converted IMU data. |
| state_estimate | State estimate to update. |
Integrates gyro data to update the estimated body attitude and rate.
| imu_converted | Converted IMU data. |
| state_estimate | State estimate to update. |
| SENSOR_STATUS sensor_cmd_execute | ( | uint8_t | subcommand | ) |
Executes a sensor subcommand and transmits the requested readings.
Executes a sensor subcommand.
| subcommand | Sensor subcommand code. |
Executes a sensor subcommand and transmits the requested readings.
| subcommand | Sensor subcommand code. |
| void sensor_conv_imu | ( | IMU_CONVERTED * | imu_converted, |
| IMU_RAW * | imu_raw ) |
Converts raw IMU readings into calibrated, remapped sensor data.
Converts raw IMU readouts into accelerometer, gyro, and magnetometer data.
| imu_converted | Converted IMU data to fill. |
| imu_raw | Raw IMU readouts. |
Converts raw IMU readings into calibrated, remapped sensor data.
| imu_converted | Converted IMU data to fill. |
| imu_raw | Raw IMU readouts. |
| SENSOR_STATUS sensor_dump | ( | SENSOR_DATA * | sensor_data_ptr | ) |
Reads the available sensors and fills the sensor data structure.
Reads all sensors and fills the sensor data structure.
| sensor_data_ptr | Pointer to the sensor data structure to fill. |
Reads the available sensors and fills the sensor data structure.
| sensor_data_ptr | Pointer to the sensor data structure to fill. |
| MOUNT_ORIENTATION sensor_get_mount_orientation | ( | void | ) |
Get the mount orientation.
Gets the configured flight-computer mount orientation.
Get the mount orientation.
| float sensor_gyro_conv | ( | int16_t | readout | ) |
Converts a raw gyro reading to degrees per second.
Converts gyro readouts to degrees per second.
| readout | Raw gyro readout. |
Converts a raw gyro reading to degrees per second.
| readout | Raw gyro readout. |
| void sensor_imu_velo | ( | const IMU_CONVERTED * | imu_converted, |
| STATE_ESTIMATION * | state_estimate ) |
Calculates velocity from converted accelerometer measurements.
Calculates velocity from acceleration.
| imu_converted | Converted IMU data. |
| state_estimate | State estimate to update. |
Calculates velocity from converted accelerometer measurements.
| imu_converted | Converted IMU data. |
| state_estimate | State estimate to update. |
| SENSOR_STATUS sensor_init | ( | PRESET_DATA * | preset_data | ) |
Initializes sensor timing and resets velocity state.
Initializes sensor timing, velocity, and attitude state.
| preset_data | Pointer to the preset calibration data. |
Initializes sensor timing and resets velocity state.
| preset_data | Pointer to the preset calibration data. |
| void sensor_reset_velo | ( | void | ) |
Resets accumulated velocity values to prevent drift.
Resets velocity values to prevent accumulation of drift.
Resets accumulated velocity values to prevent drift.
| void sensor_set_mount_orientation | ( | MOUNT_ORIENTATION | orientation | ) |
Set the mount orientation.
Sets the flight-computer mount orientation.
| orientation | The new mount orientation |
Set the mount orientation.
| orientation | Mount orientation to use for axis remapping. |