Detecting elevation inside range

Hi,
I’m trying to combine two elevation detectors to detect events when the elevation of a spacecraft falls into a certain range [low, high]. E1 is an ElevationDetector with const elevation high, and E2 is an ElevationDetector with const elevation low.
Tried to combine them using andCombine([E2, notCombine(E1)]). Should this work?

BTW, I’m pleased with all the help you have provided in these formus.

Hello @5tardust,

This should Indeed do the trick ! Just be careful with the “maxCheck” setting as your combined detector could miss the event if the range is small.

We are happy to help :+1:

Cheers,
Vincent

Hi there,

Note that combining detectors is not performant in the sense that elevation will be computed twice (might not be a problem for your application). You could create your own detector with g like that:
g = (el - el_min) * (el - el_max)
You can check out in ElevationDetector how the elevation is obtained from the state.

Cheers,
Romain.

2 Likes

Sorry about the delay in my response.

detectors = [ElevationDetector(frame).
                 withConstantElevation(radians(15)),
                 BooleanDetector.notCombine(
                 ElevationDetector(frame).
                 withConstantElevation(radians(40)))]
ba = BooleanDetector.andCombine(detectors).withHandler(gs)

This did not work, the second elevation detector had no effect. However,

ba = Elevation2Detector(frame, (15, 40))

… did, with Elevation2Detector being a custom detector with g() function:

def g(self, state: SpacecraftState):
        el = self._frame.getElevation(state.getPosition(), state.getFrame(),
                                      state.getDate())
        return (el - self._el_minmax[0]) * (self._el_minmax[1] - el)

Update. It seems that my custom detector causes orekit to enter a live-lock. Added some debugging since my program sometimes seemed to hang. I discovered that orekit enters an endless loop of calling the g() function above with various states.

Any inkling about the reason for this?

Thanks.

Hi,

Whare are the settings you pass to the detector ?
I mean threshold, etc.

Cheers,
Romain.

        super().__init__(float(time_step),
                         PythonAbstractDetector.DEFAULT_THRESHOLD,
                         PythonAbstractDetector.DEFAULT_MAX_ITER,
                         handler)

Time step is 10

One twist is that this detector runs in an chain like this:

BooleanDetector.andCombine([Elevation2Detector(...)]).withHandler(ehandler)

This happend regardless if andCombine list only contains the Elevation2Detector or additional detectors.

Is there a potential problem in that I reuse the propagator with different detectors? I.e. using clearEventsDetectors() then addEventDetector()?

Regards,
Nils

It seems that I was wrong in assuming a live lock. Please ignore my last two comments.
Regards

1 Like