STK's
Astrogator capability has an autosequence feature that enables you to create dynamic missions.
Autosequences are Mission Control Sequence (MCS) elements that are structurally similar to Sequence segments but are not technically MCS segments. Rather, you can assign autosequences to Propagate and Maneuver segments, and they will function as subroutines by executing in response to specified stopping conditions of those segments.
One typical use of this feature is the performance of station-keeping maneuvering. In a perfect, circular world the spacecraft would remain in its exact same orbit forever. However, it experiences perturbations, such as those from the Sun and Moon’s gravitational forces, that cause its trajectory to veer off course.
It is important to understand the spacecraft's behavior in orbit if you want to make corrections. However, you have to first know what is causing it to change. In the example below, a satellite propagates for 300 days with different force models. The first model only includes the Earth's gravity. The second model adds in perturbations from the Moon's gravity. Finally, the third model adds the Sun's gravity perturbation to the others. Below are the graphs of the inclination using the three respective propagators:



The satellite in a perfect circular world (first graph) retains the same inclination the whole time, but as soon as it experiences third-body perturbations (second and third graphs), it starts to oscillate. There are other perturbing forces to consider, but in an orbit far away from the atmosphere, it is easier to isolate and analyze the effects of the third-body perturbations.
Station-keeping can become very complicated very quickly. A good practice is to separate the individual elements you want to restore before mixing them together. In other words, you should test the targeted maneuvers on a few different satellites separately instead of doing them all at once. The remainder of the article continues with the above example to tighten the range of inclination using autosequences.
In the MCS segments shown below, the satellite propagates to the ascending node and then performs an impulsive burn in the normal (Velocity-Normal-Co-normal Y axis) direction to achieve the targeted inclination at the end of the maneuver.


After determining that the targeter converges, add in a propagate segment after the initial state to go for about 10 days, and then put it all into a sequence. Change the repeat count to 4 and run the MCS. This will help you understand how the corrections are applied overtime.


Graphing the inclination of the satellite shows how the satellite behaves prior to and after the corrections are applied. It is important to see how the satellite behaves before creating the autosequence, because you will need to know what the best way is to trigger the autosequence. As shown in the graph, the inclination tends to decrease over time.
Now you can construct the autosequence. Delete the first propagate segment that goes for a duration of time. Copy the entire sequence by selecting the segment and then clicking the copy icon (

) at the top of the MCS. Open the Automatic Sequence Browser at the top of the MCS.

Click New to make a new Autosequence. Paste the Autosequence in by clicking the paste (

) at the top.

This will be triggered by a stopping condition in a propagate segment. The logic is that it will propagate for a user-set duration of time, and every time the inclination reaches a less-than-desirable value, it will call the autosequence.
Add in a propagate segment as well as a STOP before the sequence. Add in a stopping condition to the propagate segment for inclination. Do this by adding the UserSelect stopping condition and changing the calculation object.



Since the trend was a decrease in inclination, set the trip value to be 44.9. Change Sequence to the one that was just created.


Set the duration stopping condition to 50 days and run the MCS.

Here you can see the correction made when the satellite reached 44.9. Extend the duration to see how it behaves for a longer period of time. Change the duration stopping condition to 90 days and run the MCS.

As shown, the first correction is made, but then the inclination doesn't quite reach 44.9, so you need to tighten the inclination stopping condition. Change the trip value to 44.95 and run the MCS.

This fix helped, but after a while it starts to increase instead of decrease as the oscillation range was tightened from the station-keeping.
This sequential process of creating autosequences is the best practice of implementing them into your MCS. If you were to then look at the eccentricity and the altitude of your satellite as well, you would undoubtedly see the effects of the perturbations. To correct and maintain the rest of your desired elements, you should go through this process of ensuring the individual sequence works before coupling the elements in an autosequence.