.. _scenarioAttitudePointingPy: scenarioAttitudePointingPy ========================== Overview -------- This script showcases how to create a Python Xmera 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 :ref:`scenarioAttitudePointing` where the :ref:`mrpPD` feedback control module is replaced with an equivalent python based BSK MRP PD control module. The script is found in the folder ``xmera/examples`` and executed by using:: python3 scenarioAttitudePointingPy.py As with :ref:`scenarioAttitudePointing`, 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 ``PythonMRPPD``. Note that it has the same setup and update routines as are found with a C/C++ Xmera module. These Python modules behave exactly as other C++/C modules: they respect their given priority and can run before C++/C modules. Similarly to C++ modules, creating an instance of the Python module is done with the code:: pyMRPPD = PythonMRPPD() pyMRPPD.modelTag = "pyMRP_PD" pyMRPPD.K = 3.5 pyMRPPD.P = 30.0 scSim.AddModelToTask(simTaskName, pyMRPPD) 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. .. image:: /_images/Scenarios/scenarioAttitudePointingPy1.svg :align: center .. image:: /_images/Scenarios/scenarioAttitudePointingPy2.svg :align: center