WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
Magnetometer.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/*
17Magnetometer model header file
18
19Author: James Tabony
20*/
21/*
22Metadata for MS GUI:
23imdata = {"displayname" : "Magnetometer",
24 "exclude" : False,
25 "category" : "Sensors"
26}
27aliases = {"bias_initial" : "Bias",
28 "min_mag_field_strength" : "Minimum Mag. Strength",
29 "max_mag_field_strength" : "Maximum Mag. Strength",
30 "mount_frame" : "Spacecraft Body",
31 "mount_position__mf" : "EXCLUDE",
32 "mount_alignment_mf" : "EXCLUDE",
33 "resolution" : "EXCLUDE",
34 "rate_hz" : "Rate Hz",
35 "seed_value" : "EXCLUDE",
36 "mag_field_model_frame" : "Mag. Field Model Frame",
37 "latency" : "EXCLUDE",
38 "gaussian_noise" : "Noise",
39 "walking_bias_std" : "EXCLUDE",
40 "scale_factor_std" : "EXCLUDE",
41 "truth_mag_field__model" : "Truth Mag. Field",
42 "meas_mag_field__mag" : "Meas. Mag. Field",
43 "truth_mag_field__mag" : "EXCLUDE",
44 "is_valid" : "Meas. Validity Flag",
45 "operational_power_draw" : "Operational Power Draw",
46 "mass" : "Mass",
47 "current_power_draw" : "Current Power Draw",
48}
49*/
50
51#ifndef MODELS_SENSORS_MAGNETOMETER_H
52#define MODELS_SENSORS_MAGNETOMETER_H
53
54#include "simulation/Model.h"
55#include "frames/Frame.h"
58#include "utils/LatencyUtil.hpp"
59
60namespace warptwin {
61
96
101 // Default constuctor (should populate with model defualt outputs)
105 // Custom constructor
109 };
110
111 MODEL(Magnetometer)
112 public:
113 // Model params
114 // NAME TYPE DEFAULT VALUE
118 SIGNAL(bias_initial, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
121 SIGNAL(min_mag_field_strength, double, -800000.0)
124 SIGNAL(max_mag_field_strength, double, 800000.0)
128 SIGNAL(mount_frame, Frame*, nullptr)
131 SIGNAL(mount_position__mf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
133 SIGNAL(mount_alignment_mf, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
137 SIGNAL(resolution, double, 0.0)
140 SIGNAL(rate_hz, int, 0)
142 SIGNAL(seed_value, int, 0)
144 SIGNAL(mag_field_model_frame, Frame*, nullptr)
148 SIGNAL(latency, int, 0)
151 SIGNAL(operational_power_draw, double, 0.0)
153 SIGNAL(mass, double, 0.0)
155
156 // Model inputs
157 // NAME TYPE DEFAULT VALUE
161 SIGNAL(gaussian_noise, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
164 SIGNAL(walking_bias_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
166 SIGNAL(scale_factor_std, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
170 SIGNAL(truth_mag_field__model, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
172
173 // Model outputs
174 // NAME TYPE DEFAULT VALUE
179 SIGNAL(output_time, clockwerk::Time, clockwerk::Time(0, 0))
183 SIGNAL(meas_mag_field__mag, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
188 SIGNAL(truth_mag_field__mag, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
191 SIGNAL(is_valid, bool, false)
194 SIGNAL(current_power_draw, double, 0.0)
196
198 clockwerk::DataIO<Frame*> sensor_frame = clockwerk::DataIO<Frame*>(this, "sensor_frame", &_sensor_frame);
199
202 warptwin::MarkovUncertaintyModel* biasNoiseModel() {return &_sensor_noise_model;}
203
206 warptwin::RateMonitor* rateMonitor() {return &_rate_monitor;}
207
208 int16 activate() override;
209 int16 deactivate() override;
210
211 protected:
212 int16 start() override;
213 int16 execute() override;
214
216 void _configureInternal();
217
220
222 MarkovUncertaintyModel _sensor_noise_model;
223
225 RateMonitor _rate_monitor;
226
229
232
235
237 std::array<bool, 3> _in_deadzone;
238
241
244 };
245
246}
247
248#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
Frame class definition.
Definition Frame.h:96
Latency model.
Definition LatencyUtil.hpp:41
#define CartesianVector3
Definition mathmacros.h:43
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)
MarkovUncertaintyModel _sensor_noise_model
The bias and noise model for sensor output.
Definition Accelerometer.h:240
CartesianVector3 _truth_mag_field__mag
Temporary variable to hold the truth magnetic field vector in the sensor frame.
Definition Magnetometer.h:231
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
LatencyUtil< double > _latency_model
The latency model for servo angle output.
Definition Servo.h:116
CartesianVector3 _perturbed_mag
Temporary variable to hold the perturbed acceleration with and without gravity.
Definition Magnetometer.h:234
MODEL(Magnetometer) public warptwin::MarkovUncertaintyModel * biasNoiseModel()
Accessor for the internal bias and noise model.
Definition Magnetometer.h:202
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
Configurable magnetometer model which takes input from simplified or high fidelity magnetic field mod...
Definition Magnetometer.h:98
bool is_valid
Definition Magnetometer.h:100
_magnetometer_output_struct()
Definition Magnetometer.h:102
_magnetometer_output_struct(CartesianVector3 meas_mag_field__mag, bool is_valid)
Definition Magnetometer.h:106
CartesianVector3 meas_mag_field__mag
Definition Magnetometer.h:99