![]() |
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.
******************************************************************************/
/*
Reaction wheel model header file
Author: Alex Jackson
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Reaction Wheel",
"exclude" : False,
"category" : "Actuators"
}
aliases = {"sc_body" : "Spacecraft Body",
"wheel_location__body" : "Wheel Position",
"quat_wheel_body" : "Wheel Orientation",
"torque_bias" : "Bias",
"torque_noise_std" : "Noise",
"seed_value" : "EXCLUDE",
"mass" : "Mass",
"mom_inertia" : "Moment of Inertia",
"operational" : "Operational",
"power" : "Power Draw",
"rad_tolerance" : "Rad. Tolerance",
"peak_torque" : "Peak Torque",
"momentum_cap" : "Momentum Cap",
"torque_com" : "Torque Cmd",
"momentum" : "Momentum",
"saturated" : "Saturated",
"wheel_speed" : "Wheel RPM",
"power_draw" : "Power Draw",
"applied_torque" : "Applied Torque",
}
*/
#ifndef MODELS_ACTUATORS_REACTION_WHEEL_MODEL_H
#define MODELS_ACTUATORS_REACTION_WHEEL_MODEL_H
#include "simulation/Model.h"
#include "core/CartesianVector.hpp"
#include "frames/Body.h"
#include "frames/Node.h"
#include "frames/Joint.h"
#include "models/support/BiasNoiseModel.h"
namespace warptwin {
/**
* @brief Reaction Wheel Model
*
* This is a model of a reaction wheel which applies a torque to a reaction wheel
* and thus the spacecraft in the opposite direction. The momentum stored in the
* reaction wheel and the wheel speed are both recorded. A positive torque is applied
* about the z axis of the reaction wheel which is the orthoganal vector to the reaction
* wheel.
*
* Note that the torque applied to the sc body will be negative of the commmanded torque.
* Noise is applied as a gaussian noise about the commanded torque.
*
* @author Alex Jackson <alex.jackson@attx.tech>
*/
MODEL(ReactionWheelModel)
public:
// Model params
// NAME TYPE DEFAULT VALUE
START_PARAMS
/** The body which will be controlled by this model. The torque will be applied to a
* node aligned to this body, and WarpTwin will translate to force and torque at the body */
SIGNAL(sc_body, Body*, nullptr)
/** The reaction wheel location relative to the provided body in the body frame */
SIGNAL(wheel_location__body, CartesianVector3, CartesianVector3({0.0, 0.0, 0.0}))
/** The reaction wheel orientation wrt the body frame. This z axis of the reaction wheel
* is the orthogonal vector to the reaction wheel that a positive torque is applied about */
SIGNAL(quat_wheel_body, clockwerk::Quaternion, clockwerk::Quaternion({1.0, 0.0, 0.0, 0.0}))
/** The bias in the wheel which is applied to every time it is commanded. */
SIGNAL(torque_bias, double, 0.0)
/** The standard deviation of torque noise. A new noise
* draw is taken every time a new torque command is received. */
SIGNAL(torque_noise_std, double, 0.0)
/** Value to seed the internal RNG for this model. */
SIGNAL(seed_value, int, 0)
/** The mass of the reaction wheel in kg. Default is massless */
SIGNAL(mass, double, 0.0)
/** The moment of inertia of the reaction wheel about its rotational axis in kg-m^2. */
SIGNAL(mom_inertia, double, 0.0)
/** The radiation tolerance of the reaction wheel in krad. Default is no radiation tolerance */
SIGNAL(rad_tolerance, double, 0.0)
/** The peak torque that can be applied by the reaction wheel in Nm */
SIGNAL(peak_torque, double, 0.0)
/** The momentum capacity of the reaction wheel in Nms */
SIGNAL(momentum_cap, double, 0.0)
/** The power draw of the reaction wheel in watts. Default is no power draw */
SIGNAL(power, double, 0.0)
/** Boolean value to specify if the reaction wheel is on and drawing power. Default is on */
SIGNAL(operational, bool, true)
END_PARAMS
// Model inputs
// NAME TYPE DEFAULT VALUE
START_INPUTS
/** The commanded torque to the reaction wheel about its normal vector*/
SIGNAL(torque_com, double, 0.0)
END_INPUTS
// Model outputs
// NAME TYPE DEFAULT VALUE
START_OUTPUTS
/** The momentum stored by the reaction wheel in Nms*/
SIGNAL(momentum, double, 0.0)
/** Boolean to specify if the wheel is saturated */
SIGNAL(saturated, bool, false)
/** The wheel speed of the reaction wheel in rpm*/
SIGNAL(wheel_speed, double, 0.0)
/** The power draw of the reaction wheel. Simply outputs the power parameter when the reaction wheel is on */
SIGNAL(power_draw, double, 0.0)
/** The torque applied to the body */
SIGNAL(applied_torque, double, 0.0)
END_OUTPUTS
protected:
int16 start() override;
int16 execute() override;
/// @brief The bias and noise model for torque output.
BiasNoiseModel _torque_bias_noise;
/// @brief The reaction wheel node.
Node _wheel_node;
/// @brief Matrix to hold the moment of inertia tensor of the wheel
Matrix3 _mom_inertia_tensor;
/// @brief Value to hold perturbation to torque
double _torque_perturbation = 0.0;
/// @brief Value to hold total torque calculation
double _total_torque = 0.0;
/// @brief Conversion between radians per second and revolutions per minute
double _rps_to_rpm = 60.0/(2*M_PI);
/// @brief Boolean to store the previous operational state
bool _prev_com = false;
};
}
#endif