![]() |
WarpTwin
Documentation for WarpTwin models and classes.
|
/******************************************************************************
* Copyright (c) ATTX INC 2025. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the
* proprietary and confidential information of ATTX INC. The Software is
* furnished under a license agreement between ATTX and the user organization
* and may be used or copied only in accordance with the terms of the agreement.
* Refer to 'license/attx_license.adoc' for standard license terms.
*
* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
* transmitted in any form or by any means, for any purpose, without the express
* written permission of ATTX INC.
******************************************************************************/
/*
IMU model header file
Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "IMU",
"exclude" : False,
"category" : "Sensors"
}
aliases = {"accelerometer_bias_initial" : "Accelerometer Bias",
"min_acceleration" : "Minimum Acceleration",
"max_acceleration" : "Maximum Acceleration",
"gyroscope_bias_initial" : "Gyro Bias",
"min_ang_vel" : "Minimum Angular Velocity",
"max_ang_vel" : "Maximum Angluar Velocity",
"mount_frame" : "Spacecraft Body",
"mount_position__mf" : "Body Mount Position",
"mount_alignment_mf" : "Body Mount Alignment",
"rate_hz" : "Rate Hz",
"accelerometer_seed_value" : "EXCLUDE",
"gyro_seed_value" : "EXCLUDE",
"gravity_frame" : "Gravity Vector Frame",
"accelerometer_resolution" : "EXCLUDE",
"gyroscope_resolution" : "EXCLUDE",
"latency" : "EXCLUDE",
"accelerometer_gaussian_noise" : "Accelerometer Noise",
"accelerometer_walking_bias_std" : "EXCLUDE",
"accelerometer_scale_factor_std" : "EXCLUDE",
"gyroscope_gaussian_noise" : "Gyro Noise",
"gyroscope_walking_bias_std" : "EXCLUDE",
"gyroscope_scale_factor_std" : "EXCLUDE",
"gravity__gf" : "Gravity Vector",
"meas_accel_sf" : "Meas. Acceleration",
"perfect_accel_sf" : "EXCLUDE",
"meas_accel_sf_incl_grav" : "EXCLUDE",
"perfect_accel_sf_incl_grav" : "EXCLUDE",
"meas_ang_vel_sf" : "Meas. Ang. Vel.",
"perfect_ang_vel_sf" : "EXCLUDE",
"accelerometer_is_valid" : "Accelerometer Meas. Validity Flag",
"gyroscope_is_valid" : "Gyro Meas. Validity Flag",
"accelerometer_operational_power_draw" : "Accelerometer Operational Power Draw",
"gyro_operational_power_draw" : "Gyro Operational Power Draw",
"mass" : "Mass",
"accelerometer_current_power_draw" : "Accelerometer Current Power Draw",
"gyro_current_power_draw" : "Gyro Current Power Draw",
}
*/
#ifndef MODELS_SENSORS_IMU_H
#define MODELS_SENSORS_IMU_H
#include "simulation/Model.h"
#include "models/sensors/Accelerometer.h"
#include "models/sensors/Gyroscope.h"
#include "constants/planetdefaults.h"
namespace warptwin {
/**
* @brief Model of IMU on vehicle which accounts for noise, bias, and drift
*
* The IMU model is a simple wrapper around the accelerometer and gyro models,
* wrapping them into a single package. For details on each element of the IMU,
* see the accelerometer or gyro definitions.
*
* Author: Alex Reynolds <alex.reynolds@attx.tech>
*/
MODEL(IMU)
public:
// Model params
// NAME TYPE DEFAULT VALUE
START_PARAMS
/** The initial bias in accelerometer measurement output described as a three-element vector in meters/second^2.
* Default is no bias. Must be set before model startup. */
SIGNAL(accelerometer_bias_initial, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The minimum acceleration that the sensor can record in each axis. Default is -20 g's (meters/second^2) */
SIGNAL(min_acceleration, double, -20.0*warpos::earth_wgs84.mean_gravity)
/** The maximum acceleration that the sensor can record in each axis. Defualt is 20 g's (meters/second^2) */
SIGNAL(max_acceleration, double, 20.0*warpos::earth_wgs84.mean_gravity)
/** The initial bias in gyroscope measurement output described as a three-element vector in radians/second.
* Default is no bias. Must be set before model startup. */
SIGNAL(gyroscope_bias_initial, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The minimum angular velocity that the sensor can record in each axis. Default is -540 degrees/second (radians/second) */
SIGNAL(min_ang_vel, double, -540.0*warpos::DEGREES_TO_RADIANS)
/** The maximum angular velocity that the sensor can record in each axis. Default is 540 degrees/second (radians/second) */
SIGNAL(max_ang_vel, double, 540.0*warpos::DEGREES_TO_RADIANS)
/** The vehicle frame relative to which the sensor is mounted and aligned. This is most
* typically the body frame of a spacecraft or other vehicle. mount_position__mf and mount_alignment_mf
* are described relative to this frame. */
SIGNAL(mount_frame, Frame*, nullptr)
/** The position of the sensor in the mount frame, represented in the default simulation
* unit (meters by deĀ fault. pretty much always meters) */
SIGNAL(mount_position__mf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The alignment of the accelerometer relative to the mount frame */
SIGNAL(mount_alignment_mf, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
/** The rate at which the sensor generates an output, in hertz. Setting this value
* to 0 forces the sensor to output at the simulation rate. */
SIGNAL(rate_hz, int, 0)
/** Value to seed the internal RNG for this model. */
SIGNAL(accelerometer_seed_value,int, 0)
/** Value to seed the internal RNG for this model. */
SIGNAL(gyro_seed_value, int, 0)
/** The frame in which gravity is represented. If this parameter is not set,
* the gravity frame is assumed to be the root frame of the simulation. */
SIGNAL(gravity_frame, Frame*, nullptr)
/** The measurement resolution. The output value will be some multiple of this value. If the
* value is left at zero, an infinite resolution will be assumed, i.e. no data loss/quantinization.
* From a data sheet, this value can be computed as (measurement range) / 2^(bits per measurement) . (meters/second^2) */
SIGNAL(accelerometer_resolution, double, 0.0)
/** The measurement resolution. The output value will be some multiple of this value. If the
* value is left at zero, an infinite resolution will be assumed, i.e. no data loss/quantinization.
* From a data sheet, this value can be computed as (measurement range) / 2^(bits per measurement) . (radians/second) */
SIGNAL(gyroscope_resolution, double, 0.0)
/** Latency of the pressure sensor, millisecond value for the amount of delay in sim time for
* the correct values to be reflected in the outputs. Must be set before executive startup.
* Defaults to no delay. (milliseconds) */
SIGNAL(latency, int, 0)
/** Power draw of the accelerometer. This value may or may not be the peak power draw provided by most
* data sheets. This value is the expected power draw of a sensor when operational. (Watts) */
SIGNAL(accelerometer_operational_power_draw, double, 0.0)
/** Power draw of the gyroscope. This value may or may not be the peak power draw provided by most
* data sheets. This value is the expected power draw of a sensor when operational. (Watts) */
SIGNAL(gyro_operational_power_draw, double, 0.0)
/** Mass of the accelerometer. (kg) */
SIGNAL(mass, double, 0.0)
END_PARAMS
// Model inputs
// NAME TYPE DEFAULT VALUE
START_INPUTS
/** The one-sigma Gaussian noise in accelerometer measurement output described as a three-element vector
* in meters/second^2. Default is no noise. */
SIGNAL(accelerometer_gaussian_noise, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The one-sigma Gaussian noise in the accelerometer bias drift described as a three-element vector
* in meters/second^2/sqrt(second). Default is no walking-bias drift. */
SIGNAL(accelerometer_walking_bias_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The one-sigma scale percent increase/decrease of the measurement. Default is no scaling. */
SIGNAL(accelerometer_scale_factor_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The one-sigma Gaussian noise in gyroscope measurement output described as a three-element vector
* in radians/second. Default is no noise. */
SIGNAL(gyroscope_gaussian_noise, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The one-sigma Gaussian noise in the gyroscope bias drift described as a three-element vector
* in radians/second/sqrt(second). Default is no walking-bias drift. */
SIGNAL(gyroscope_walking_bias_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The one-sigma scale percent increase/decrease of the measurement. Default is no scaling. */
SIGNAL(gyroscope_scale_factor_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The gravity vector acting on the sensor as represented in the gravity frame */
SIGNAL(gravity__gf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
END_INPUTS
// Model outputs
// NAME TYPE DEFAULT VALUE
START_OUTPUTS
/** Output time tied to measurements. Output time is exactly the navigation time
* (see SimTimeManager for configuration), without latency (instantaneous) but
* but with a rate that mirrors output rate */
SIGNAL(output_time, clockwerk::Time, clockwerk::Time(0, 0))
/** The measured output acceleration produced by the accelerometer describing the
* acceleration of the sensor frame relative to the simulation root frame
* appropriate bias, noise, and rate limiting, with gravity removed */
SIGNAL(meas_accel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The "perfect" output acceleration produced by the accelerometer describing the
* acceleration of the sensor frame relative to the simulation root frame
* without error sources, with gravity removed. This is an informational parameter. */
SIGNAL(perfect_accel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The measured output acceleration produced by the accelerometer describing the
* acceleration of the sensor frame relative to the simulation root frame
* with error sources, with gravity included. (meters/second^2) */
SIGNAL(meas_accel_sf_incl_grav, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The "perfect" output acceleration produced by the accelerometer describing the
* acceleration of the sensor frame relative to the simulation root frame
* without error sources, with gravity included. This is an informational parameter */
SIGNAL(perfect_accel_sf_incl_grav, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The measured output angular velocity produced by the gyro describing the
* angular velocity of the sensor frame relative to the simulation root frame
* appropriate bias, noise, and rate limiting */
SIGNAL(meas_ang_vel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The "perfect" output angular velocity produced by the gyro describing the
* angular velocity of the sensor frame (incl. misalignment) relative to the simulation root frame
* without bias and noise. This is an informational parameter. */
SIGNAL(perfect_ang_vel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** Boolean value to notify if the output measurement is valid (i.e. boolean for
* blackout-zones). True = not in blackout-zone, False = in blackout-zone. */
SIGNAL(accelerometer_is_valid, bool, false)
/** Boolean value to notify if the output measurement is valid (i.e. boolean for
* blackout-zones). True = not in blackout-zone, False = in blackout-zone. */
SIGNAL(gyroscope_is_valid, bool, false)
/** Power draw of the accelerometer. This value is populated when the model is active, and zero
* when the model is deactive. Allows the user to create duty cycles and power budgets. (Watts) */
SIGNAL(accelerometer_current_power_draw, double, 0.0)
/** Power draw of the gyroscope. This value is populated when the model is active, and zero
* when the model is deactive. Allows the user to create duty cycles and power budgets. (Watts) */
SIGNAL(gyro_current_power_draw, double, 0.0)
/** The bias of the gyroscope. (rad/s) */
SIGNAL(gyro_bias, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The bias of the accelerometer. (m/s^2) */
SIGNAL(accel_bias, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
END_OUTPUTS
/// @brief Function to access the internal accelerometer model
/// @return Handle to the accelerometer model
warptwin::Accelerometer* accelerometer() {return &_accelerometer;}
/// @brief Function to access the internal gyro model
/// @return Handle to the gyro model
warptwin::Gyroscope* Gyroscope() {return &_gyro;}
// Activate amd deactivate functions call both the accelerometer and gyro active/deactive
int16 activate() override;
int16 deactivate() override;
// Model-specific implementations of startup and derivative
protected:
int16 start() override;
/// @brief Function to configure sensor -- runs in all constructors
void _configureInternal();
/// @brief The IMU accelerometer model
warptwin::Accelerometer _accelerometer;
/// @brief The IMU gyro model
warptwin::Gyroscope _gyro;
};
}
#endif