constrainedAttitudeManeuver#
Executive Summary#
Module to maneuver a spacecraft subject to hard rotational constraints. This module enables the user to add keep-in and keep-out zones that must not be violated by certain user-specified body-frame directions during the maneuver. See the Detailed Module Description for a better description on how this is achieved. The module produces an Attitude Reference Message containing the reference trajectory that is tracked by the spacecraft.
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 |
---|---|---|
attRefOutMsg |
AttRefMsgPayload |
Output Attitude Reference Message. |
attRefOutMsgC |
AttRefMsgPayload |
C-wrapped Output Attitude Reference Message. |
scStateInMsg |
SCStatesMsgPayload |
Input SC States Message. |
vehicleConfigInMsg |
VehicleConfigMsgPayload |
Input Vehicle Configuration Message. |
keepOutCelBodyInMsg |
SpicePlanetStateMsgPayload |
Input keep-out Planet State Message. |
keepInCelBodyInMsg |
SpicePlanetStateMsgPayload |
Input keep-in Planet State Message. |
Module Assumptions and Limitations#
The module, in its current form, allows to only include one keep-out and one keep-in celestial object(s). Multiple boresights (up to 10) can be specified as either keep-in or keep-out body directions. The keep-out constraint is considered respected when all the keep-out body-fixed boresights are outside of the keep-out zone simultaneously. On the contrary, the keep-in constraint is considered respected when at least one keep-in body-fixed direction is inside the keep-in zone.
At this stage of development, constraint compliance is only guaranteed for the attitude waypoints that are used as a base for the interpolation that yields the attitude
reference trajectory (see Detailed Module Description below). It may happen that portions of the reference trajectory between waypoints still violate the rotational
constraints. Ensuring that this does not happen will be subject of further refinements of this module. For the time being, it is possible to circumvent this problem
changing the grid refinement level N
. This changes the coordinates of the grid points, thus yielding a different reference trajectory for every N
. A small N
results in a coarser grid, which is more likely to yield a trajectory that violates some constraints, but is generally smoother. Viceversa, a higher N
gives a
finer grid where the chance of obtaining a constraint-incompliant grid is reduced. However, the trajectory in this case is less regular due to the fact that the
interpolating curve is forced to pass through a larger number of waypoints. A higher N
is also associated with a higher computational cost.
Detailed Module Description#
A detailed explanation of the method implemented in this module can be found in R. Calaon and H. Schaub, “Constrained Attitude Maneuvering via Modified-Rodrigues-Parameter-Based
Motion Planning Algorithms”. To summarize, this module builds a 3D grid in MRP space, whose density is regulated by the input
parameter N
. Each grid node corresponds to an attitude. An undirected graph is built with all the nodes that are constraint compliant. Two nodes are added to the graph:
startNode
whose coordinates \(\sigma_{BN,S}\) correspond to the attitude of the spacecraft contained in thevehicleConfigInMsg
;goalNode
whose coordinates \(\sigma_{BN,G}\) correspond to the desired target attitude at the end of the maneuver.
Two different cost functions are used by the \(A^*\) algorithm to search a valid path. The first is based on the total cartesian length of the path in MRP space. The second is the effort-based cost function computed integrating the control torque norm over the interpolated trajectory obtained from a path., as explained in R. Calaon and H. Schaub. In both cases, the final reference passed to the Attitude Reference Message consists in the interpolated curve obtained from the optimal path computed by \(A^*\), based on the chosen cost function. Interpolation is performed using the routine in BSpline.
Note that this module does not implement the constant angular rate norm routine described in R. Calaon and H. Schaub. The attitude, rates and accelerations provided to the Attitude Reference Message are those obtained directly from the BSpline interpolation.
User Guide#
The required module configuration is:
CAM = constrainedAttitudeManeuver.ConstrainedAttitudeManeuver(N)
CAM.modelTag = "constrainedAttitudeManeuvering"
CAM.sigma_BN_goal = sigma_BN_G
CAM.omega_BN_B_goal = [0, 0, 0]
CAM.avgOmega = 0.04
CAM.BSplineType = 0
CAM.costFcnType = 0
CAM.appendKeepOutDirection([1,0,0], keepOutFov)
CAM.appendKeepInDirection([0,1,0], keepInFov)
scSim.AddModelToTask(simTaskName, CAM)
The module is configurable with the following parameters:
Parameter |
Description |
---|---|
|
goal MRP attitude set |
|
desired angular rate at goal, in body frame coordinates |
|
average angular rate norm desired for the maneuver |
|
desired type of BSpline: 0 for precise interpolation, 1 for least-squares approximation |
|
desired cost function for the graph search algorithm: 0 for total MRP distance, 1 for effort-based cost. |
Class ConstrainedAttitudeManeuver#
-
class ConstrainedAttitudeManeuver : public SysModel#
waypoint reference module class
Public Functions
-
ConstrainedAttitudeManeuver()#
This is the constructor for the module class. It sets default variable values and initializes the various parts of the model
-
ConstrainedAttitudeManeuver(int N)#
This is the constructor for the module class. It sets default variable values and initializes the various parts of the model
-
void reset(uint64_t currentSimNanos)#
This method is used to reset the module. The input messages are read here, the grid is generated and the graph search is performed.
-
void updateState(uint64_t currentSimNanos)#
This method is the state update. It reads the information from the interpolated trajectory and writes the output message.
- Parameters:
currentSimNanos – The current simulation time for system
- Returns:
void
-
void ReadInputs()#
This method reads the input messages in from the system and sets the appropriate parameters
- Returns:
void
-
void GenerateGrid(Node startNode, Node goalNode)#
This method generates the MRP grid and connects the free neighboring nodes
- Returns:
void
-
void appendKeepOutDirection(double direction[3], double Fov)#
Add keep-out body-frame direction
-
void appendKeepInDirection(double direction[3], double Fov)#
Add keep-in body-frame direction
-
void AStar()#
This method applies standard distance-based A* to find a valid path
- Returns:
void
-
void effortBasedAStar()#
This method applies the effort-based A* to find a valid path
- Returns:
void
-
void backtrack(Node *p)#
This method is used inside A* to track the path from goal to start, order it from start to goal and store in class variable path
- Returns:
void
-
void pathHandle()#
This method takes a path of waypoints and returns an Input structure suitable for BSpline interpolation/approximation
- Returns:
void
-
void spline()#
This method performs the BSpline interpolation/approximation and outputs an Output structure
- Returns:
void
-
void computeTorque(int n, double I[9], double L[3])#
This method computes the torque vector required at time step with index n
- Returns:
void
-
double computeTorqueNorm(int n, double I[9])#
This method computes the torque vector required at time step with index n
- Returns:
void
-
double effortEvaluation()#
This method integrates the control torque norm over maneuver time and returns the cost for the effort-based A*.
- Returns:
void
-
double returnNodeCoord(int key[3], int nodeCoord)#
This method allows to access the coordinates of a Node in NodesMap without swigging the C++ Map. It is designed to be used in the UnitTest primarily.
- Returns:
void
-
bool returnNodeState(int key[3])#
This method allows to access the state of a Node (free or not free) in NodesMap without swigging the C++ Map. It is designed to be used in the UnitTest primarily.
- Returns:
void
-
double returnPathCoord(int index, int nodeCoord)#
This method allows to access the coordinates of path Nodes in without swigging NodesList C++. It is designed to be used in the UnitTest primarily.
- Returns:
void
Public Members
-
int N#
Fineness level of discretization.
-
int BSplineType#
0 for interpolation; 1 for LS approximation
-
int costFcnType#
0 for minimum distance path; 1 for minimum control effort path
-
double sigma_BN_goal[3]#
Initial S/C attitude.
-
double omega_BN_B_goal[3]#
Initial S/C angular rate.
-
double avgOmega#
Average angular rate norm during the maneuver.
-
double keepOutFov#
Field of view of the sensitive instrument.
-
double keepOutBore_B[3]#
Body-frame direction of the boresight of the sensitive instrument.
-
constraintStruct constraints#
Structure containing the constraint directions in inertial coordinates.
-
scBoresightStruct boresights#
Structure containing the instrument boresight directions in body frame coordinates.
-
std::map<int, std::map<int, std::map<int, Node>>> NodesMap#
C++ map from node indices to Node class.
-
int keyS[3]#
Key to Start node in NodesMap.
-
int keyG[3]#
Key to Goal node in NodesMap.
-
NodeList path#
Path of nodes from start to goal.
-
double pathCost#
Cost of the path above, according to the cost function used.
-
InputDataSet Input#
Input structure for the BSpline interpolation/approximation.
-
OutputDataSet Output#
Output structure of the BSpline interpolation/approximation.
-
ReadFunctor<SCStatesMsgPayload> scStateInMsg#
Spacecraft state input message.
-
ReadFunctor<VehicleConfigMsgPayload> vehicleConfigInMsg#
FSW vehicle configuration input message.
-
ReadFunctor<SpicePlanetStateMsgPayload> keepOutCelBodyInMsg#
Celestial body state msg - keep out direction.
-
ReadFunctor<SpicePlanetStateMsgPayload> keepInCelBodyInMsg#
Celestial body state msg - keep in direction.
-
Message<AttRefMsgPayload> attRefOutMsg#
Attitude reference output message.
-
BSKLogger bskLogger#
BSK Logging.
-
ConstrainedAttitudeManeuver()#