scenarioAttitudePointingNumba
Overview
This script showcases how to create a Numba Basilisk module.
Demonstrates how to stabilize the attitude tumble without translational motion. This script sets up a 6-DOF spacecraft, but without specifying any orbital motion. Thus, this scenario simulates the spacecraft translating in deep space. The scenario is a version of scenarioAttitudePointingPy where the Python MRP PD control module is replaced with an equivalent Making Numba Modules-based implementation.
The script is found in the folder basilisk/examples and executed by using:
python3 scenarioAttitudePointingNumba.py
As with scenarioAttitudePointingPy, when the simulation completes 3 plots are shown for the MRP attitude history, the rate tracking errors, as well as the control torque vector.
The MRP PD control module in this script is a class called NumbaMRPPD. It subclasses
NumbaModel and implements the entire control law inside UpdateStateImpl, which is
JIT-compiled by Numba to native code. Gains K and P are stored in the persistent
memory namespace and can be configured before InitializeSimulation is called:
numMRPPD = NumbaMRPPD()
numMRPPD.ModelTag = "numMRP_PD"
numMRPPD.memory.K = 3.5 # [N m]
numMRPPD.memory.P = 30.0 # [N m s/rad]
numMRPPD.guidInMsg.subscribeTo(attError.attGuidOutMsg)
scSim.AddModelToTask(simTaskName, numMRPPD)
Illustration of Simulation Results
show_plots = True
Here a small initial tumble is simulated. The resulting attitude and control torque histories are shown below. The spacecraft quickly regains a stable orientation without tumbling past 180 degrees.
- class scenarioAttitudePointingNumba.NumbaMRPPD(*args, **kwargs)[source]
Bases:
NumbaModelMRP PD attitude controller implemented as a NumbaModel.
The control law is:
L_r = -(K * sigma_BR + P * omega_BR_B)
Gains
KandPare stored in the persistentmemorynamespace so they are accessible inside the JIT-compiledUpdateStateImpl.