![]() |
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.
******************************************************************************/
/*
Star Tracker model header file
Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Star Tracker",
"exclude" : False,
"category" : "Sensors"
}
aliases = {"reference_frame" : "Att. Reference Frame",
"bias" : "Bias",
"cross_axis_accuracy" : "Cross Axis Accuracy",
"twist_accuracy" : "Twist Axis Accuracy",
"fov" : "FOV",
"mount_frame" : "Spacecraft Body",
"mount_position__mf" : "Body Mount Position",
"mount_alignment_mf" : "Body Mount Alignment",
"rad_tolerance" : "Rad. Tolerance",
"rate_hz" : "Rate Hz",
"seed_value" : "EXCLUDE",
"meas_quat_sf_ref" : "Meas. Attitude",
"perfect_quat_sf_ref" : "EXCLUDE",
"operational_power_draw" : "Operational Power Draw",
"mass" : "Mass",
"current_power_draw" : "Current Power Draw",
}
*/
#ifndef MODELS_SENSORS_STAR_TRACKER_H
#define MODELS_SENSORS_STAR_TRACKER_H
#include "simulation/Model.h"
#include "dynamics/Euler321.h"
#include "dynamics/Quaternion.h"
#include "dynamics/DCM.h"
#include "frames/Frame.h"
#include "models/support/BiasNoiseModel.h"
#include "monitors/RateMonitor.h"
namespace warptwin {
/**
* @brief Model of spacecraft star tracker
*
* This model represents a simple star tracker which may be parameterized
* with a given bias, noise, and rate. It measures the attitude of the
* star tracker frame, which is internally configured, relative to
* an externally assigned reference frame.
*
* The mount frame is defined as:
* Centered in the center of the reference image
* X is "up" in the image
* Y is "right" in the image
* Z is "into" the image completing the right hand frame
*
* |----------------------|
* | x^ |
* | |-->y |
* | |
* |----------------------|
*
* Author: Alex Reynolds <alex.reynolds@attx.tech>
*/
MODEL(StarTracker)
public:
// Model params
// NAME TYPE DEFAULT VALUE
START_PARAMS
/** The bias in measurement output described as a 3-2-1 Euler angle sequence, with angles
* in RADIANS. This parameter may account for a number of factors, including misalignment,
* measurement bias, etc. Default is no bias. */
SIGNAL(bias, clockwerk::Euler321, clockwerk::Euler321({0.0, 0.0, 0.0}))
/** The cross axis accuracy of the star tracker in radians. Default is perfect accuracy */
SIGNAL(cross_axis_accuracy, double, 0.0)
/** The twist axis accuracy of the star tracker in radians. The default is perfect accuracy */
SIGNAL(twist_accuracy, double, 0.0)
/** The field of view of the star tracker defined as the full cone angle in Radians.
* Default is pi/6 radians.
*/
SIGNAL(fov, double, M_PI/6)
/** The mass of the star tracker in kg. Default is massless */
SIGNAL(mass, double, 0.0)
/** The vehicle frame relative to which the star tracker 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 star tracker in the mount frame, represented in the default simulation
* unit (meters by default. pretty much always meters) */
SIGNAL(mount_position__mf, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The alignment of the star tracker relative to the mount frame */
SIGNAL(mount_alignment_mf, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
/** The radiation tolerance of the star tracker in krad. Default is no radiation tolerance */
SIGNAL(rad_tolerance, double, 0.0)
/** The reference frame relative to which all star tracker measurements will be returned.
* If a reference frame is not set, all star tracker measurements will be returned relative
* to the simulation root frame. */
SIGNAL(reference_frame, Frame*, nullptr)
/** The rate at which the star tracker generates an output, in hertz. Setting this value
* to 0 forces the star tracker to output at the simulation rate. */
SIGNAL(rate_hz, int, 0)
/** Value to seed the internal RNG for this model. */
SIGNAL(seed_value, int, 0)
/** Power draw of the star tracker. 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(operational_power_draw, double, 0.0)
END_PARAMS
// Model inputs
// NAME TYPE DEFAULT VALUE
START_INPUTS
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 measurement output quaternion produced by the star tracker describing the
* orientation of the star tracker "sensor frame" relative to the reference frame plus
* appropriate bias, noise, and rate limiting. */
SIGNAL(meas_quat_sf_ref, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
/** The "perfect" output quaternion produced by the star tracker describing the
* orientation of the star tracker "sensor frame" relative to the reference frame. This parameter
* is informational and free from error. */
SIGNAL(perfect_quat_sf_ref, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
/** Power draw of the sensor. 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(current_power_draw, double, 0.0)
END_OUTPUTS
/// @brief Accessor for the sensor's frame
clockwerk::DataIO<Frame*> sensor_frame = clockwerk::DataIO<Frame*>(this, "sensor_frame", &_sensor_frame);
/// @brief Accessor for the internal bias and noise model
/// @return Pointer to the bias noise model
warptwin::BiasNoiseModel* biasNoiseModel() {return &_sensor_bias_noise;}
/// @brief Accessor for the internal rate monitor model
/// @return Pointer to the rate monitor model
warptwin::RateMonitor* rateMonitor() {return &_rate_monitor;}
int16 activate() override;
int16 deactivate() override;
protected:
int16 start() override;
int16 execute() override;
/// @brief Function to configure sensor -- runs in all constructors
void _configureInternal();
/// @brief The sensor frame in which all measurements will be taken
Frame _sensor_frame;
/// @brief The bias and noise model for sensor output.
BiasNoiseModel _sensor_bias_noise;
/// @brief Rate monitor to control the rate at which the sensor runs
RateMonitor _rate_monitor;
// Temporary DCM to hold temporary attitude calculations
clockwerk::DCM _tmp_dcm;
// Internal variable to hold full bias and noise
clockwerk::Euler321 _total_error;
};
}
#endif