From dcce1803dbe0ef03bde3734ddb4d8c747572db32 Mon Sep 17 00:00:00 2001 From: Julian Hammerl Date: Mon, 14 Aug 2023 12:30:29 -0600 Subject: [PATCH] Add defaultControlPeriod parameter for first module call --- .../thrFiringRemainder/thrFiringRemainder.c | 7 ++++++- .../thrFiringRemainder/thrFiringRemainder.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.c b/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.c index 7b774f75a7..db550b6c80 100755 --- a/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.c +++ b/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.c @@ -77,6 +77,11 @@ void Reset_thrFiringRemainder(thrFiringRemainderConfig *configData, uint64_t cal configData->pulseRemainder[i] = 0.0; } + /*! - use default value of 2 seconds for control period of first call if not specified. + * Control period (FSW rate) is computed dynamically for any subsequent calls. + */ + configData->defaultControlPeriod = (0.0 == configData->defaultControlPeriod) ? + 2.0 : configData->defaultControlPeriod; } /*! This method maps the input thruster command forces into thruster on times using a remainder tracking logic. @@ -99,7 +104,7 @@ void Update_thrFiringRemainder(thrFiringRemainderConfig *configData, uint64_t ca /*! - The first time update() is called there is no information on the time step. * Pick 2 seconds for the control period */ if(configData->prevCallTime == 0) { - controlPeriod = 2.; + controlPeriod = configData->defaultControlPeriod; } else { /*! - compute control time period Delta_t */ controlPeriod = ((double)(callTime - configData->prevCallTime)) * NANO2SEC; diff --git a/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.h b/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.h index 59638e039d..ad314eacfa 100755 --- a/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.h +++ b/src/fswAlgorithms/effectorInterfaces/thrFiringRemainder/thrFiringRemainder.h @@ -39,6 +39,7 @@ typedef struct { int numThrusters; //!< [-] The number of thrusters available on vehicle double maxThrust[MAX_EFF_CNT]; //!< [N] Max thrust int baseThrustState; //!< [-] Indicates on-pulsing (0) or off-pusling (1) + double defaultControlPeriod; //!< [s] Default control period used for first call uint64_t prevCallTime; //!< callTime from previous function call