STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fsw::calibration::RobustCalibrationManager Class Reference

Runtime PT calibration via RobustCalibrationFramework (9-D basis, TLS / Bayesian / RLS / GLR / bias), seeded from factory cubic. More...

#include <RobustCalibrationManager.hpp>

Collaboration diagram for fsw::calibration::RobustCalibrationManager:
[legend]

Public Member Functions

 RobustCalibrationManager ()
void initialize_sensor (uint16_t sensor_id, const PTCalibrationCoeffs &baseline)
void update_calibration (uint16_t sensor_id, int32_t adc_code, double reference_pressure)
void zero_sensor (uint16_t sensor_id, int32_t adc_code)
void reseed_sensor (uint16_t sensor_id, const PTCalibrationCoeffs &baseline)
 Reseed a sensor's framework cleanly from the given cubic baseline, discarding any learned adjustments and ignoring restored/population priors.
double predict_pressure_psi (uint16_t sensor_id, int32_t adc_code)
 Mean PSI from the robust model (default environment).
bool has_sensor (uint16_t sensor_id) const
 True if this sensor_id was initialized for robust tracking (factory-baselined).
void reset_adjustment (uint16_t sensor_id)
bool save_adjustments (const std::string &path, const std::map< uint16_t, std::string > *uid_to_role=nullptr) const
 Persist per-sensor θ.
bool load_adjustments (const std::string &path, const std::map< uint16_t, std::string > *uid_to_role=nullptr)
 Restore per-sensor θ.

Private Attributes

std::mutex mutex_
std::map< uint16_t, SensorState > states_
std::optional< Eigen::VectorXd > population_theta_mean_
std::optional< Eigen::MatrixXd > population_theta_cov_
std::map< uint16_t, Eigen::VectorXd > restored_theta_mean_
std::map< uint16_t, Eigen::MatrixXd > restored_theta_cov_

Detailed Description

Runtime PT calibration via RobustCalibrationFramework (9-D basis, TLS / Bayesian / RLS / GLR / bias), seeded from factory cubic.

Streaming pressure uses predict_pressure_psi(), not a live cubic polynomial.

Definition at line 29 of file RobustCalibrationManager.hpp.

Constructor & Destructor Documentation

◆ RobustCalibrationManager()

fsw::calibration::RobustCalibrationManager::RobustCalibrationManager ( )
default

Member Function Documentation

◆ has_sensor()

bool fsw::calibration::RobustCalibrationManager::has_sensor ( uint16_t sensor_id) const

True if this sensor_id was initialized for robust tracking (factory-baselined).

Definition at line 193 of file RobustCalibrationManager.cpp.

References lock, mutex_, and states_.

Referenced by invert_abort_psi_to_adc(), and main().

◆ initialize_sensor()

void fsw::calibration::RobustCalibrationManager::initialize_sensor ( uint16_t sensor_id,
const PTCalibrationCoeffs & baseline )

◆ load_adjustments()

bool fsw::calibration::RobustCalibrationManager::load_adjustments ( const std::string & path,
const std::map< uint16_t, std::string > * uid_to_role = nullptr )

Restore per-sensor θ.

When uid_to_role is given, an entry tagged with a role is restored into the sensor_id that role currently maps to (so a moved sensor keeps its learned state), falling back to the persisted numeric id for untagged/legacy entries.

Definition at line 256 of file RobustCalibrationManager.cpp.

References lock, mutex_, fsw::calibration::RobustCalibrationFramework::N, population_theta_cov_, population_theta_mean_, restored_theta_cov_, restored_theta_mean_, state, and states_.

Referenced by main().

◆ predict_pressure_psi()

double fsw::calibration::RobustCalibrationManager::predict_pressure_psi ( uint16_t sensor_id,
int32_t adc_code )

Mean PSI from the robust model (default environment).

Definition at line 185 of file RobustCalibrationManager.cpp.

References lock, mutex_, and states_.

Referenced by invert_abort_psi_to_adc(), and main().

◆ reseed_sensor()

void fsw::calibration::RobustCalibrationManager::reseed_sensor ( uint16_t sensor_id,
const PTCalibrationCoeffs & baseline )

Reseed a sensor's framework cleanly from the given cubic baseline, discarding any learned adjustments and ignoring restored/population priors.

Used when a calibration profile is swapped live: the profile is the whole cal, so robust resets and relearns from it.

Definition at line 209 of file RobustCalibrationManager.cpp.

References lock, mutex_, state, and states_.

Referenced by main().

◆ reset_adjustment()

void fsw::calibration::RobustCalibrationManager::reset_adjustment ( uint16_t sensor_id)

Definition at line 199 of file RobustCalibrationManager.cpp.

References lock, mutex_, state, and states_.

Referenced by main().

◆ save_adjustments()

bool fsw::calibration::RobustCalibrationManager::save_adjustments ( const std::string & path,
const std::map< uint16_t, std::string > * uid_to_role = nullptr ) const

Persist per-sensor θ.

When uid_to_role is given, each entry also records its role so a later load can re-attach it to the role's current sensor_id (calibration follows the sensor).

Definition at line 218 of file RobustCalibrationManager.cpp.

References basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::array(), lock, mutex_, fsw::calibration::RobustCalibrationFramework::N, r, state, and states_.

Referenced by main().

◆ update_calibration()

void fsw::calibration::RobustCalibrationManager::update_calibration ( uint16_t sensor_id,
int32_t adc_code,
double reference_pressure )

◆ zero_sensor()

void fsw::calibration::RobustCalibrationManager::zero_sensor ( uint16_t sensor_id,
int32_t adc_code )

Member Data Documentation

◆ mutex_

std::mutex fsw::calibration::RobustCalibrationManager::mutex_
mutableprivate

◆ population_theta_cov_

std::optional<Eigen::MatrixXd> fsw::calibration::RobustCalibrationManager::population_theta_cov_
private

Definition at line 70 of file RobustCalibrationManager.hpp.

Referenced by initialize_sensor(), and load_adjustments().

◆ population_theta_mean_

std::optional<Eigen::VectorXd> fsw::calibration::RobustCalibrationManager::population_theta_mean_
private

Definition at line 69 of file RobustCalibrationManager.hpp.

Referenced by initialize_sensor(), and load_adjustments().

◆ restored_theta_cov_

std::map<uint16_t, Eigen::MatrixXd> fsw::calibration::RobustCalibrationManager::restored_theta_cov_
private

Definition at line 73 of file RobustCalibrationManager.hpp.

Referenced by initialize_sensor(), and load_adjustments().

◆ restored_theta_mean_

std::map<uint16_t, Eigen::VectorXd> fsw::calibration::RobustCalibrationManager::restored_theta_mean_
private

Definition at line 72 of file RobustCalibrationManager.hpp.

Referenced by initialize_sensor(), and load_adjustments().

◆ states_

std::map<uint16_t, SensorState> fsw::calibration::RobustCalibrationManager::states_
private

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