.. _BskSim_scenarios_scenario_FeedbackRW: scenario_FeedbackRW =================== .. raw:: html Overview -------- This script sets up a 6-DOF spacecraft orbiting Earth. The goal of the scenario is to #. add reaction wheels to :ref:`BSK_Dynamics`, and #. establish a inertial pointing FSW mode in :ref:`BSK_FSW`. The script is found in the folder ``xmera/examples/BskSim/scenarios`` and executed by using:: python3 scenario_FeedbackRW.py The simulation mimics the basic simulation simulation in the earlier tutorial in :ref:`scenarioAttitudeFeedbackRW`. The simulation layout is shown in the following illustration. .. image:: /_images/static/test_scenario_FeedbackRW.svg :align: center Two simulation processes are created: one which contains dynamics modules, and one that contains the FSW modules. The initial setup for the simulation closely models that of :ref:`scenario_BasicOrbit`. Custom Dynamics Configurations Instructions ------------------------------------------- In addition to the modules used in :ref:`scenario_BasicOrbit`, the user must configure the RW module in :ref:`BSK_Dynamics` to stabilize the tumbling. This is accomplished by first creating the RW state effector. The RW object is then configured through ``InitAllDynObjects(SimBase)`` which includes the ``SetReactionWheelDynEffector()`` function which configures the RW pyramid's properties and messages. Custom FSW Configurations Instructions -------------------------------------- To configure the desired :ref:`inertial3D` FSW mode the user must declare the following modules within the ``__init__()`` function in :ref:`BSK_FSW`. These provide the initial setup for an attitude guidance system that makes use of an inertial pointing model, a module that tracks the error of the spacecraft's MRP parameters against the pointing model, and a module that takes that information to provide a torque to correct for the error. Following the initial declaration of these configuration modules, :ref:`BSK_FSW` calls a ``InitAllFSWObjects()`` command, which, like :ref:`BSK_Dynamics`'s ``InitAllDynObjects()``, calls additional setter functions that configure each of the FSW modules with the appropriate information and message names. In addition to the modules used for attitude guidance, there are also two setter functions that send vehicle and RW configuration messages that are linked into the attitude guidance modules called ``SetVehicleConfiguration()`` and ``SetRWConfigMsg()``. After each configuration module has been properly initialized with various message names, FSW tasks are generated. The two tasks required for the :ref:`inertial3D` mode are ``inertial3DPointTask`` and ``mrpFeedbackRWsTask``. Note how the tasks are divided between the pointing model and control loop. These modular tasks allow for simple FSW reconfigurations should the user want to use a different pointing model, but to use the same feedback control loop. This will be seen and discussed in later scenarios. Because the FSW guidance and control are broken up into separate tasks to be enabled, they must share a common stand-along (gateway) message to connect these tasks. These are setup with the method ``setupGatewayMsgs()``. Note that if a C FSW module re-directs its message writing to such a stand-alone message, when recording the message this stand-alone message should be recorded. The output message payload within the module itself remain zero in such a case. Finally, the :ref:`inertial3D` mode call in :ref:`scenario_FeedbackRW` needs to be triggered by:: SimBase.createNewEvent("initiateInertial3D", self.processTasksTimeStep, True, ["self.modeRequest == 'inertial3D'"], ["self.fswProc.disableTasks()", "self.FSWModels.zeroGateWayMsgs()", "self.enableTask('inertial3DPointTask')", "self.enableTask('mrpFeedbackRWsTask')"]) which disables any existing tasks, zero's all the stand-alone gateway messages and enables the inertial pointing task and RW feedback task. This concludes how to construct a preconfigured FSW mode that will be available for any future scenario that uses the BSK_Sim architecture. This simulation runs for 10 minutes and then switches the FSW mode to ``directInertial3D``. The difference here is that the requested command torque from the ``mrpFeedback`` module in this mode is directly sent to the spacecraft object as an external torque. Also, not that while in ``inertial3D`` mode the ``mrpFeedback`` module receives the RW speeds to feed-forward compensate for them, in the ``directInertial3D`` mode this is not the case. Illustration of Simulation Results ---------------------------------- :: showPlots = True .. image:: /_images/Scenarios/scenario_FeedbackRW_attitudeErrorNorm.svg :align: center .. image:: /_images/Scenarios/scenario_FeedbackRW_rwMotorTorque.svg :align: center .. image:: /_images/Scenarios/scenario_FeedbackRW_rateError.svg :align: center .. image:: /_images/Scenarios/scenario_FeedbackRW_rwSpeed.svg :align: center