WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
Accelerometer.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX INC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX INC.
15******************************************************************************/
16/*
17Accelerometer model header file
18
19Author: Alex Reynolds
20*/
21/*
22Metadata for MS GUI:
23imdata = {"displayname" : "Accelerometer",
24 "exclude" : False,
25 "category" : "Sensors"
26}
27aliases = {"bias_initial" : "Bias",
28 "min_acceleration" : "Minimum Acceleration",
29 "max_acceleration" : "Maximum Acceleration",
30 "mount_frame" : "Spacecraft Body",
31 "mount_position__mf" : "Body Mount Position",
32 "mount_alignment_mf" : "Body Mount Alignment",
33 "resolution" : "EXCLUDE",
34 "rate_hz" : "Rate Hz",
35 "seed_value" : "EXCLUDE",
36 "gravity_frame" : "Gravity Vector Frame",
37 "latency" : "EXCLUDE",
38 "gaussian_noise" : "Noise",
39 "walking_bias_std" : "EXCLUDE",
40 "scale_factor_std" : "EXCLUDE",
41 "gravity__gf" : "Gravity Vector",
42 "meas_accel_sf" : "Meas. Acceleration",
43 "perfect_accel_sf" : "EXCLUDE",
44 "meas_accel_sf_incl_grav" : "EXCLUDE",
45 "perfect_accel_sf_incl_grav" : "EXCLUDE",
46 "is_valid" : "Meas. Validity Flag",
47 "operational_power_draw" : "Operational Power Draw",
48 "mass" : "Mass",
49 "current_power_draw" : "Current Power Draw",
50}
51*/
52
53#ifndef MODELS_SENSORS_ACCELEROMETER_H
54#define MODELS_SENSORS_ACCELEROMETER_H
55
56#include "simulation/Model.h"
57#include "frames/Frame.h"
62#include "utils/LatencyUtil.hpp"
63
64namespace warptwin {
65
100
120
121 MODEL(Accelerometer)
122 public:
123 // Model params
124 // NAME TYPE DEFAULT VALUE
128 SIGNAL(bias_initial, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
130 SIGNAL(min_acceleration, double, -20.0*warpos::earth_wgs84.mean_gravity)
132 SIGNAL(max_acceleration, double, 20.0*warpos::earth_wgs84.mean_gravity)
136 SIGNAL(mount_frame, Frame*, nullptr)
139 SIGNAL(mount_position__mf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
141 SIGNAL(mount_alignment_mf, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
145 SIGNAL(resolution, double, 0.0)
148 SIGNAL(rate_hz, int, 0)
150 SIGNAL(seed_value, int, 0)
153 SIGNAL(gravity_frame, Frame*, nullptr)
157 SIGNAL(latency, int, 0)
160 SIGNAL(operational_power_draw, double, 0.0)
162 SIGNAL(mass, double, 0.0)
164
165 // Model inputs
166 // NAME TYPE DEFAULT VALUE
170 SIGNAL(gaussian_noise, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
173 SIGNAL(walking_bias_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
175 SIGNAL(scale_factor_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
177 SIGNAL(gravity__gf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
179
180 // Model outputs
181 // NAME TYPE DEFAULT VALUE
186 SIGNAL(output_time, clockwerk::Time, clockwerk::Time(0, 0))
190 SIGNAL(meas_accel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
195 SIGNAL(perfect_accel_sf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
199 SIGNAL(meas_accel_sf_incl_grav, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
204 SIGNAL(perfect_accel_sf_incl_grav,CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
207 SIGNAL(is_valid, bool, false)
210 SIGNAL(current_power_draw, double, 0.0)
212 SIGNAL(bias, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
214
216 clockwerk::DataIO<Frame*> sensor_frame = clockwerk::DataIO<Frame*>(this, "sensor_frame", &_sensor_frame);
217
220 warptwin::MarkovUncertaintyModel* getNoiseModel() {return &_sensor_noise_model;}
221
224 warptwin::RateMonitor* rateMonitor() {return &_rate_monitor;}
225
226 int16 activate() override;
227 int16 deactivate() override;
228
229 protected:
230 int16 start() override;
231 int16 execute() override;
232
234 void _configureInternal();
235
238
240 MarkovUncertaintyModel _sensor_noise_model;
241
243 RateMonitor _rate_monitor;
244
247
250
253
256
259
262
265 };
266
267}
268
269#endif
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition appmacros.h:27
#define START_PARAMS
Definition appmacros.h:42
#define END_OUTPUTS
Definition appmacros.h:33
#define END_PARAMS
Definition appmacros.h:47
#define START_OUTPUTS
Definition appmacros.h:28
#define END_INPUTS
Definition appmacros.h:40
#define START_INPUTS
Definition appmacros.h:35
Standard vector class derived from Matrix.
Definition CartesianVector.hpp:39
Class defining a direction cosine matrix inherited from Matrix.
Definition DCM.h:69
Frame class definition.
Definition Frame.h:96
Latency model.
Definition LatencyUtil.hpp:41
#define CartesianVector3
Definition mathmacros.h:43
PlanetDefaults earth_wgs84
Definition planetdefaults.cpp:22
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
CartesianVector3 _previous_bias
Temporary variable to hold the bias vector at last function call.
Definition Accelerometer.h:246
int16 start() override
Class to execute logging.
SIGNAL(_mu, double, warpos::earth_wgs84.mu)
CartesianVector3 _perturbed_accel_no_grav
Definition Accelerometer.h:249
MarkovUncertaintyModel _sensor_noise_model
The bias and noise model for sensor output.
Definition Accelerometer.h:240
clockwerk::DCM _dcm_sf_root
A DCM relating our sensor frame to root.
Definition Accelerometer.h:252
Frame _sensor_frame
The sensor frame in which all measurements will be taken.
Definition Accelerometer.h:237
void _configureInternal()
Function to configure sensor – runs in all constructors.
warptwin::RateMonitor * rateMonitor()
Accessor for the internal rate monitor model.
Definition Accelerometer.h:224
int16 activate() override
_accel_output_struct _last_output
Temporary variable for the latest recorded output added to latency model and dummy output for steppin...
Definition Accelerometer.h:264
MODEL(Servo) public int16 deactivate() override
Model to simulate a servo's motion.
@ MODEL
Simplified dynamics model representing motion in the circular restricted 3 body problem.
Definition ImNode.h:31
CartesianVector3 _perturbed_accel
Temporary variable to hold the perturbed acceleration with and without gravity.
Definition Accelerometer.h:249
LatencyUtil< double > _latency_model
The latency model for servo angle output.
Definition Servo.h:116
MODEL(Accelerometer) public warptwin::MarkovUncertaintyModel * getNoiseModel()
Accessor for the internal noise model.
Definition Accelerometer.h:220
int16 execute() override
Function to check monitor input conditions and set trigger flag accordingly. Should be implemented in...
RateMonitor _rate_monitor
Rate monitor to control the rate at which the sensor runs.
Definition Accelerometer.h:243
clockwerk::CartesianVector< 3 > _in_deadzone
Temporary variable for checking if sensor is in deadzone. Each element of vector corresponds to an ax...
Definition Accelerometer.h:258
double _latency_return
Temporary value for the return of the latency value.
Definition Servo.h:122
CartesianVector3 _gravity__sensor
The gravity vector as represented in the sensor frame.
Definition Accelerometer.h:255
Accelerometer Model.
Definition Accelerometer.h:102
CartesianVector3 meas_accel_sf
Definition Accelerometer.h:103
_accel_output_struct()
Definition Accelerometer.h:108
_accel_output_struct(CartesianVector3 meas_accel_sf, CartesianVector3 meas_accel_sf_incl_grav, CartesianVector3 bias, bool is_valid)
Definition Accelerometer.h:114
CartesianVector3 meas_accel_sf_incl_grav
Definition Accelerometer.h:104
bool is_valid
Definition Accelerometer.h:106
CartesianVector3 bias
Definition Accelerometer.h:105