Module: prescribedRotation1DOF

Executive Summary

This module profiles a 1 DOF rotation for a spinning rigid body connected to a rigid spacecraft hub. The body frame of the spinning body is designated by the frame \(\mathcal{F}\). The spinning body’s states are profiled relative to a hub-fixed frame \(\mathcal{M}\). The PrescribedRotationMsgPayload message is used to output the prescribed rotational states from the module. The prescribed states profiled in this module are: omega_FM_F, omegaPrime_FM_F, and sigma_FM. This module has four options to profile the spinning body rotation. The first option is a bang-bang acceleration profile that minimizes the time required for the rotation. The second option is a bang-coast-bang acceleration profile that adds a coast period of zero acceleration between the acceleration ramp segments. The third option is a smoothed bang-bang acceleration profile that uses cubic splines to construct a continuous acceleration profile across the entire rotation. The fourth option is a smoothed bang-coast-bang acceleration profile.

The module defaults to the non-smoothed bang-bang option with no coast period. If the coast option is desired, the user must set the module variable coastOptionBangDuration to a nonzero value. If smoothing is desired, the module variable smoothingDuration must be set to a nonzero value.

Important

Note that this module assumes the initial and final spinning body hub-relative angular rates are zero.

The general inputs to this module that must be set by the user are the spinning body rotation axis expressed as a unit vector in mount frame components rotHat_M, the initial spinning body angle relative to the hub-fixed mount frame thetaInit, the reference angle relative to the mount frame thetaRef, and the maximum scalar angular acceleration for the rotation thetaDDotMax. The optional inputs coastOptionBangDuration and smoothingDuration can be set by the user to select the specific type of profiler that is desired. If these variables are not set by the user, the module defaults to the non-smoothed bang-bang profiler. If only the variable coastOptionBangDuration is set to a nonzero value, the bang-coast-bang profiler is selected. If only the variable smoothingDuration is set to a nonzero value, the smoothed bang-bang profiler is selected. If both variables are set to nonzero values, the smoothed bang-coast-bang profiler is selected.

Important

To use this module for prescribed motion, it must be connected to the Module: prescribedMotionStateEffector dynamics module. This ensures the spinning body’s states are correctly incorporated into the spacecraft dynamics. See the example script scenarioDeployingSolarArrays for more information about how to set up hub-relative multi-body prescribed motion using the state effector module together with this profiler module.

Message Connection Descriptions

The following table lists all the module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what the message is used for.

Module I/O Messages

Msg Variable Name

Msg Type

Description

spinningBodyInMsg

HingedRigidBodyMsgPayload

input msg with the spinning body reference states

spinningBodyOutMsg

HingedRigidBodyMsgPayload

output message with the scalar spinning body states

spinningBodyOutMsgC

HingedRigidBodyMsgPayload

C-wrapoped output message with the scalar spinning body states

prescribedRotationOutMsg

PrescribedRotationMsgPayload

output message with the prescribed spinning body rotational states

prescribedRotationOutMsgC

PrescribedRotationMsgPayload

C-wrapped output message with the prescribed spinning body rotational states

Detailed Module Description

Non-Smoothed Bang-Bang Profiler

The first option to profile the spinning body rotation is a pure bang-bang acceleration profile. If the spinning body reference angle is greater than the given initial angle, the user-specified maximum angular acceleration value is applied positively to the first half of the rotation and negatively to the second half of the rotation. However, if the reference angle is less than the initial spinning body angle, the acceleration is instead applied negatively during the first half of the rotation and positively during the second half of the rotation. As a result of this acceleration profile, the spinning body’s angle rate changes linearly with time and reaches a maximum in magnitude halfway through the rotation. Note that the angle rate is assumed to both start and end at zero in this module. The resulting spinning body hub-relative angle for the rotation is parabolic in time.

To profile this spinning body motion, the spinning body’s hub-relative scalar states \(\theta\), \(\dot{\theta}\), and \(\ddot{\theta}\) are prescribed as a function of time. During the first half of the rotation the states are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \ddot{\theta} (t - t_0) + \dot{\theta}_0\]
\[\theta(t) = a (t - t_0)^2 + \theta_0\]

where

\[a = \frac{ \theta_{\text{ref}} - \theta_0}{2 (t_{b1} - t_0)^2}\]

During the second half of the rotation the states are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \ddot{\theta} (t - t_f) + \dot{\theta}_0\]
\[\theta(t) = b (t - t_f)^2 + \theta_{\text{ref}}\]

where

\[b = - \frac{ \theta_{\text{ref}} - \theta_0}{2 (t_{b1} - t_f)^2}\]

The switch time \(t_{b1}\) is the simulation time at the end of the first bang segment:

\[t_{b1} = t_0 + \frac{\Delta t_{\text{tot}}}{2}\]

The total time required to complete the rotation \(\Delta t_{\text{tot}}\) is:

\[\Delta t_{\text{tot}} = 2 \sqrt{ \frac{| \theta_{\text{ref}} - \theta_0 | }{\ddot{\theta}_{\text{max}}}} = t_f - t_0\]

Non-Smoothed Bang-Coast-Bang Profiler

The second option to profile the spinning body rotation is a bang-coast-bang acceleration profile with an added coast period between the acceleration segments where the acceleration is zero. Similar to the previous profiler, if the spinning body reference angle is greater than the given initial angle, the maximum angular acceleration value is applied positively for the specified ramp time coastOptionBangDuration to the first segment of the rotation and negatively to the third segment of the rotation. The second segment of the rotation is the coast period. However, if the reference angle is less than the initial spinning body angle, the acceleration is instead applied negatively during the first segment of the rotation and positively during the third segment of the rotation. As a result of this acceleration profile, the spinning body’s hub-relative angle rate changes linearly with time and reaches a maximum in magnitude at the end of the first segment and is constant during the coast segment. The angle rate returns to zero during the third segment. The resulting spinning body angle for the rotation is parabolic during the first and third segments and linear during the coast segment.

To profile this spinning body motion, the spinning body’s hub-relative scalar states \(\theta\), \(\dot{\theta}\), and \(\ddot{\theta}\) are prescribed as a function of time. During the first segment of the rotation the states are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \ddot{\theta} (t - t_0) + \dot{\theta}_0\]
\[\theta(t) = a (t - t_0)^2 + \theta_0\]

where

\[a = \frac{ \theta(t_{b1}) - \theta_0}{2 (t_{b1} - t_0)^2}\]

and \(\theta(t_{b1})\) is the spinning body angle at the end of the first bang segment:

\[\theta(t_{b1}) = \pm \frac{1}{2} \ddot{\theta}_{\text{max}} t_{\text{bang}}^2 + \dot{\theta}_0 t_{\text{bang}} + \theta_0\]

Important

Note the distinction between \(t_{b1}\) and \(t_{\text{bang}}\). \(t_{\text{bang}}\) is the time duration of the acceleration segment configured by the user as the module variable coastOptionBangDuration. \(t_{b1}\) is the simulation time at the end of the first acceleration segment. \(t_{b1} = t_0 + t_{\text{bang}}\)

During the coast segment, the rotation states are:

\[\ddot{\theta}(t) = 0\]
\[\dot{\theta}(t) = \dot{\theta}(t_{b1}) = \ddot{\theta}_{\text{max}} t_{\text{bang}} + \dot{\theta}_0\]
\[\theta(t) = \dot{\theta}(t_{b1}) (t - t_{b1}) + \theta(t_{b1})\]

During the third segment, the rotation states are

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \ddot{\theta} (t - t_f) + \dot{\theta}_0\]
\[\theta(t) = b (t - t_f)^2 + \theta_{\text{ref}}\]

where

\[b = - \frac{ \theta_{\text{ref}} - \theta(t_c) }{(t_c - t_f)^2}\]

Here \(\theta(t_c)\) is the spinning body angle at the end of the coast segment:

\[\theta(t_c) = \theta(t_{b1}) + \Delta \theta_{\text{coast}}\]

and \(\Delta \theta_{\text{coast}}\) is the angle traveled during the coast segment:

\[\Delta \theta_{\text{coast}} = (\theta_{\text{ref}} - \theta_0) - 2 (\theta(t_{b1}) - \theta_0)\]

\(t_c\) is the simulation time at the end of the coast segment:

\[t_c = t_{b1} + \frac{\Delta \theta_{\text{coast}}}{\dot{\theta}(t_{b1})}\]

Using the given rotation axis rotHat_M, the scalar states are then transformed to the spinning body rotational states omega_FM_F, omegaPrime_FM_F, and sigma_FM. The states are then written to the PrescribedRotationMsgPayload module output message.

Smoothed Bang-Bang Profiler

The third option to profile the rotation is a smoothed bang-bang acceleration profile. This option is selected by setting the module variable smoothingDuration to a nonzero value. This profiler uses cubic splines to construct a continuous acceleration profiler across the entire rotation. Similar to the non-smoothed bang-bang profiler, this option smooths the acceleration between the given maximum acceleration values. To profile this motion, the spinning body’s hub-relative scalar states \(\theta\), \(\dot{\theta}\), and \(\ddot{\theta}\) are prescribed as a function of time and the rotational motion is split into five different segments.

The first segment smooths the acceleration from zero to the user-specified maximum acceleration value in the given time smoothingDuration. If the given reference angle is greater than the given initial angle, the acceleration is smoothed positively to the given maximum acceleration value. If the given reference angle is less than the given initial angle, the acceleration is smoothed from zero to the negative maximum acceleration value. During this phase, the scalar hub-relative states are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{3 (t - t_0)^2}{t_{\text{smooth}}^2} - \frac{2 (t - t_0)^3}{t_{\text{smooth}}^3} \right)\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_0)^3}{t_{\text{smooth}}^2} - \frac{(t - t_0)^4}{2 t_{\text{smooth}}^3} \right)\]
\[\theta(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_0)^4}{4 t_{\text{smooth}}^2} - \frac{(t - t_0)^5}{10 t_{\text{smooth}}^3} \right) + \theta_0\]

The second segment is the first bang segment where the maximum acceleration value is applied either positively or negatively as discussed previously. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} (t - t_{s1}) + \dot{\theta}(t_{s1})\]
\[\theta(t) = \pm \frac{\ddot{\theta}_{\text{max}} (t - t_{s1})^2}{2} + \dot{\theta}(t_{s1})(t - t_{s1}) + \theta(t_{s1})\]

where \(t_{s1}\) is the time at the end of the first smoothing segment:

\[t_{s1} = t_0 + t_{\text{smooth}}\]

The third segment smooths the acceleration from the current maximum acceleration value to the opposite magnitude maximum acceleration value. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( 1 - \frac{3 (t - t_{b1})^2}{2 t_{\text{smooth}}^2} + \frac{(t - t_{b1})^3}{2 t_{\text{smooth}}^3} \right)\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( (t - t_{b1}) - \frac{(t - t_{b1})^3}{2 t_{\text{smooth}}^2} + \frac{(t - t_{b1})^4}{8 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_{b1})\]
\[\theta(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_{b1})^2}{2} - \frac{(t - t_{b1})^4}{8 t_{\text{smooth}}^2} + \frac{(t - t_{b1})^5}{40 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_{b1})(t - t_{b1}) + \theta(t_{b1})\]

where \(t_{b1}\) is the time at the end of the first bang segment:

\[t_{b1} = t_{s1} + t_{\text{bang}}\]

The fourth segment is the second bang segment where the maximum acceleration value is applied either positively or negatively as discussed previously. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} (t - t_{s2}) + \dot{\theta}(t_{s2})\]
\[\theta(t) = \mp \frac{\ddot{\theta}_{\text{max}} (t - t_{s2})^2}{2} + \dot{\theta}(t_{s2})(t - t_{s2}) + \theta(t_{s2})\]

where \(t_{s2}\) is the time at the end of the second smoothing segment:

\[t_{s2} = t_{b1} + t_{\text{smooth}}\]

The fifth segment is the third and final smoothing segment where the acceleration returns to zero. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} \left ( -1 + \frac{3(t - t_{b2})^2}{t_{\text{smooth}}^2} - \frac{2 (t - t_{b2})^3}{t_{\text{smooth}}^3} \right )\]
\[\dot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} \left ( -(t - t_{b2}) + \frac{(t - t_{b2})^3}{t_{\text{smooth}}^2} - \frac{(t - t_{b2})^4}{2 t_{\text{smooth}}^3} \right ) + \dot{\theta}(t_{b2})\]
\[\theta(t) = \mp \ddot{\theta}_{\text{max}} \left ( \frac{(t - t_{b2})^2}{2} + \frac{(t - t_{b2})^4}{4 t_{\text{smooth}}^2} - \frac{(t - t_{b2})^5}{10 t_{\text{smooth}}^3} \right ) + \dot{\theta}(t_{b2})(t - t_{b2}) + \theta(t_{b2})\]

where \(t_{b2}\) is the time at the end of the second bang segment:

\[t_{b2} = t_{s2} + t_{\text{bang}}\]

Smoothed Bang-Coast-Bang Profiler

The fourth option to profile the rotation is a smoothed bang-coast-bang acceleration profile. This option is selected by setting the module variables coastOptionBangDuration and smoothingDuration to nonzero values. This profiler uses cubic splines to construct a continuous acceleration profiler across the entire rotation. To profile this motion, the spinning body’s hub-relative scalar states \(\theta\), \(\dot{\theta}\), and \(\ddot{\theta}\) are prescribed as a function of time and the rotational motion is split into seven different segments.

The first segment smooths the acceleration from zero to the user-specified maximum acceleration value in the given time smoothingDuration. If the given reference angle is greater than the given initial angle, the acceleration is smoothed positively to the given maximum acceleration value. If the given reference angle is less than the given initial angle, the acceleration is smoothed from zero to the negative maximum acceleration value. During this phase, the scalar hub-relative states are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{3 (t - t_0)^2}{t_{\text{smooth}}^2} - \frac{2 (t - t_0)^3}{t_{\text{smooth}}^3} \right)\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_0)^3}{t_{\text{smooth}}^2} - \frac{(t - t_0)^4}{2 t_{\text{smooth}}^3} \right)\]
\[\theta(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_0)^4}{4 t_{\text{smooth}}^2} - \frac{(t - t_0)^5}{10 t_{\text{smooth}}^3} \right) + \theta_0\]

The second segment is the first bang segment where the maximum acceleration value is applied either positively or negatively as discussed previously. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} (t - t_{s1}) + \dot{\theta}(t_{s1})\]
\[\theta(t) = \pm \frac{\ddot{\theta}_{\text{max}} (t - t_{s1})^2}{2} + \dot{\theta}(t_{s1})(t - t_{s1}) + \theta(t_{s1})\]

where \(t_{s1}\) is the time at the end of the first smoothing segment.

The third segment prior to the coast phase smooths the acceleration from the current maximum acceleration value to zero. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( 1 - \frac{3 (t - t_{b1})^2}{t_{\text{smooth}}^2} - \frac{2 (t - t_{b1})^3}{t_{\text{smooth}}^3} \right)\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left( (t - t_{b1}) - \frac{(t - t_{b1})^3}{t_{\text{smooth}}^2} - \frac{(t - t_{b1})^4}{2 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_{b1})\]
\[\theta(t) = \pm \ddot{\theta}_{\text{max}} \left( \frac{(t - t_{b1})^2}{2} - \frac{(t - t_{b1})^4}{4 t_{\text{smooth}}^2} - \frac{(t - t_{b1})^5}{10 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_{b1})(t - t_{b1}) + \theta(t_{b1})\]

where \(t_{b1}\) is the time at the end of the first bang segment.

The fourth segment is the coast segment where the rotational states are:

\[\ddot{\theta}(t) = 0\]
\[\dot{\theta}(t) = \dot{\theta}(t_{s2})\]
\[\theta(t) = \dot{\theta}(t_{s2}) (t - t_{s2}) + \theta(t_{s2})\]

where \(t_{s2}\) is the time at the end of the second smoothing segment.

The fifth segment smooths the acceleration from zero to the maximum acceleration value prior to the second bang segment. The rotational states during this phase are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} \left( \frac{3 (t - t_c)^2}{t_{\text{smooth}}^2} - \frac{2 (t - t_c)^3}{t_{\text{smooth}}^3} \right)\]
\[\dot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} \left( \frac{(t - t_c)^3}{t_{\text{smooth}}^2} - \frac{(t - t_c)^4}{2 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_c)\]
\[\theta(t) = \mp \ddot{\theta}_{\text{max}} \left( \frac{(t - t_c)^4}{4 t_{\text{smooth}}^2} - \frac{(t - t_c)^5}{10 t_{\text{smooth}}^3} \right) + \dot{\theta}(t_c) (t - t_c) + \theta(t_c)\]

where \(t_c\) is the time at the end of the coast segment.

The sixth segment is the second bang segment where the maximum acceleration value is applied either positively or negatively as discussed previously. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}}\]
\[\dot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} (t - t_{s3}) + \dot{\theta}(t_{s3})\]
\[\theta(t) = \mp \frac{\ddot{\theta}_{\text{max}} (t - t_{s3})^2}{2} + \dot{\theta}(t_{s3})(t - t_{s3}) + \theta(t_{s3})\]

where \(t_{s3}\) is the time at the end of the third smoothing segment.

The seventh segment is the fourth and final smoothing segment where the acceleration returns to zero. The scalar hub-relative states during this phase are:

\[\ddot{\theta}(t) = \mp \ddot{\theta}_{\text{max}} \left (\frac{3(t_f - t)^2}{t_{\text{smooth}}^2} - \frac{2 (t_f - t)^3}{t_{\text{smooth}}^3} \right )\]
\[\dot{\theta}(t) = \pm \ddot{\theta}_{\text{max}} \left (\frac{(t_f - t)^3}{t_{\text{smooth}}^2} - \frac{(t_f - t)^4}{2 t_{\text{smooth}}^3} \right )\]
\[\theta(t) = \mp \ddot{\theta}_{\text{max}} \left (\frac{(t_f - t)^4}{4 t_{\text{smooth}}^2} - \frac{(t_f - t)^5}{10 t_{\text{smooth}}^3} \right ) + \theta_{\text{ref}}\]

where \(t_f\) is the time at the end of the rotation:

Module Testing

The unit test for this module ensures that the profiled 1 DOF rotation for a secondary rigid body relative to the spacecraft hub is properly computed for several different simulation configurations. The unit test profiles two successive rotations to ensure the module is correctly configured. The initial spinning body angle relative to the spacecraft hub is varied, along with the two final reference angles and the maximum angular acceleration for the rotation.

The unit test also tests four different methods of profiling the rotation. Two profilers prescribe a pure bang-bang or bang-coast-bang angular acceleration profile for the rotation. The bang-bang option results in the fastest possible rotation; while the bang-coast-bang option includes a coast period with zero acceleration between the acceleration segments. The other two profilers apply smoothing to the bang-bang and bang-coast-bang acceleration profiles so that the spinning body hub-relative rates start and end at zero.

To verify the module functionality, the final angle at the end of each rotation is checked to match the specified reference angle. Additionally, for the smoothed profiler options, the numerical derivative of the profiled angles and their rates is determined across the entire simulation. These numerical derivatives are checked with the module’s acceleration and rate profiles to ensure the profiled acceleration is correctly integrated in the module to obtain the angles and their rates.

User Guide

The general inputs to this module that must be set by the user are the spinning body rotation axis expressed as a unit vector in mount frame components rotHat_M, the initial spinning body angle relative to the hub-fixed mount frame thetaInit, the reference angle relative to the mount frame thetaRef, and the maximum scalar angular acceleration for the rotation thetaDDotMax. The optional inputs coastOptionBangDuration and smoothingDuration can be set by the user to select the specific type of profiler that is desired. If these variables are not set by the user, the module defaults to the non-smoothed bang-bang profiler. If only the variable coastOptionBangDuration is set to a nonzero value, the bang-coast-bang profiler is selected. If only the variable smoothingDuration is set to a nonzero value, the smoothed bang-bang profiler is selected. If both variables are set to nonzero values, the smoothed bang-coast-bang profiler is selected.

This section is to outline the steps needed to set up the prescribed rotational 1 DOF module in python using Basilisk.

  1. Import the prescribedRotation1DOF class:

    from Basilisk.simulation import prescribedRotation1DOF
    
  2. Create an instantiation of the module:

    prescribedRot1DOF = prescribedRotation1DOF.PrescribedRotation1DOF()
    
  3. Define all of the configuration data associated with the module. For example, to configure the smoothed bang-coast-bang option:

    prescribedRot1DOF.ModelTag = "prescribedRotation1DOF"
    prescribedRot1DOF.setRotHat_M(np.array([0.0, 1.0, 0.0]))
    prescribedRot1DOF.setThetaDDotMax(macros.D2R * 1.0)  # [rad/s^2]
    prescribedRot1DOF.setThetaInit(macros.D2R * 10.0)  # [rad]
    prescribedRot1DOF.setCoastOptionBangDuration(3.0)  # [s]
    prescribedRot1DOF.setSmoothingDuration(1.0)  # [s]
    
  4. Connect a HingedRigidBodyMsgPayload message for the spinning body reference angle to the module. For example, the user can create a stand-alone message to specify the reference angle:

    hingedRigidBodyMessageData = messaging.HingedRigidBodyMsgPayload()
    hingedRigidBodyMessageData.theta = macros.D2R * 90.0  # [rad]
    hingedRigidBodyMessageData.thetaDot = 0.0  # [rad/s]
    hingedRigidBodyMessage = messaging.HingedRigidBodyMsg().write(hingedRigidBodyMessageData)
    
  5. Subscribe the spinning body reference message to the prescribedRotation1DOF module input message:

    prescribedRot1DOF.spinningBodyInMsg.subscribeTo(hingedRigidBodyMessage)
    
  6. Add the module to the task list:

    unitTestSim.AddModelToTask(unitTaskName, prescribedRot1DOF)
    

class PrescribedRotation1DOF : public SysModel
#include <prescribedRotation1DOF.h>

Prescribed 1 DOF Rotation Profiler Class.

Public Functions

PrescribedRotation1DOF() = default

Constructor.

~PrescribedRotation1DOF() = default

Destructor.

void SelfInit() override

Member function to initialize the C-wrapped output message.

This method self initializes the C-wrapped output messages.

Returns

void

void Reset(uint64_t CurrentSimNanos) override

Reset member function.

This method resets required module variables and checks the input messages to ensure they are linked.

Parameters

callTime – [ns] Time the method is called

Returns

void

void UpdateState(uint64_t CurrentSimNanos) override

Update member function.

This method profiles the spinning body rotation and updates the prescribed rotational states as a function of time. The spinning body rotational states are then written to the output message.

Parameters

callTime – [ns] Time the method is called

Returns

void

void setCoastOptionBangDuration(const double bangDuration)

Setter for the coast option bang duration.

Setter method for the coast option bang duration.

Parameters

bangDuration – [s] Bang segment time duration

Returns

void

void setRotHat_M(const Eigen::Vector3d &rotHat_M)

Setter for the spinning body rotation axis.

Setter method for the spinning body rotation axis.

Parameters

rotHat_M – Spinning body rotation axis (unit vector)

Returns

void

void setSmoothingDuration(const double smoothingDuration)

Setter method for the duration the acceleration is smoothed until reaching the given maximum acceleration value.

Setter method for the duration the acceleration is smoothed until reaching the given maximum acceleration value.

Parameters

smoothingDuration – [s] Duration the acceleration is smoothed until reaching the given maximum acceleration value

Returns

void

void setThetaDDotMax(const double thetaDDotMax)

Setter for the bang segment scalar angular acceleration.

Setter method for the bang segment scalar angular acceleration.

Parameters

thetaDDotMax – [rad/s^2] Bang segment scalar angular acceleration

Returns

void

void setThetaInit(const double thetaInit)

Setter for the initial spinning body angle.

Setter method for the initial spinning body angle.

Parameters

thetaInit – [rad] Initial spinning body angle

Returns

void

double getCoastOptionBangDuration() const

Getter for the coast option bang duration.

Getter method for the coast option bang duration.

Returns

double

const Eigen::Vector3d &getRotHat_M() const

Getter for the spinning body rotation axis.

Getter method for the spinning body rotation axis.

Returns

const Eigen::Vector3d

double getSmoothingDuration() const

Getter method for the duration the acceleration is smoothed until reaching the given maximum acceleration value.

Getter method for the duration the acceleration is smoothed until reaching the given maximum acceleration value.

Returns

double

double getThetaDDotMax() const

Getter for the bang segment scalar angular acceleration.

Getter method for the ramp segment scalar angular acceleration.

Returns

double

double getThetaInit() const

Getter for the initial spinning body angle.

Getter method for the initial spinning body angle.

Returns

double

Public Members

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.

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.

BSKLogger *bskLogger

BSK Logging.

Private Functions

void computeRotationParameters()

Intermediate method to group the calculation of rotation parameters into a single method.

This intermediate method groups the calculation of rotation parameters into a single method.

Returns

void

void computeBangBangParametersNoSmoothing()

Method for computing the required parameters for the non-smoothed bang-bang profiler option.

This method computes the required parameters for the rotation with a non-smoothed bang-bang acceleration profile.

Returns

void

void computeBangCoastBangParametersNoSmoothing()

Method for computing the required parameters for the non-smoothed bang-coast-bang profiler option.

This method computes the required parameters for the rotation with a non-smoothed bang-coast-bang acceleration profile.

Returns

void

void computeSmoothedBangBangParameters()

Method for computing the required parameters for the smoothed bang-bang profiler option.

This method computes the required parameters for the rotation with a smoothed bang-bang acceleration profile.

Returns

void

void computeSmoothedBangCoastBangParameters()

Method for computing the required parameters for the smoothed bang-coast-bang profiler option.

This method computes the required parameters for the rotation with a smoothed bang-coast-bang acceleration profile.

Returns

void

void computeCurrentState(double time)

Intermediate method used to group the calculation of the current rotational states into a single method.

This intermediate method groups the calculation of the current rotational states into a single method.

Returns

void

bool isInFirstBangSegment(double time) const

Method for determining if the current time is within the first bang segment.

This method determines if the current time is within the first bang segment.

Parameters

t – [s] Current simulation time

Returns

bool

bool isInSecondBangSegment(double time) const

Method for determining if the current time is within the second bang segment.

This method determines if the current time is within the second bang segment.

Parameters

t – [s] Current simulation time

Returns

bool

bool isInFirstSmoothedSegment(double time) const

Method for determining if the current time is within the first smoothing segment for the smoothed profiler options.

This method determines if the current time is within the first smoothing segment for the smoothed profiler options.

Parameters

t – [s] Current simulation time

Returns

bool

bool isInSecondSmoothedSegment(double time) const

Method for determining if the current time is within the second smoothing segment for the smoothed profiler options.

This method determines if the current time is within the second smoothing segment for the smoothed profiler options..

Parameters

t – [s] Current simulation time

Returns

bool

bool isInThirdSmoothedSegment(double time) const

Method for determining if the current time is within the third smoothing segment for the smoothed profiler options.

This method determines if the current time is within the third smoothing segment for the smoothed profiler options.

Parameters

t – [s] Current simulation time

Returns

bool

bool isInFourthSmoothedSegment(double time) const

Method for determining if the current time is within the fourth smoothing segment for the smoothed bang-coast-bang option.

This method determines if the current time is within the fourth smoothing segment for the smoothed bang-coast-bang option.

Parameters

t – [s] Current simulation time

Returns

bool

bool isInCoastSegment(double time) const

Method for determining if the current time is within the coast segment.

This method determines if the current time is within the coast segment.

Parameters

t – [s] Current simulation time

Returns

bool

void computeFirstBangSegment(double time)

Method for computing the first bang segment scalar rotational states.

This method computes the scalar rotational states for the first bang segment.

Parameters

t – [s] Current simulation time

Returns

void

void computeSecondBangSegment(double time)

Method for computing the second bang segment scalar rotational states.

This method computes the scalar rotational states for the second bang segment.

Parameters

t – [s] Current simulation time

Returns

void

void computeFirstSmoothedSegment(double time)

Method for computing the first smoothing segment scalar rotational states for the smoothed profiler options.

This method computes the first smoothing segment scalar rotational states for the smoothed profiler options.

Parameters

t – [s] Current simulation time

Returns

void

void computeSecondSmoothedSegment(double time)

Method for computing the second smoothing segment scalar rotational states for the smoothed profiler options.

This method computes the second smoothing segment scalar rotational states for the smoothed profiler options.

Parameters

t – [s] Current simulation time

Returns

void

void computeThirdSmoothedSegment(double time)

Method for computing the third smoothing segment scalar rotational states for the smoothed profiler options.

This method computes the third smoothing segment scalar rotational states for the smoothed profiler options.

Parameters

t – [s] Current simulation time

Returns

void

void computeFourthSmoothedSegment(double time)

Method for computing the fourth smoothing segment scalar rotational states for the smoothed bang-coast-bang option.

This method computes the fourth smoothing segment scalar rotational states for the smoothed bang-coast-bang option.

Parameters

t – [s] Current simulation time

Returns

void

void computeCoastSegment(double time)

Method for computing the coast segment scalar rotational states.

This method computes the coast segment scalar rotational states

Parameters

t – [s] Current simulation time

Returns

void

void computeRotationComplete()

Method for computing the scalar rotational states when the rotation is complete.

This method computes the scalar rotational states when the rotation is complete.

Returns

void

void writeOutputMessages(uint64_t CurrentSimNanos)

Method for writing the module output messages and computing the output message data.

This method writes the module output messages and computes the output message data.

Returns

void

Eigen::Vector3d computeSigma_FM()

Method for computing the current spinning body MRP attitude relative to the mount frame: sigma_FM.

This method computes the current spinning body MRP attitude relative to the mount frame: sigma_FM

Returns

void

Private Members

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 thetaInit

[rad] Initial spinning body angle from frame M to frame F about rotHat_M

double thetaRef

[rad] Spinning body reference angle from frame M to frame F about rotHat_M

double theta

[rad] Current angle

double thetaDot

[rad/s] Current angle rate

double thetaDDot

[rad/s^2] Current angular acceleration

double theta_tb1

[rad] Angle at the end of the first bang segment

double thetaDot_tb1

[rad/s] Angle rate at the end of the first bang segment

double theta_tb2

[rad] Angle at the end of the second bang segment

double thetaDot_tb2

[rad/s] Angle rate at the end of the second bang segment

double theta_ts1

[rad] Angle at the end of the first smoothed segment

double thetaDot_ts1

[rad/s] Angle rate at the end of the first smoothed segment

double theta_ts2

[rad] Angle at the end of the second smoothed segment

double thetaDot_ts2

[rad/s] Angle rate at the end of the second smoothed segment

double theta_ts3

[rad] Angle at the end of the third smoothed segment

double thetaDot_ts3

[rad/s] Angle rate at the end of the third smoothed segment

double theta_tc

[rad] Angle at the end of the coast segment

double thetaDot_tc

[rad/s] Angle rate at the end of the coast segment

double tInit

[s] Simulation time at the beginning of the rotation

double t_b1

[s] Simulation time at the end of the first bang segment

double t_b2

[s] Simulation time at the end of the second bang segment

double t_s1

[s] Simulation time at the end of the first smoothed segment

double t_s2

[s] Simulation time at the end of the second smoothed segment

double t_s3

[s] Simulation time at the end of the third smoothed segment

double t_c

[s] Simulation time at the end of the coast segment

double t_f

[s] Simulation time when the rotation is complete

bool convergence

Boolean variable is true when the rotation is complete.

double a

Parabolic constant for the first half of the bang-bang non-smoothed rotation.

double b

Parabolic constant for the second half of the bang-bang non-smoothed rotation.