scenarioAttitudeGuidance
Overview
Discusses how to use guidance modules to align the spacecraft frame to the orbit or Hill frame. This script sets up a 6-DOF spacecraft which is orbiting the Earth.
The script is found in the folder basilisk/examples
and executed by using:
python3 scenarioAttitudeGuidance.py
The simulation layout is shown in the following illustration. A single simulation process is created which contains both the spacecraft simulation modules, as well as the Flight Software (FSW) algorithm modules.
When the simulation completes 4 plots are shown for the MRP attitude history, the rate
tracking errors, the control torque vector, as well as the projection of the body-frame B
axes
The basic simulation setup is the same as the one used in scenarioAttitudeFeedback. The dynamics simulation is setup using a Module: spacecraft module to which a gravity effector is attached. Note that both the rotational and translational degrees of freedom of the spacecraft hub are turned on here to get a 6-DOF simulation. For more information on how to setup orbit, see scenarioBasicOrbit.
In contrast to the simple inertial pointing guidance example scenarioAttitudeFeedback,
this module also requires the
spacecraft’s position and velocity information. The planet ephemeris message relative to which the Hill pointing
is being achieved by connecting the celBodyInMsg
message.
This is useful, for example, if orbiting the sun, and wanting to point the spacecraft back at the
Earth which is also orbiting the sun.
Note that if the celestial body ephemeris input message is not connected then
a zero message is created which corresponds to the planet having a zero position and velocity vector.
If non-zero ephemeris information is required then the input name must point
to a message of type EphemerisMsgPayload.
In this scenario, however, the spacecraft is to point at the Earth while already orbiting the Earth and the input
message name is set to a dummy message.
Illustration of Simulation Results
show_plots = True, useAltBodyFrame = False
The default scenario shown has the useAltBodyFrame
flag turned off. This means that we seek
to align the body frame B with the Hill reference frame
show_plots = True, useAltBodyFrame = True
Here the control should not align the principal body frame B with R, but rather an alternate,
corrected body frame
attError.sigma_R0R = [0,1,0]
The DCM
- scenarioAttitudeGuidance.plot_attitude_error(timeLineSet, dataSigmaBR)[source]
Plot the attitude result.
- scenarioAttitudeGuidance.plot_control_torque(timeLineSet, dataLr)[source]
Plot the control torque response.
- scenarioAttitudeGuidance.plot_orientation(timeLineSet, dataPos, dataVel, dataSigmaBN)[source]
Plot the spacecraft orientation.
- scenarioAttitudeGuidance.plot_rate_error(timeLineSet, dataOmegaBR)[source]
Plot the body angular velocity tracking error.
- scenarioAttitudeGuidance.run(show_plots, useAltBodyFrame)[source]
The scenarios can be run with the followings setups parameters:
- Parameters:
show_plots (bool) – Determines if the script should display plots
useAltBodyFrame (bool) – Specify if the alternate body frame should be aligned with Hill frame.