Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -30,6 +30,7 @@
void PrescribedRotation1DOF::SelfInit() {
HingedRigidBodyMsg_C_init(&this->spinningBodyOutMsgC);
PrescribedRotationMsg_C_init(&this->prescribedRotationOutMsgC);
PrescribedTranslationMsg_C_init(&this->prescribedTranslationOutMsgC);
}

/*! This method resets required module variables and checks the input messages to ensure they are linked.
Expand Down Expand Up @@ -663,6 +664,19 @@ void PrescribedRotation1DOF::writeOutputMessages(uint64_t callTime) {
this->prescribedRotationOutMsg.write(&prescribedRotationOut, moduleID, callTime);
HingedRigidBodyMsg_C_write(&spinningBodyOut, &spinningBodyOutMsgC, this->moduleID, callTime);
PrescribedRotationMsg_C_write(&prescribedRotationOut, &prescribedRotationOutMsgC, this->moduleID, callTime);

if (this->c_screw != 0.0) {
// Write the prescribed translation output message if screw motion is configured
PrescribedTranslationMsgPayload prescribedTranslationOut;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write
PrescribedTranslationMsgPayload prescribedTranslationOut = {} to define this variable and have the structure zero'd in one step.

prescribedTranslationOut = PrescribedTranslationMsgPayload();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this line if you implement the above suggestion.

Eigen::Vector3d r_PM_M = (this->rhoInit + this->c_screw * this->theta) * this->rotHat_M;
Eigen::Vector3d rPrime_PM_M = this->c_screw * this->thetaDot * this->rotHat_M;
Eigen::Vector3d rPrimePrime_PM_M = this->c_screw * this->thetaDDot * this->rotHat_M;
eigenVector3d2CArray(r_PM_M, prescribedTranslationOut.r_PM_M);
eigenVector3d2CArray(rPrime_PM_M, prescribedTranslationOut.rPrime_PM_M);
eigenVector3d2CArray(rPrimePrime_PM_M, prescribedTranslationOut.rPrimePrime_PM_M);
this->prescribedTranslationOutMsg.write(&prescribedTranslationOut, moduleID, callTime);
}
}

/*! This method computes the current spinning body MRP attitude relative to the mount frame: sigma_PM
Expand Down Expand Up @@ -768,3 +782,33 @@ double PrescribedRotation1DOF::getThetaDDotMax() const {
double PrescribedRotation1DOF::getThetaInit() const {
return this->thetaInit;
}

/*! Setter method for the initial linear displacement if screw motion is selected.

@param initDisplacement Initial linear displacement
*/
void PrescribedRotation1DOF::setInitDisplacement(const double initDisplacement) {
this->rhoInit = initDisplacement;
}

/*! Setter method for the screw constant for modeling prescribed screw motion.

@param screwConstant Screw slope constant
*/
void PrescribedRotation1DOF::setScrewConstant(const double screwConstant) {
this->c_screw = screwConstant;
}

/*! Getter method for the initial linear displacement if screw motion is selected.
@return double
*/
double PrescribedRotation1DOF::getInitDisplacement() const {
return this->rhoInit;
}

/*! Getter method for the screw constant.
@return double
*/
double PrescribedRotation1DOF::getScrewConstant() const {
return this->c_screw;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "architecture/utilities/bskLogging.h"
#include "cMsgCInterface/HingedRigidBodyMsg_C.h"
#include "cMsgCInterface/PrescribedRotationMsg_C.h"
#include "cMsgCInterface/PrescribedTranslationMsg_C.h"
#include <Eigen/Dense>
#include <cstdint>

Expand All @@ -47,11 +48,19 @@ class PrescribedRotation1DOF: public SysModel{
double getThetaDDotMax() const; //!< Getter for the bang segment scalar angular acceleration
double getThetaInit() const; //!< Getter for the initial spinning body angle

// Method for optional prescribed screw motion
void setInitDisplacement(const double initDisplacement); //!< Setter for the initial linear displacement
void setScrewConstant(const double screwConstant); //!< Setter for the screw motion constant
double getScrewConstant() const; //!< Getter for the screw motion constant
double getInitDisplacement() const; //!< Getter for the initial linear displacement

ReadFunctor<HingedRigidBodyMsgPayload> spinningBodyInMsg; //!< Input msg for the spinning body reference angle and angle rate
Message<HingedRigidBodyMsgPayload> spinningBodyOutMsg; //!< Output msg for the spinning body angle and angle rate
Message<PrescribedRotationMsgPayload> prescribedRotationOutMsg; //!< Output msg for the spinning body prescribed rotational states
Message<PrescribedTranslationMsgPayload> prescribedTranslationOutMsg; //!< Output msg for the prescribed translational states if screw motion is configured
HingedRigidBodyMsg_C spinningBodyOutMsgC = {}; //!< C-wrapped output msg for the spinning body angle and angle rate
PrescribedRotationMsg_C prescribedRotationOutMsgC = {}; //!< C-wrapped output msg for the spinning body prescribed rotational states
PrescribedTranslationMsg_C prescribedTranslationOutMsgC = {}; //!< C-wrapped output msg for the prescribed translational states if screw motion is configured

BSKLogger *bskLogger; //!< BSK Logging

Expand Down Expand Up @@ -85,10 +94,12 @@ class PrescribedRotation1DOF: public SysModel{
Eigen::Vector3d computeSigma_PM(); //!< Method for computing the current spinning body MRP attitude relative to the mount frame: sigma_PM

/* User-configurable variables */
double rhoInit{}; //!< [m] Initial displacement from frame M to frame P along rotHat_M
double coastOptionBangDuration; //!< [s] Time used for the coast option bang segment
double smoothingDuration; //!< [s] Time the acceleration is smoothed to the given maximum acceleration value
double thetaDDotMax; //!< [rad/s^2] Maximum angular acceleration of spinning body used in the bang segments
Eigen::Vector3d rotHat_M; //!< Spinning body rotation axis in M frame components
double c_screw{}; //!< Screw slope constant for modeling prescribed screw motion (1-DOF rotation with coupled translation)

/* Scalar rotational states */
double thetaInit; //!< [rad] Initial spinning body angle from frame M to frame P about rotHat_M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ from Basilisk.architecture.swig_common_model import *
struct HingedRigidBodyMsg_C;
%include "architecture/msgPayloadDefC/PrescribedRotationMsgPayload.h"
struct PrescribedRotationMsg_C;
%include "architecture/msgPayloadDefC/PrescribedTranslationMsgPayload.h"
struct PrescribedTranslationMsg_C;

%pythoncode %{
import sys
Expand Down