Add EventDetector to propagator while propagating

Dear community,

in my current setup I wrote a “CustomEventHandler”.
In the “eventOccured” method of it, I insatiate an other Event (ImpulseManeuver) and add it to the propagator, via addEventDetector.
The state, which is passed to “eventOccured” has an epoch prioir to the Event I newly define and add to the propagator within the “eventOccured” method.

Unfortunately, when the propagation is over the Impulse Maneuver I added within the EventHandler is not beeing considered. Aka the maneuver is not conducted!

Is it even possible to edit the “DetectorList” of the propagator while it’s running dynamically?

Short summary of it:
DateDetector with custom “EventHandler” reached during propagation → “eventOccured” adds ImpulseManeuver in the future to the propagator → “ACTION” Continue → Propagation ends (enough days into the future) → Problem: ImpulseManeuver not considered!

Cheers and thanks a lot for the support!

I tried with the “Action.RESET_EVENTS” as a return of “eventOccured”, which sounded exactly what I need, but still it does not work…

  • after the propagation is finished, the propagator does actually have the added event in its List of detectors, however the “gDate” value of this event is NULL, aka it was never evaluated during the propagation. So somehow the propagator does not consider this “on the fly” added event?

How can I fix that?

Cheers!

Hello @afu,

I think of two problems that can lead to such issue.

  • Could you show us a code sample of your CustomEventHandler to see how you implement the ImpulseManeuver during propagation ?
  • What is the trigger event of the added ImpulseManeuver ? Indeed, when adding an ImpulseManeuver during propagation, its init method is not called by the propagator. Hence, its internal trigger is never initialized as well. Depending on the triggering event, this can be an issue.

Another way to debug this would be to see if the internal event detector list is updated properly.

From my understanding of the code, this should be possible.

Cheers,
Vincent

At first, I would have said it is not possible. However, looking at the code (at Hipparchus level, for integration-based propagators), it may be possible, I don’t really know.
There may be a glitch however as the init methods of both the detector and its handler will be called only at integration start, so maybe if the event detector is added after start, the init methods are not called. We should certainly not call init again for the detectors already started, but maybe we should do something if we call addEventDetector while initIntegration has already been called and integrate has not returned yet.

Hi guys,

thanks for the first assessment!

The ImpulseManeuver’s trigger is a DateDetector. Could I just call it’s “init” method manually, or is this not possible?

Here is the implementation (slightly changed in order to make it more obvious):

private static class ImpulsiveReboostEventHandler implements EventHandler
    {
        /**
         * Specific implementation of the eventOccurred interface.
         */
        public ImpulsiveReboostEventHandler(){

        }
        
         @Override
        public Action eventOccurred(final SpacecraftState s, final EventDetector detector, final boolean increasing) {
            final DateDetector manDatetrigger = new DateDetector(AbsoluteDate(2029, 03, 01, 0, 0, 0, utc));
            final ImpulseManeuver maneuver = new ImpulseManeuver(manDatetrigger, new Vector3D(10.0, 0.0, 0.0), 300);
            // add maneuver to timeline
            starlab.propagator.addEventDetector(maneuver);
            return Action.RESET_EVENTS;
        }
    }

The EventHandler “ImpulsiveReboostEventHandler” is added to a previous DateDetector, added to the propagator prior to propgation.

Cheers!