![]() |
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.
******************************************************************************/
/*
Camera sensor model header file
Author: Alex Reynolds
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Simple Camera",
"exclude" : False,
"category" : "Sensors"
}
aliases = {"target_obj_frame" : "Sensed Target",
"alpha_bias" : "Alpha Angle Bias",
"beta_bias" : "Beta Angle Bias",
"alpha_gaussian_noise" : "Alpha Angle Noise",
"beta_gaussian_noise" : "Beta Angle Noise",
"mount_frame" : "Spacecraft Body",
"mount_position__mf" : "Body Mount Position",
"mount_alignment_mf" : "Body Mount Alignment",
"rate_hz" : "Rate Hz",
"seed_value" : "EXCLUDE",
"measured_alpha" : "Meas. Alpha Angle",
"measured_beta" : "Meas. Beta Angle",
"perfect_alpha" : "EXCLUDE",
"perfect_beta" : "EXCLUDE",
"operational_power_draw" : "Operational Power Draw",
"mass" : "Mass",
"current_power_draw" : "Current Power Draw",
}
*/
#ifndef MODELS_SENSORS_SIMPLE_CAMERA_SENSOR_H
#define MODELS_SENSORS_SIMPLE_CAMERA_SENSOR_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 Simple Camera Model
*
* This model simulates a simplified camera which produces line of sight
* (alpha and beta) angles relative to a target
*
* Author: Alex Reynolds <alex.reynolds@attx.tech>
*/
MODEL(SimpleCamera)
public:
// Model params
// NAME TYPE DEFAULT VALUE
START_PARAMS
/** The frame of the object being sensed by the simple camera model. */
SIGNAL(target_obj_frame, Frame*, nullptr)
/** The bias in the alpha angle measurement output described as a single scalar, with angle
* in RADIANS. This parameter may account for a number of factors, including misalignment,
* measurement bias, etc. Default is no bias. */
SIGNAL(alpha_bias, double, 0.0)
/** The bias in the beta angle measurement output described as a single scalar, with angle
* in RADIANS. This parameter may account for a number of factors, including misalignment,
* measurement bias, etc. Default is no bias. */
SIGNAL(beta_bias, double, 0.0)
/** The one-sigma gaussian noise in alpha measurement output described as a scalar,
* with angle in RADIANS. Default is no noise. */
SIGNAL(alpha_gaussian_noise, double, 0.0)
/** The one-sigma gaussian noise in beta measurement output described as a scalar,
* with angle in RADIANS. Default is no noise. */
SIGNAL(beta_gaussian_noise, double, 0.0)
/** The vehicle frame relative to which the camera 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 camera 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 camera 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 camera generates an output, in hertz. Setting this value
* to 0 forces the camera 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 camera. 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)
/** Mass of the camera. (kg) */
SIGNAL(mass, double, 0.0)
END_PARAMS
// Model inputs
// NAME TYPE DEFAULT VALUE
START_INPUTS
END_INPUTS
// Model outputs
// NAME TYPE DEFAULT VALUE
START_OUTPUTS
/** The alpha angle measurement output produced from the camera describing the
* location of the target object frame relative to the reference frame plus
* appropriate bias, noise, and rate limiting. */
SIGNAL(measured_alpha, double, 0.0)
/** The beta angle measurement output produced from the camera describing the
* location of the target object frame relative to the reference frame plus
* appropriate bias, noise, and rate limiting. */
SIGNAL(measured_beta, double, 0.0)
/** The alpha angle measurement output produced from the camera describing the
* location of the target object frame relative to the reference frame without
* noise or error. This parameter is informational. */
SIGNAL(perfect_alpha, double, 0.0)
/** The beta angle measurement output produced from the camera describing the
* location of the target object frame relative to the reference frame without
* noise or error. This parameter is informational. */
SIGNAL(perfect_beta, double, 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
CartesianVector3 _pos_tgt_mount__mount;
};
}
#endif