Inequality constraints in a DC

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.

Tags: ,

4 Responses to “Inequality constraints in a DC”

  1. YJ MOON says:

    Hello. I’m a big fan of this site.
    I’ve learned a lot of things. I really appreciate it.

    I’m gonna ask you something. How can I use MATLAB inline function?

    I wanted to stop propagating when the condition (-10 deg <flight path angle <0 deg) is met. So I tried like this.

    ret=0; fpa=Lunar_Flight_Path_Angle; if fpa0 ret=fpa; end;

    This works in MATLAB command window but doesn’t work in Astrogator.

  2. Matt Berry says:

    Matlab inline functions can only contain a single statement (see the help for “inline” in Matlab). The multi-statement inline function we use here only works for the JScript inline calc object.

    Since Matlab has a lot of additional overhead, it’s not a good choice for you anyway. You really only want to use Matlab when you are using some built-in Matlab capability. For your problem you can use JScript, which has a similar syntax as Matlab, and it will work fine and also be faster.

  3. YJ MOON says:

    Thank you for your answer.
    Then what about VBScript?
    I tried the code you showed but I counldn’t get it. What should I do to use VBScript?

    Actually I only have Maltab, Perl and VBScript options.

    And I have one more quesion.
    I want to change the thickness of trajectory lines in 3D Graphics.
    What should I do?

  4. Matt Berry says:

    VBScript doesn’t support multi-statement inlines either. Actually the reason we added JScript as an option was to be able to do multi-statement inlines. None of the other languages support them. We added JScript inline calc objects in STK 8.1. If you don’t have them you must have an older version so you’ll need to upgrade.

    You can change line thickness under 2D Graphics, Attributes.

Leave a Reply