Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def thrusterEffectorAllTests(show_plots):
# provide a unique test method name, starting with test_
def test_unitThrusters(show_plots, long_angle, lat_angle, location, rate):
r"""
This unit test checks the functionality of attaching a dynamic thruster to a body other than the hub. Although the
attached body is fixed with respect to the hub, the point where the thruster is attached now has an additional
offset and a different orientation.
This unit test checks the functionality of attaching a dynamic thruster to a body other than the hub using the
messaging system. Although the attached body is fixed with respect to the hub, the point where the thruster is
attached now has an additional offset and a different orientation.

The unit test sets up the thruster as normal, but then converts the direction and location to take into account the
attached body for testing purposes. The thruster is set to fire for the first half of the simulation, and then turn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ ThrusterDynamicEffector::ThrusterDynamicEffector()
forceExternal_N.fill(0.0);
this->stateDerivContribution.resize(1);
this->stateDerivContribution.setZero();

/* this effector can be attached onto a state effector */
this->isAttachableToStateEffector = true;
return;
}

Expand Down Expand Up @@ -180,11 +183,19 @@ void ThrusterDynamicEffector::ConfigureThrustRequests(double currentTime)
void ThrusterDynamicEffector::UpdateThrusterProperties()
{
// Save hub variables
Eigen::Vector3d r_BN_N = (Eigen::Vector3d)*this->inertialPositionProperty;
Eigen::Vector3d omega_BN_B = this->hubOmega->getState();
Eigen::MRPd sigma_BN;
sigma_BN = (Eigen::Vector3d)this->hubSigma->getState();
Eigen::Vector3d omega_BN_B;
if (!this->stateNameOfSigma.empty()) {
omega_BN_B = this->hubOmega->getState();
sigma_BN = (Eigen::Vector3d)this->hubSigma->getState();
}
else {
omega_BN_B = *this->inertialAngVelocityProperty;
sigma_BN = (Eigen::Vector3d)*this->inertialAttitudeProperty;
}

Eigen::Matrix3d dcm_BN = (sigma_BN.toRotationMatrix()).transpose();
Eigen::Vector3d r_BN_N = (Eigen::Vector3d)*this->inertialPositionProperty;

// Define the variables related to which body the thruster is attached to. The F frame represents the platform body where the thruster attaches to
Eigen::MRPd sigma_FN;
Expand Down Expand Up @@ -242,6 +253,16 @@ void ThrusterDynamicEffector::linkInStates(DynParamManager& states){
}
}

/*! This method is used to link properties to the thrusters
@return void
@param properties The parameter manager to collect from
*/
void ThrusterDynamicEffector::linkInProperties(DynParamManager& properties){
this->inertialAttitudeProperty = properties.getPropertyReference(this->propName_inertialAttitude);
this->inertialAngVelocityProperty = properties.getPropertyReference(this->propName_inertialAngVelocity);
this->inertialPositionProperty = properties.getPropertyReference(this->propName_inertialPosition);
}

/*! This method computes the Forces on Torque on the Spacecraft Body.

@param integTime Integration time
Expand All @@ -250,7 +271,13 @@ void ThrusterDynamicEffector::linkInStates(DynParamManager& states){
void ThrusterDynamicEffector::computeForceTorque(double integTime, double timeStep)
{
// Save omega_BN_B
Eigen::Vector3d omegaLocal_BN_B = this->hubOmega->getState();
Eigen::Vector3d omegaLocal_BN_B;
if (!this->stateNameOfSigma.empty()) {
omegaLocal_BN_B = this->hubOmega->getState();
}
else {
omegaLocal_BN_B = *this->inertialAngVelocityProperty;
}

// Force and torque variables
Eigen::Vector3d SingleThrusterForce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class ThrusterDynamicEffector: public SysModel, public DynamicEffector {
public:
ThrusterDynamicEffector();
~ThrusterDynamicEffector();
void linkInStates(DynParamManager& states);
void computeForceTorque(double integTime, double timeStep);
void computeStateContribution(double integTime);
void Reset(uint64_t CurrentSimNanos);
void linkInStates(DynParamManager& states) override;
void linkInProperties(DynParamManager& properties) override;
void computeForceTorque(double integTime, double timeStep) override;
void computeStateContribution(double integTime) override;
void Reset(uint64_t CurrentSimNanos) override;
void addThruster(std::shared_ptr<THRSimConfig> newThruster);
void addThruster(std::shared_ptr<THRSimConfig> newThruster, Message<SCStatesMsgPayload>* bodyStateMsg);
void UpdateState(uint64_t CurrentSimNanos);
void UpdateState(uint64_t CurrentSimNanos) override;
void writeOutputMessages(uint64_t CurrentClock);
bool ReadInputs();
void ConfigureThrustRequests(double currentTime);
Expand All @@ -75,6 +76,8 @@ class ThrusterDynamicEffector: public SysModel, public DynamicEffector {
StateData *hubSigma; //!< pointer to the hub attitude states
StateData *hubOmega; //!< pointer to the hub angular velocity states
Eigen::MatrixXd* inertialPositionProperty; //!< [m] r_N inertial position relative to system spice zeroBase/refBase
Eigen::MatrixXd* inertialAttitudeProperty; //!< attitude relative to inertial frame
Eigen::MatrixXd* inertialAngVelocityProperty; //!< [rad/s] inertial angular velocity relative to inertial frame

BSKLogger bskLogger; //!< -- BSK Logging

Expand Down
Loading
Loading