Switch operations based on state? #266
-
I see in the flyby scenario that you can switch between operations by starting and stopping the simulation. Is there a way to switch operations based on state? For example, I'd like to have a despin process that runs until the gyros drop below a certain number, after which the simulation switches into a pointing process. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You can write a Python module that takes in the information you need to make a decision and then change the flight mode accordingly. See |
Beta Was this translation helpful? Give feedback.
-
Here's what I came up with. It feels a little hacky passing modules into another module like this, but it works. class modeSelector(simulationArchTypes.PythonModelClass):
def __init__(self, modelName, modelActive=True, modelPriority=-1, sim=None, task=None):
super(modeSelector, self).__init__(modelName, modelActive, modelPriority)
# Initialize dictionary of dependent modules
self.sim = sim
self.task = task
self.eclipse = False
# Input messages
self.cssConstInMsg = messaging.CSSArraySensorMsgReader()
# self.cssConstConfigInMsg = messaging.CSSConfigMsgReader() TODO: submit issue to modify to include minOutput
def reset(self, currentTime):
return
def updateState(self, currentTime):
# read input messages
CSSMsg = self.cssConstInMsg()
# CSSConfigMsg = self.cssConstConfigInMsg()
# Use CSS to determine whether we are in Eclipse
CSSMsgData = CSSMsg.CosValue
if any([v > 0.1 for v in CSSMsgData]):
self.eclipse = False
else:
self.eclipse = True
# Enable/disable tasks based on state.
if self.eclipse:
self.sim.disableTask(self.task)
else:
self.sim.enableTask(self.task)
return |
Beta Was this translation helpful? Give feedback.
You can write a Python module that takes in the information you need to make a decision and then change the flight mode accordingly. See
scenarioAttitudePointingPy
for details on Python modules. Please note that the way Python modules are integrated is changing. See PR #239, and issues #200 and #209 for details.