@@ -72,11 +72,13 @@ void ThrusterDynamicEffector::Reset(uint64_t CurrentSimNanos)
7272void ThrusterDynamicEffector::writeOutputMessages (uint64_t CurrentClock)
7373{
7474 int idx = 0 ;
75- std::vector<THRSimConfig>::iterator it;
75+ std::vector<std::shared_ptr<THRSimConfig>>::iterator itp;
76+ std::shared_ptr<THRSimConfig> it;
7677
7778 THROutputMsgPayload tmpThruster;
78- for (it = this ->thrusterData .begin (); it != this ->thrusterData .end (); ++it )
79+ for (itp = this ->thrusterData .begin (); itp != this ->thrusterData .end (); ++itp )
7980 {
81+ it = *itp;
8082 tmpThruster = this ->thrusterOutMsgs [idx]->zeroMsgPayload ;
8183 eigenVector3d2CArray (it->thrLoc_B , tmpThruster.thrusterLocation );
8284 eigenVector3d2CArray (it->thrDir_B , tmpThruster.thrusterDirection );
@@ -140,32 +142,32 @@ bool ThrusterDynamicEffector::ReadInputs()
140142 */
141143void ThrusterDynamicEffector::ConfigureThrustRequests (double currentTime)
142144{
143- std::vector<THRSimConfig>::iterator it;
144145 std::vector<double >::iterator CmdIt;
146+ size_t THIter = 0 ;
145147 // Iterate through the list of thruster commands that we read in.
146- for (CmdIt = NewThrustCmds.begin (), it = this ->thrusterData .begin ();
147- it != this ->thrusterData .end (); it++, CmdIt++)
148+ for (CmdIt = NewThrustCmds.begin (); CmdIt != NewThrustCmds.end (); CmdIt++)
148149 {
149- if (*CmdIt >= it ->MinOnTime ) // Check to see if we have met minimum for each thruster
150+ if (*CmdIt >= this -> thrusterData [THIter] ->MinOnTime ) // Check to see if we have met minimum for each thruster
150151 {
151152 // For each case where we are above the minimum firing request, reset the thruster
152- it ->ThrustOps .ThrustOnCmd = *CmdIt;
153- it-> ThrustOps .fireCounter += it ->ThrustOps .ThrustFactor > 0.0
153+ this -> thrusterData [THIter] ->ThrustOps .ThrustOnCmd = *CmdIt;
154+ this -> thrusterData [THIter]-> ThrustOps .fireCounter += this -> thrusterData [THIter] ->ThrustOps .ThrustFactor > 0.0
154155 ? 0 : 1 ;
155156 }
156157 else
157158 {
158159 // Will ensure that thruster shuts down once this cmd expires
159- it-> ThrustOps .ThrustOnCmd = it ->ThrustOps .ThrustFactor > 0.0
160+ this -> thrusterData [THIter]-> ThrustOps .ThrustOnCmd = this -> thrusterData [THIter] ->ThrustOps .ThrustFactor > 0.0
160161 ? *CmdIt : 0.0 ;
161162 }
162- it ->ThrustOps .ThrusterStartTime = currentTime;
163- it ->ThrustOps .PreviousIterTime = currentTime;
164- it ->ThrustOps .ThrustOnRampTime = 0.0 ;
165- it ->ThrustOps .ThrustOnSteadyTime = 0.0 ;
166- it ->ThrustOps .ThrustOffRampTime = 0.0 ;
163+ this -> thrusterData [THIter] ->ThrustOps .ThrusterStartTime = currentTime;
164+ this -> thrusterData [THIter] ->ThrustOps .PreviousIterTime = currentTime;
165+ this -> thrusterData [THIter] ->ThrustOps .ThrustOnRampTime = 0.0 ;
166+ this -> thrusterData [THIter] ->ThrustOps .ThrustOnSteadyTime = 0.0 ;
167+ this -> thrusterData [THIter] ->ThrustOps .ThrustOffRampTime = 0.0 ;
167168 // After we have assigned the firing to the internal thruster, zero the command request.
168169 *CmdIt = 0.0 ;
170+ THIter++;
169171 }
170172
171173}
@@ -233,7 +235,7 @@ void ThrusterDynamicEffector::linkInStates(DynParamManager& states){
233235
234236 for (const auto & thrusterConfig : this ->thrusterData ) {
235237 if (this ->fuelMass < 0.0 &&
236- (!thrusterConfig. thrBlowDownCoeff .empty () || !thrusterConfig. ispBlowDownCoeff .empty ())) {
238+ (!thrusterConfig-> thrBlowDownCoeff .empty () || !thrusterConfig-> ispBlowDownCoeff .empty ())) {
237239 bskLogger.bskLog (BSK_WARNING ," ThrusterDynamicEffector: blow down coefficients have been "
238240 " specified, but no fuel tank is attached." );
239241 }
@@ -274,13 +276,14 @@ void ThrusterDynamicEffector::computeForceTorque(double integTime, double timeSt
274276 axesWeightMatrix << 2 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 ;
275277
276278 // Loop variables
277- std::vector <THRSimConfig>::iterator it;
279+ std::shared_ptr <THRSimConfig> it;
278280 THROperation* ops;
279281
280282 // Iterate through all of the thrusters to aggregate the force/torque in the system
281283 int index;
282- for (it = this -> thrusterData . begin (), index = 0 ; it != this ->thrusterData .end (); it++, index++ )
284+ for (index = 0 ; index < this ->thrusterData .size (); ++ index)
283285 {
286+ it = this ->thrusterData [index];
284287 ops = &it->ThrustOps ;
285288
286289 // Compute the thruster properties wrt the hub (note that B refers to the F frame when extracting from the thruster info)
@@ -289,23 +292,24 @@ void ThrusterDynamicEffector::computeForceTorque(double integTime, double timeSt
289292
290293 // If the connected fuel tank is subject to blow down effects, update them here
291294 if (this ->fuelMass >= 0.0 && (!it->thrBlowDownCoeff .empty () || !it->ispBlowDownCoeff .empty ())) {
292- this ->computeBlowDownDecay (&(*it) );
295+ this ->computeBlowDownDecay (it );
293296 }
294297
295298 // For each thruster see if the on-time is still valid and if so, call ComputeThrusterFire()
296299 if ((ops->ThrustOnCmd + ops->ThrusterStartTime - integTime) >= -dt*10E-10 &&
297300 ops->ThrustOnCmd > 0.0 )
298301 {
299- ComputeThrusterFire (&(*it) , integTime);
302+ ComputeThrusterFire (it , integTime);
300303 }
301304 // If we are not actively firing, continue shutdown process for active thrusters
302305 else if (ops->ThrustFactor > 0.0 )
303306 {
304- ComputeThrusterShut (&(*it) , integTime);
307+ ComputeThrusterShut (it , integTime);
305308 }
306309
307310 // For each thruster, aggregate the current thrust direction into composite body force
308311 tmpThrustMag = it->MaxThrust * ops->ThrustFactor * ops->thrustBlowDownFactor ;
312+
309313 // Apply dispersion to magnitude
310314 tmpThrustMag *= (1 . + it->thrusterMagDisp );
311315 SingleThrusterForce = tmpThrustMag * thrustDirection_B;
@@ -351,9 +355,9 @@ void ThrusterDynamicEffector::computeForceTorque(double integTime, double timeSt
351355
352356 @param newThruster thruster sim config(s)
353357 */
354- void ThrusterDynamicEffector::addThruster (THRSimConfig* newThruster)
358+ void ThrusterDynamicEffector::addThruster (std::shared_ptr< THRSimConfig> newThruster)
355359{
356- this ->thrusterData .push_back (* newThruster);
360+ this ->thrusterData .push_back (newThruster);
357361
358362 // Create corresponding output message
359363 Message<THROutputMsgPayload>* msg;
@@ -377,9 +381,9 @@ void ThrusterDynamicEffector::addThruster(THRSimConfig* newThruster)
377381 @param newThruster thruster sim config(s)
378382 @param bodyStateMsg body states to which thruster(s) are attached
379383 */
380- void ThrusterDynamicEffector::addThruster (THRSimConfig* newThruster, Message<SCStatesMsgPayload>* bodyStateMsg)
384+ void ThrusterDynamicEffector::addThruster (std::shared_ptr< THRSimConfig> newThruster, Message<SCStatesMsgPayload>* bodyStateMsg)
381385{
382- this ->thrusterData .push_back (* newThruster);
386+ this ->thrusterData .push_back (newThruster);
383387
384388 // Create corresponding output message
385389 Message<THROutputMsgPayload>* msg;
@@ -405,7 +409,7 @@ void ThrusterDynamicEffector::addThruster(THRSimConfig* newThruster, Message<SCS
405409* tank subject to blow down effects.
406410
407411 */
408- void ThrusterDynamicEffector::computeBlowDownDecay (THRSimConfig * currentThruster)
412+ void ThrusterDynamicEffector::computeBlowDownDecay (std::shared_ptr< THRSimConfig> currentThruster)
409413{
410414 THROperation *ops = &(currentThruster->ThrustOps );
411415
@@ -435,14 +439,16 @@ void ThrusterDynamicEffector::computeBlowDownDecay(THRSimConfig *currentThruster
435439/* ! This method computes contributions to the fuel mass depletion. */
436440void ThrusterDynamicEffector::computeStateContribution (double integTime){
437441
438- std::vector<THRSimConfig>::iterator it;
442+ std::vector<std::shared_ptr<THRSimConfig>>::iterator itp;
443+ std::shared_ptr<THRSimConfig> it;
439444 THROperation *ops;
440445 double mDotSingle =0.0 ;
441446 this ->mDotTotal = 0.0 ;
442447 this ->stateDerivContribution .setZero ();
443448 // Iterate through all of the thrusters to aggregate the force/torque in the system
444- for (it = this ->thrusterData .begin (); it != this ->thrusterData .end (); it ++)
449+ for (itp = this ->thrusterData .begin (); itp != this ->thrusterData .end (); itp ++)
445450 {
451+ it = *itp;
446452 ops = &it->ThrustOps ;
447453 mDotSingle = 0.0 ;
448454 if (it->steadyIsp * ops->IspFactor * ops->ispBlowDownFactor > 0.0 )
@@ -464,7 +470,7 @@ void ThrusterDynamicEffector::computeStateContribution(double integTime){
464470 @param CurrentThruster Pointer to the configuration data for a given thruster
465471 @param currentTime The current simulation clock time converted to a double
466472 */
467- void ThrusterDynamicEffector::ComputeThrusterFire (THRSimConfig * CurrentThruster,
473+ void ThrusterDynamicEffector::ComputeThrusterFire (std::shared_ptr< THRSimConfig> CurrentThruster,
468474 double currentTime)
469475{
470476 std::vector<THRTimePair>::iterator it;
@@ -523,7 +529,7 @@ void ThrusterDynamicEffector::ComputeThrusterFire(THRSimConfig *CurrentThruster,
523529 @param CurrentThruster Pointer to the configuration data for a given thruster
524530 @param currentTime The current simulation clock time converted to a double
525531 */
526- void ThrusterDynamicEffector::ComputeThrusterShut (THRSimConfig * CurrentThruster,
532+ void ThrusterDynamicEffector::ComputeThrusterShut (std::shared_ptr< THRSimConfig> CurrentThruster,
527533 double currentTime)
528534{
529535 std::vector<THRTimePair>::iterator it;
@@ -576,7 +582,7 @@ void ThrusterDynamicEffector::ComputeThrusterShut(THRSimConfig *CurrentThruster,
576582 @param thrData The data for the thruster that we are currently firing
577583 @param thrRamp This just allows us to avoid switching to figure out which ramp
578584 */
579- double ThrusterDynamicEffector::thrFactorToTime (THRSimConfig * thrData,
585+ double ThrusterDynamicEffector::thrFactorToTime (std::shared_ptr< THRSimConfig> thrData,
580586 std::vector<THRTimePair> *thrRamp)
581587{
582588 std::vector<THRTimePair>::iterator it;
0 commit comments