Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
rosflight_firmware::Sensors Class Reference

#include <sensors.h>

Inheritance diagram for rosflight_firmware::Sensors:
Inheritance graph
[legend]

Classes

struct  Data
 
class  OutlierFilter
 

Public Member Functions

const Datadata () const
 
void get_filtered_IMU (turbomath::Vector &accel, turbomath::Vector &gyro, uint64_t &stamp_us)
 
bool gyro_calibration_complete (void)
 
void init ()
 
void param_change_callback (uint16_t param_id) override
 
bool run ()
 
 Sensors (ROSflight &rosflight)
 
bool should_send_imu_data (void)
 
bool start_baro_calibration (void)
 
bool start_diff_pressure_calibration (void)
 
bool start_gyro_calibration (void)
 
bool start_imu_calibration (void)
 

Private Types

enum  : uint8_t {
  BAROMETER, GNSS, DIFF_PRESSURE, SONAR,
  MAGNETOMETER, BATTERY_MONITOR, NUM_LOW_PRIORITY_SENSORS
}
 

Private Member Functions

void calibrate_accel (void)
 
void calibrate_baro (void)
 
void calibrate_diff_pressure (void)
 
void calibrate_gyro (void)
 
void correct_baro (void)
 
void correct_diff_pressure (void)
 
void correct_imu (void)
 
void correct_mag (void)
 
void init_imu ()
 
void look_for_disabled_sensors (void)
 
void update_battery_monitor (void)
 
void update_battery_monitor_multipliers (void)
 
bool update_imu (void)
 
void update_other_sensors (void)
 

Private Attributes

turbomath::Vector acc_sum_ = {0, 0, 0}
 
float acc_temp_sum_ = 0.0f
 
float accel_ [3] = {0, 0, 0}
 
uint16_t accel_calibration_count_ = 0
 
turbomath::Vector accel_int_
 
bool baro_calibrated_ = false
 
uint16_t baro_calibration_count_ = 0
 
float baro_calibration_mean_ = 0.0f
 
float baro_calibration_var_ = 0.0f
 
OutlierFilter baro_outlier_filt_
 
float battery_current_alpha_ {0.995}
 
float battery_voltage_alpha_ {0.995}
 
bool calibrating_acc_flag_ = false
 
bool calibrating_gyro_flag_ = false
 
Data data_
 
OutlierFilter diff_outlier_filt_
 
bool diff_pressure_calibrated_ = false
 
uint16_t diff_pressure_calibration_count_ = 0
 
float diff_pressure_calibration_mean_ = 0.0f
 
float diff_pressure_calibration_var_ = 0.0f
 
const turbomath::Vector gravity_ = {0.0f, 0.0f, 9.80665f}
 
float ground_pressure_ = 0.0f
 
float gyro_ [3] = {0, 0, 0}
 
uint16_t gyro_calibration_count_ = 0
 
turbomath::Vector gyro_int_
 
turbomath::Vector gyro_sum_ = {0, 0, 0}
 
bool imu_data_sent_
 
uint64_t int_start_us_
 
uint32_t last_baro_cal_iter_ms_ = 0
 
uint32_t last_battery_monitor_update_ms_ = 0
 
uint32_t last_diff_pressure_cal_iter_ms_ = 0
 
uint32_t last_imu_update_ms_ = 0
 
uint32_t last_time_look_for_disarmed_sensors_ = 0
 
turbomath::Vector max_ = {-1000.0f, -1000.0f, -1000.0f}
 
turbomath::Vector min_ = {1000.0f, 1000.0f, 1000.0f}
 
bool new_imu_data_
 
uint8_t next_sensor_to_update_ = BAROMETER
 
uint64_t prev_imu_read_time_us_
 
ROSflightrf_
 
OutlierFilter sonar_outlier_filt_
 

Static Private Attributes

static const float BARO_MAX_CALIBRATION_VARIANCE = 25.0
 
static const float BARO_MAX_CHANGE_RATE = 200.0f
 
static const float BARO_SAMPLE_RATE = 50.0f
 
static constexpr uint32_t BATTERY_MONITOR_UPDATE_PERIOD_MS = 10
 
static const float DIFF_MAX_CHANGE_RATE = 225.0f
 
static const float DIFF_PRESSURE_MAX_CALIBRATION_VARIANCE = 100.0
 
static const float DIFF_SAMPLE_RATE = 50.0f
 
static const int SENSOR_CAL_CYCLES = 127
 
static const int SENSOR_CAL_DELAY_CYCLES = 128
 
static const float SONAR_MAX_CHANGE_RATE = 100.0f
 
static const float SONAR_SAMPLE_RATE = 50.0f
 

Detailed Description

Definition at line 123 of file sensors.h.

Member Enumeration Documentation

anonymous enum : uint8_t
private
Enumerator
BAROMETER 
GNSS 
DIFF_PRESSURE 
SONAR 
MAGNETOMETER 
BATTERY_MONITOR 
NUM_LOW_PRIORITY_SENSORS 

Definition at line 218 of file sensors.h.

Constructor & Destructor Documentation

rosflight_firmware::Sensors::Sensors ( ROSflight rosflight)

Definition at line 60 of file sensors.cpp.

Member Function Documentation

void rosflight_firmware::Sensors::calibrate_accel ( void  )
private

Definition at line 436 of file sensors.cpp.

void rosflight_firmware::Sensors::calibrate_baro ( void  )
private

Definition at line 510 of file sensors.cpp.

void rosflight_firmware::Sensors::calibrate_diff_pressure ( void  )
private

Definition at line 548 of file sensors.cpp.

void rosflight_firmware::Sensors::calibrate_gyro ( void  )
private

Definition at line 388 of file sensors.cpp.

void rosflight_firmware::Sensors::correct_baro ( void  )
private

Definition at line 619 of file sensors.cpp.

void rosflight_firmware::Sensors::correct_diff_pressure ( void  )
private

Definition at line 627 of file sensors.cpp.

void rosflight_firmware::Sensors::correct_imu ( void  )
private

Definition at line 585 of file sensors.cpp.

void rosflight_firmware::Sensors::correct_mag ( void  )
private

Definition at line 600 of file sensors.cpp.

const Data& rosflight_firmware::Sensors::data ( ) const
inline

Definition at line 167 of file sensors.h.

void rosflight_firmware::Sensors::get_filtered_IMU ( turbomath::Vector accel,
turbomath::Vector gyro,
uint64_t &  stamp_us 
)

Definition at line 359 of file sensors.cpp.

bool rosflight_firmware::Sensors::gyro_calibration_complete ( void  )

Definition at line 293 of file sensors.cpp.

void rosflight_firmware::Sensors::init ( )

Definition at line 62 of file sensors.cpp.

void rosflight_firmware::Sensors::init_imu ( )
private

Definition at line 85 of file sensors.cpp.

void rosflight_firmware::Sensors::look_for_disabled_sensors ( void  )
private

Definition at line 237 of file sensors.cpp.

void rosflight_firmware::Sensors::param_change_callback ( uint16_t  param_id)
overridevirtual

Implements rosflight_firmware::ParamListenerInterface.

Definition at line 102 of file sensors.cpp.

bool rosflight_firmware::Sensors::run ( void  )

Definition at line 127 of file sensors.cpp.

bool rosflight_firmware::Sensors::should_send_imu_data ( void  )
inline

Definition at line 182 of file sensors.h.

bool rosflight_firmware::Sensors::start_baro_calibration ( void  )

Definition at line 273 of file sensors.cpp.

bool rosflight_firmware::Sensors::start_diff_pressure_calibration ( void  )

Definition at line 283 of file sensors.cpp.

bool rosflight_firmware::Sensors::start_gyro_calibration ( void  )

Definition at line 264 of file sensors.cpp.

bool rosflight_firmware::Sensors::start_imu_calibration ( void  )

Definition at line 253 of file sensors.cpp.

void rosflight_firmware::Sensors::update_battery_monitor ( void  )
private

Definition at line 370 of file sensors.cpp.

void rosflight_firmware::Sensors::update_battery_monitor_multipliers ( void  )
private

Definition at line 669 of file sensors.cpp.

bool rosflight_firmware::Sensors::update_imu ( void  )
private

Definition at line 300 of file sensors.cpp.

void rosflight_firmware::Sensors::update_other_sensors ( void  )
private

Definition at line 142 of file sensors.cpp.

Member Data Documentation

turbomath::Vector rosflight_firmware::Sensors::acc_sum_ = {0, 0, 0}
private

Definition at line 263 of file sensors.h.

float rosflight_firmware::Sensors::acc_temp_sum_ = 0.0f
private

Definition at line 265 of file sensors.h.

float rosflight_firmware::Sensors::accel_[3] = {0, 0, 0}
private

Definition at line 233 of file sensors.h.

uint16_t rosflight_firmware::Sensors::accel_calibration_count_ = 0
private

Definition at line 262 of file sensors.h.

turbomath::Vector rosflight_firmware::Sensors::accel_int_
private

Definition at line 270 of file sensors.h.

bool rosflight_firmware::Sensors::baro_calibrated_ = false
private

Definition at line 276 of file sensors.h.

uint16_t rosflight_firmware::Sensors::baro_calibration_count_ = 0
private

Definition at line 278 of file sensors.h.

float rosflight_firmware::Sensors::baro_calibration_mean_ = 0.0f
private

Definition at line 280 of file sensors.h.

float rosflight_firmware::Sensors::baro_calibration_var_ = 0.0f
private

Definition at line 281 of file sensors.h.

const float rosflight_firmware::Sensors::BARO_MAX_CALIBRATION_VARIANCE = 25.0
staticprivate

Definition at line 200 of file sensors.h.

const float rosflight_firmware::Sensors::BARO_MAX_CHANGE_RATE = 200.0f
staticprivate

Definition at line 192 of file sensors.h.

OutlierFilter rosflight_firmware::Sensors::baro_outlier_filt_
private

Definition at line 291 of file sensors.h.

const float rosflight_firmware::Sensors::BARO_SAMPLE_RATE = 50.0f
staticprivate

Definition at line 193 of file sensors.h.

float rosflight_firmware::Sensors::battery_current_alpha_ {0.995}
private

Definition at line 298 of file sensors.h.

constexpr uint32_t rosflight_firmware::Sensors::BATTERY_MONITOR_UPDATE_PERIOD_MS = 10
staticprivate

Definition at line 202 of file sensors.h.

float rosflight_firmware::Sensors::battery_voltage_alpha_ {0.995}
private

Definition at line 297 of file sensors.h.

bool rosflight_firmware::Sensors::calibrating_acc_flag_ = false
private

Definition at line 236 of file sensors.h.

bool rosflight_firmware::Sensors::calibrating_gyro_flag_ = false
private

Definition at line 237 of file sensors.h.

Data rosflight_firmware::Sensors::data_
private

Definition at line 231 of file sensors.h.

const float rosflight_firmware::Sensors::DIFF_MAX_CHANGE_RATE = 225.0f
staticprivate

Definition at line 194 of file sensors.h.

OutlierFilter rosflight_firmware::Sensors::diff_outlier_filt_
private

Definition at line 292 of file sensors.h.

bool rosflight_firmware::Sensors::diff_pressure_calibrated_ = false
private

Definition at line 284 of file sensors.h.

uint16_t rosflight_firmware::Sensors::diff_pressure_calibration_count_ = 0
private

Definition at line 285 of file sensors.h.

float rosflight_firmware::Sensors::diff_pressure_calibration_mean_ = 0.0f
private

Definition at line 287 of file sensors.h.

float rosflight_firmware::Sensors::diff_pressure_calibration_var_ = 0.0f
private

Definition at line 288 of file sensors.h.

const float rosflight_firmware::Sensors::DIFF_PRESSURE_MAX_CALIBRATION_VARIANCE = 100.0
staticprivate

Definition at line 201 of file sensors.h.

const float rosflight_firmware::Sensors::DIFF_SAMPLE_RATE = 50.0f
staticprivate

Definition at line 195 of file sensors.h.

const turbomath::Vector rosflight_firmware::Sensors::gravity_ = {0.0f, 0.0f, 9.80665f}
private

Definition at line 264 of file sensors.h.

float rosflight_firmware::Sensors::ground_pressure_ = 0.0f
private

Definition at line 277 of file sensors.h.

float rosflight_firmware::Sensors::gyro_[3] = {0, 0, 0}
private

Definition at line 234 of file sensors.h.

uint16_t rosflight_firmware::Sensors::gyro_calibration_count_ = 0
private

Definition at line 260 of file sensors.h.

turbomath::Vector rosflight_firmware::Sensors::gyro_int_
private

Definition at line 271 of file sensors.h.

turbomath::Vector rosflight_firmware::Sensors::gyro_sum_ = {0, 0, 0}
private

Definition at line 261 of file sensors.h.

bool rosflight_firmware::Sensors::imu_data_sent_
private

Definition at line 257 of file sensors.h.

uint64_t rosflight_firmware::Sensors::int_start_us_
private

Definition at line 272 of file sensors.h.

uint32_t rosflight_firmware::Sensors::last_baro_cal_iter_ms_ = 0
private

Definition at line 279 of file sensors.h.

uint32_t rosflight_firmware::Sensors::last_battery_monitor_update_ms_ = 0
private

Definition at line 295 of file sensors.h.

uint32_t rosflight_firmware::Sensors::last_diff_pressure_cal_iter_ms_ = 0
private

Definition at line 286 of file sensors.h.

uint32_t rosflight_firmware::Sensors::last_imu_update_ms_ = 0
private

Definition at line 254 of file sensors.h.

uint32_t rosflight_firmware::Sensors::last_time_look_for_disarmed_sensors_ = 0
private

Definition at line 253 of file sensors.h.

turbomath::Vector rosflight_firmware::Sensors::max_ = {-1000.0f, -1000.0f, -1000.0f}
private

Definition at line 266 of file sensors.h.

turbomath::Vector rosflight_firmware::Sensors::min_ = {1000.0f, 1000.0f, 1000.0f}
private

Definition at line 267 of file sensors.h.

bool rosflight_firmware::Sensors::new_imu_data_
private

Definition at line 256 of file sensors.h.

uint8_t rosflight_firmware::Sensors::next_sensor_to_update_ = BAROMETER
private

Definition at line 238 of file sensors.h.

uint64_t rosflight_firmware::Sensors::prev_imu_read_time_us_
private

Definition at line 273 of file sensors.h.

ROSflight& rosflight_firmware::Sensors::rf_
private

Definition at line 229 of file sensors.h.

const int rosflight_firmware::Sensors::SENSOR_CAL_CYCLES = 127
staticprivate

Definition at line 199 of file sensors.h.

const int rosflight_firmware::Sensors::SENSOR_CAL_DELAY_CYCLES = 128
staticprivate

Definition at line 198 of file sensors.h.

const float rosflight_firmware::Sensors::SONAR_MAX_CHANGE_RATE = 100.0f
staticprivate

Definition at line 196 of file sensors.h.

OutlierFilter rosflight_firmware::Sensors::sonar_outlier_filt_
private

Definition at line 293 of file sensors.h.

const float rosflight_firmware::Sensors::SONAR_SAMPLE_RATE = 50.0f
staticprivate

Definition at line 197 of file sensors.h.


The documentation for this class was generated from the following files:


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Fri Oct 9 2020 03:17:21