Someone doing a HEO station-keeping mission called in the other day. He has constraints on argument of periapse (aop) he has to stay between during the mission. During the course of the mission he passes through critical inclination, which changes which way aop drifts. So, he wants to do an inclination-change maneuver when he passes through critical inclination, so that at the end of the mission he's still in bounds.
He set up a stopping condition at critical inclination, and had it call an autosequence with a target sequence. The target sequence contains a maneuver, followed by a propagate to the end of life. He wants the targeter to control the maneuver so the end of life aop is at the bound.
His question was how to avoid doing the maneuver at all if the end of life aop is within bounds already. The differential corrector only knows about equality constraints, so it wants the aop to be exactly on the bound. The DC doesn't care that you really have two bounds and want to set up an inequality constraint problem. (Though an optimizer, like the one in STK 9, can do that). So, we need to be a little tricky and give the DC something that does what we want, but behaves in a way the DC understands.
Inline calc objects to the rescue.
Inline calc objects are a somewhat unknown, but very powerful capability within Astrogator. You can write a script that takes some calc object values and does some math on them, and returns that answer back to the differential corrector. For instance you can use it to subtract the value of two different calc objects. In the case here, we want something that will return zero if argument of periapse is within bounds, and returns the difference between aop and the nearest bound if aop is outside of the bounds. This way, we can have the DC make this calc object go to zero, and it won't do anything at all if we are already within bounds. If we start outside of bounds, the DC will drive you to the nearest bound.
To set it up, go to the scripts folder on the results panel, and bring over the JScript calc object. Add argument of periapse as an available CalcArgument to the JScript calc object. Change the UnitDimension to AngleUnit, so the value will be reported as an angle. For the inline func, we want this code:
var ret = 0.0; var aop = Argument_of_Periapsis; if (aop < 0.523599) ret = aop - 0.523599; if (aop > 0.610865) ret = 0.610865 - aop; ret
In the script you'll be using internal units (radians here for angles, and distances would be meters, time would be in seconds). I'm using 35 degrees for the upper bound, and 30 degrees for the lower. The GUI only lets you input one line, but the semicolons let you do more than one statement on the line. The last statement of the script is what the calc object will be equal to, in this case the value of ret: 0.0 if you are in bounds, and the distance to the nearest bound if you are outside the bounds.
If you add this calc object as a result to a segment, you can use it in a DC and set the desired value to zero. If the final value is already within bounds, the DC will already be within tolerance so it won't do any work. If you start outside of bounds, it will try to make that calc object go to zero, which will push you to the closest bound.
One disclaimer: what we've done here is create a variable with a discontinuity, and differential correctors don't like discontinuities. It's smooth on either side of the bound, so as long as you stay on one side or the other during targeting, you'll be ok. If you keep the perturbation and max step for the control (the delta-V of the maneuver) small, the DC should be happy.