Module: prescribedLinearTranslation
Executive Summary
This module profiles linear translational motion for a rigid body connected to a rigid spacecraft hub. The body frame of
the translating body is designated by the frame \(\mathcal{F}\). The states of the translating body are profiled
relative to a hub-fixed frame \(\mathcal{M}\). The PrescribedTranslationMsgPayload message is used to output
the prescribed translational states from the module. The prescribed states profiled in this module are: r_FM_M
,
rPrime_FM_M
, and rPrimePrime_FM_M
. This module has four options to profile the linear translation.
The first option is a bang-bang acceleration profile that minimizes the time required to complete the translation.
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 translation. 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 hub-relative translational rates of the translating body are zero.
The general inputs to this module that must be set by the user are the translational axis expressed as a
unit vector in mount frame components transHat_M
, the initial translational body position relative to the hub-fixed
mount frame transPosInit
, the reference position relative to the mount frame transPosRef
, and the maximum scalar
linear acceleration for the translation transAccelMax
. 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 translational body’s states are correctly incorporated into the spacecraft dynamics.
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 this message is used for.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
linearTranslationRigidBodyInMsg |
input msg with the prescribed body reference translational states |
|
prescribedTranslationOutMsg |
output message with the prescribed body translational states |
|
prescribedTranslationOutMsgC |
C-wrapped output message with the prescribed body translational states |
Detailed Module Description
Non-Smoothed Bang-Bang Profiler
The first option to profile the linear translation is a pure bang-bang acceleration profile. If the given reference position is greater than the given initial position, the user-specified maximum acceleration value is applied positively to the first half of the translation and negatively to the second half of the translation. However, if the reference position is less than the initial position, the acceleration is instead applied negatively during the first half of the translation and positively during the second half of the translation. As a result of this acceleration profile, the translational body’s hub-relative velocity changes linearly with time and reaches a maximum in magnitude halfway through the translation. Note that the velocity is assumed to both start and end at zero in this module. The resulting translational position profile is parabolic in time.
To profile this motion, the translational body’s hub-relative scalar states \(\rho\), \(\dot{\rho}\), and \(\ddot{\rho}\) are prescribed as a function of time. During the first half of the translation the states are:
where
During the second half of the translation the states are:
where
The switch time \(t_{b1}\) is the simulation time at the end of the first bang segment:
The total time required to complete the translation \(\Delta t_{\text{tot}}\) is:
Non-Smoothed Bang-Coast-Bang Profiler
The second option to profile the linear translation 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
reference position is greater than the given initial position, the maximum acceleration value is applied
positively for the specified ramp time coastOptionBangDuration
to the first segment of the translation and negatively
to the third segment of the translation. The second segment of the translation is the coast period. However, if the
reference position is less than the initial position, the acceleration is instead applied negatively during the first
segment of the translation and positively during the third segment of the translation. As a result of this acceleration
profile, the translational body’s hub-relative velocity 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 velocity returns to zero during the
third segment. The resulting position profiled is parabolic during the first and third segments and linear during the
coast segment.
To profile this linear motion, the scalar translating body’s hub-relative states \(\rho\), \(\dot{\rho}\), and \(\ddot{\rho}\) are prescribed as a function of time. During the first segment of the translation the states are:
where
and \(\rho(t_{b1})\) is the hub-relative position at the end of the first bang segment:
Important
Note the distinction between \(t_{b1}\) and \(t_{\text{bang}}\). \(t_{\text{bang}}\) is the time duration of the acceleration segment and \(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 translational states are:
During the third segment, the translational states are
where
Here \(\rho(t_c)\) is the hub-relative position at the end of the coast segment:
and \(\Delta \rho_{\text{coast}}\) is the distance traveled during the coast segment:
\(t_c\) is the simulation time at the end of the coast segment:
Using the given translation axis transHat_M
, the scalar states are then transformed to the prescribed translational
states r_FM_M
, rPrime_FM_M
, and rPrimePrime_FM_M
. The states are then written to the
PrescribedTranslationMsgPayload module output message.
Smoothed Bang-Bang Profiler
The third option to profile the linear translation 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 translation. Similar to the non-smoothed bang-bang profiler,
this option smooths the acceleration between the given maximum acceleration values.
To profile this motion, the translational body’s hub-relative scalar states \(\rho\), \(\dot{\rho}\), and
\(\ddot{\rho}\) are prescribed as a function of time and the translational 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 position is greater than the given initial position, the
acceleration is smoothed positively to the given maximum acceleration value. If the given reference position is less
than the given initial position, the acceleration is smoothed from zero to the negative maximum acceleration value.
During this phase, the scalar hub-relative states are:
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:
where \(t_{s1}\) is the time at the end of the first smoothing segment:
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:
where \(t_{b1}\) is the time at the end of the first bang segment:
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:
where \(t_{s2}\) is the time at the end of the second smoothing segment:
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:
where \(t_{b2}\) is the time at the end of the second bang segment:
Smoothed Bang-Coast-Bang Profiler
The fourth option to profile the linear translation 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 translation.
To profile this motion, the translational body’s hub-relative scalar states \(\rho\), \(\dot{\rho}\), and
\(\ddot{\rho}\) are prescribed as a function of time and the translational 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 position is greater than the given initial position, the
acceleration is smoothed positively to the given maximum acceleration value. If the given reference position is less
than the given initial position, the acceleration is smoothed from zero to the negative maximum acceleration value.
During this phase, the scalar hub-relative states are:
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:
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:
where \(t_{b1}\) is the time at the end of the first bang segment.
The fourth segment is the coast segment where the translational states are:
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 translational states during this phase are:
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:
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:
where \(t_f\) is the time at the end of the translation:
Module Testing
The unit test for this module ensures that the profiled linear translation for a secondary rigid body relative to the spacecraft hub is properly computed for several different simulation configurations. The unit test profiles two successive translations to ensure the module is correctly configured. The secondary body’s initial scalar translational position relative to the spacecraft hub is varied, along with the two final reference positions and the maximum translational acceleration.
The unit test also tests four different methods of profiling the translation. Two profilers prescribe a pure bang-bang or bang-coast-bang linear acceleration profile for the translation. The bang-bang option results in the fastest possible translation; 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 secondary body hub-relative rates start and end at zero.
To verify the module functionality, the final position at the end of each translation segment is checked to match the specified reference positions. Additionally, for the smoothed profiler options, the numerical derivative of the profiled displacements and velocities is determined across the entire simulation. These numerical derivatives are checked with the module’s acceleration and velocity profiles to ensure the profiled acceleration is correctly integrated in the module to obtain the displacements and velocities.
User Guide
The general inputs to this module that must be set by the user are the translational axis expressed as a
unit vector in mount frame components transHat_M
, the initial translational body position relative to the hub-fixed
mount frame transPosInit
, the reference position relative to the mount frame transPosRef
, and the maximum scalar
linear acceleration for the translation transAccelMax
. 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 setup the prescribed linear translational module in python using Basilisk.
Import the prescribedLinearTranslation class:
from Basilisk.simulation import prescribedLinearTranslation
Create an instantiation of the module:
prescribedLinearTrans = prescribedLinearTranslation.PrescribedLinearTranslation()
Define all of the configuration data associated with the module. For example, to configure the smoothed bang-coast-bang option:
prescribedLinearTrans.ModelTag = "prescribedLinearTranslation" prescribedLinearTrans.setTransHat_M(np.array([0.5, 0.0, 0.5 * np.sqrt(3)])) prescribedLinearTrans.setTransAccelMax(0.01) # [m/s^2] prescribedLinearTrans.setTransPosInit(0.5) # [m] prescribedLinearTrans.setCoastRampDuration(1.0) # [s] prescribedLinearTrans.setSmoothingDuration(1.0) # [s]
Connect a LinearTranslationRigidBodyMsgPayload message for the translating body reference position to the module. For example, the user can create a stand-alone message to specify the reference position:
linearTranslationRigidBodyMessageData = messaging.LinearTranslationRigidBodyMsgPayload() linearTranslationRigidBodyMessageData.rho = 1.0 # [m] linearTranslationRigidBodyMessageData.rhoDot = 0.0 # [m/s] linearTranslationRigidBodyMessage = messaging.LinearTranslationRigidBodyMsg().write(linearTranslationRigidBodyMessageData)
Subscribe the reference message to the prescribedTranslation module input message:
prescribedLinearTrans.linearTranslationRigidBodyInMsg.subscribeTo(linearTranslationRigidBodyMessage)
Add the module to the task list:
unitTestSim.AddModelToTask(unitTaskName, prescribedLinearTrans)
-
class PrescribedLinearTranslation : public SysModel
- #include <prescribedLinearTranslation.h>
Prescribed Linear Translation Profiler Class.
Public Functions
-
PrescribedLinearTranslation() = default
Constructor.
-
~PrescribedLinearTranslation() = default
Destructor.
-
void SelfInit() override
Member function to initialize the C-wrapped output message.
This method self initializes the C-wrapped output message.
- 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 translation and updates the prescribed translational states as a function of time. The prescribed translational states are then written to the output message.
- Parameters:
callTime – [ns] Time the method is called
- Returns:
void
-
void setCoastOptionBangDuration(const double bangDuration)
Setter method for the coast option bang duration.
Setter method for the coast option bang duration.
- Parameters:
coastOptionBangDuration – [s] Bang segment time duration
- 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 setTransAccelMax(const double transAccelMax)
Setter method for the bang segment scalar linear acceleration.
Setter method for the bang segment scalar linear acceleration.
- Parameters:
transAccelMax – [m/s^2] Bang segment linear angular acceleration
- Returns:
void
-
void setTransHat_M(const Eigen::Vector3d &transHat_M)
Setter method for the translating body axis of translation.
Setter method for the translating body axis of translation.
- Parameters:
transHat_M – Translating body axis of translation (unit vector)
- Returns:
void
-
void setTransPosInit(const double transPosInit)
Setter method for the initial translating body hub-relative position.
Setter method for the initial translating body hub-relative position.
- Parameters:
transPosInit – [m] Initial translating body position relative to the hub
- Returns:
void
-
double getCoastOptionBangDuration() const
Getter method for the coast option bang duration.
Getter method for the coast option bang duration.
- Returns:
double
-
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 getTransAccelMax() const
Getter method for the bang segment scalar linear acceleration.
Getter method for the bang segment scalar linear acceleration.
- Returns:
double
-
const Eigen::Vector3d &getTransHat_M() const
Getter method for the translating body axis of translation.
Getter method for the translating body axis of translation.
- Returns:
const Eigen::Vector3d
-
double getTransPosInit() const
Getter method for the initial translating body position.
Getter method for the initial translating body position.
- Returns:
double
Public Members
-
ReadFunctor<LinearTranslationRigidBodyMsgPayload> linearTranslationRigidBodyInMsg
Input msg for the translational reference position and velocity.
-
Message<PrescribedTranslationMsgPayload> prescribedTranslationOutMsg
Output msg for the translational body prescribed states.
-
PrescribedTranslationMsg_C prescribedTranslationOutMsgC = {}
C-wrapped Output msg for the translational body prescribed states.
-
BSKLogger *bskLogger
BSK Logging.
Private Functions
-
void computeTranslationParameters()
Intermediate method to group the calculation of translation parameters into a single method.
This intermediate method groups the calculation of translation 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 translation 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 translation with a non-smoothed bang-coast-bang acceleration profile.
- Returns:
void
-
void computeSmoothedBangBangParameters()
Method for computing the required parameters for the translation with a smoothed bang-bang acceleration profile.
This method computes the required parameters for the translation with a smoothed bang-bang acceleration profile.
- Returns:
void
-
void computeSmoothedBangCoastBangParameters()
Method for computing the required parameters for the smoothed bang-coast-bang option.
This method computes the required parameters for the translation with a smoothed bang-coast-bang acceleration profile.
- Returns:
void
-
void computeCurrentState(double time)
Intermediate method used to group the calculation of the current translational states into a single method.
This intermediate method groups the calculation of the current translational 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 translational states.
This method computes the first bang segment scalar translational states.
- Parameters:
t – [s] Current simulation time
- Returns:
void
-
void computeSecondBangSegment(double time)
Method for computing the second bang segment scalar translational states.
This method computes the second bang segment scalar translational states.
- Parameters:
t – [s] Current simulation time
- Returns:
void
-
void computeFirstSmoothedSegment(double time)
Method for computing the first smoothing segment scalar translational states for the smoothed profiler options.
This method computes the first smoothing segment scalar translational 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 translational states for the smoothed profiler options.
This method computes the second smoothing segment scalar translational 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 translational states for the smoothed profiler options.
This method computes the third smoothing segment scalar translational 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 translational states for the smoothed bang-coast-bang option.
This method computes the fourth smoothing segment scalar translational 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 translational states.
This method computes the coast segment scalar translational states
- Parameters:
t – [s] Current simulation time
- Returns:
void
-
void computeTranslationComplete()
Method for computing the scalar translational states when the translation is complete.
This method computes the scalar translational states when the translation 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
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 transAccelMax
[m/s^2] Maximum acceleration magnitude
-
Eigen::Vector3d transHat_M
Axis along the direction of translation expressed in M frame components.
-
double transPosInit
[m] Initial translational body position from M to F frame origin along transHat_M
-
double transPosRef
[m] Reference translational body position from M to F frame origin along transHat_M
-
double transPos
[m] Current translational body position along transHat_M
-
double transVel
[m] Current translational body velocity along transHat_M
-
double transAccel
[m] Current translational body acceleration along transHat_M
-
double transPos_tb1
[m] Position at the end of the first bang segment
-
double transVel_tb1
[m/s] Velocity at the end of the first bang segment
-
double transPos_tb2
[m] Position at the end of the second bang segment
-
double transVel_tb2
[m/s] Velocity at the end of the second bang segment
-
double transPos_ts1
[m] Position at the end of the first smoothed segment
-
double transVel_ts1
[m/s] Velocity at the end of the first smoothed segment
-
double transPos_ts2
[m] Position at the end of the second smoothed segment
-
double transVel_ts2
[m/s] Velocity at the end of the second smoothed segment
-
double transPos_ts3
[m] Position at the end of the third smoothed segment
-
double transVel_ts3
[m/s] Velocity at the end of the third smoothed segment
-
double transPos_tc
[m] Position at the end of the coast segment
-
double transVel_tc
[m/s] Velocity at the end of the coast segment
-
double tInit
[s] Simulation time at the beginning of the translation
-
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 translation is complete
-
bool convergence
Boolean variable is true when the translation is complete.
-
double a
Parabolic constant for the first half of the bang-bang non-smoothed translation.
-
double b
Parabolic constant for the second half of the bang-bang non-smoothed translation.
-
PrescribedLinearTranslation() = default