Not converging propagation combining EclipseDetector and LongitudeCrossingDetector

Hi community
I want to check if I might have found a bug or just a wrong usage from my side.
I basically want to reproduce validate my Longitude (and Latitude) Crossing event detectors, firstly replicating what shown here: python - Using pyephem to calculate when a satellite crosses a Longitude - Stack Overflow

Running the example actually the SGP4 propagator does not ends calculation (some infinite loop?).
I noticed it happens only when I add also EclipseDetector with LongitudeDetector. Below my code:

long endTimestamp = 1366547952523L;
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, false);
    final OneAxisEllipsoid earthShapeIERS = new OneAxisEllipsoid(
        org.orekit.utils.Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
        org.orekit.utils.Constants.WGS84_EARTH_FLATTENING,
        itrf);
    //Add logger and events
    EventsLogger logger = new EventsLogger();
    EventDetector longDetector = new LongitudeCrossingDetector(earthShapeIERS, FastMath.toRadians(-83.4))
        .withHandler(new ContinueOnEvent<>());
    final EclipseDetector sunEclipseDetector = new EclipseDetector(
        CelestialBodyFactory.getSun(), org.orekit.utils.Constants.SUN_RADIUS,
        earthShapeIERS)
        .withHandler(new ContinueOnEvent<>());

    //TLE propagator from ISS 2013 orbit
    TLE tle = new TLE("1 25544U 98067A   13110.27262069  .00008419  00000-0  14271-3 0  6447",
        "2 25544  51.6474  35.7007 0010356 160.4171 304.1803 15.52381363825715");
    TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle);

    //Add event detectors and propagate
    propagator.addEventDetector(logger.monitorDetector(longDetector));
    propagator.addEventDetector(logger.monitorDetector(sunEclipseDetector));
    propagator.propagate(Time.getAbsoluteDateFromEpochMilli(endTimestamp));

    //Get logged events
    assertFalse(logger.getLoggedEvents().stream()
        .filter(e -> e.getEventDetector() instanceof LongitudeCrossingDetector)
        .toList()
        .isEmpty());

where

public static AbsoluteDate getAbsoluteDateFromTimestamp(long timestamp) {
    LocalDateTime utcDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), UTC_ZONE_ID);
    val year = utcDate.getYear();
    val month = utcDate.getMonthValue();
    val day = utcDate.getDayOfMonth();
    val hour = utcDate.getHour();
    val minute = utcDate.getMinute();
    val second = utcDate.getSecond();
    val millis = utcDate.getNano() / 1e9;
    return new AbsoluteDate(year, month, day, hour, minute, second, TimeScalesFactory.getUTC()).shiftedBy(millis);
}

So the issue is that the propagator does not finish the propagation and I don’t understand why :slight_smile:
Thanks!
Alberto

Just a quick update.
It seems the issue is indeed in LatitudeCrossingDetector.
I did the following permutations (from the previous example):

  • LongitudeCrossingDetector → works
  • LatitudeCrossingDetector → works
  • LongitudeCrossingDetector + EclipseDetector → no converges
  • LatitudeCrossingDetector + EclipseDetector → works
  • LongitudeCrossingDetector + LatitudeCrossingDetector → no converges

So no issue with LatitudeCrossingDetector.
Was is something known that we cannot mix LongitudeCrossingDetector with other detectors?
Or somehow it is linked to my example?

Thanks

Alberto

Hi @alberto-ferrero,

Not to my knowledge. But I may be wrong.

Probably, but still, I think you found a bug. Thank you!
Could you please open an issue on the forge? I think your test case can be used as a JUnit test.

I haven’t run your code yet but my guess is that the event detection falls into an infinite loop.
We had several issues like that (see 684 or 493).
Could you try and print the date and lat/lon type of event in the event handlers of your detectors?

Thanks,
Maxime

Hi Maxime
created issue Infinite loop combining `LongitudeCrossingDetector` and another `EventDetector` (#1207) · Issues · Orekit / Orekit · GitLab.

To print the info requested, I crated this custom handler:

public static class ContinueOnEventAndPrint<T extends EventDetector> implements EventHandler<T> {
    @Override
    public Action eventOccurred(SpacecraftState s, T detector, boolean increasing) {
      GeodeticPoint geo = Constants.earthShapeIERS.transform(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate());
      System.out.println("Date: " + s.getDate().toString() + ", lat: " + FastMath.toDegrees(geo.getLatitude()) + " lng: " + FastMath.toDegrees(geo.getLongitude()));
      return Action.CONTINUE;
    }
  }

Here the output I have (it keeps forever):

Date: 2013-04-20T06:57:32.5233335889327Z, lat: -16.97823367420323 lng: -83.40000000009367
Date: 2013-04-20T06:57:32.5233338498914Z, lat: -16.978233687138246 lng: -83.39999998964318
Date: 2013-04-20T06:57:32.5233348498914Z, lat: -16.978233736705754 lng: -83.39999995001145
Date: 2013-04-20T06:57:32.5233358498914Z, lat: -16.978233786273293 lng: -83.39999991037887
Date: 2013-04-20T06:57:32.5233368498914Z, lat: -16.978233835840733 lng: -83.39999987049805
Date: 2013-04-20T06:57:32.5233378498914Z, lat: -16.978233885408194 lng: -83.39999983086553
Date: 2013-04-20T06:57:32.5233388498914Z, lat: -16.978233934975847 lng: -83.39999979123367
Date: 2013-04-20T06:57:32.5233398498914Z, lat: -16.97823398454325 lng: -83.39999975160119
Date: 2013-04-20T06:57:32.5233408498914Z, lat: -16.978234034110816 lng: -83.3999997117194
Date: 2013-04-20T06:57:32.5233418498914Z, lat: -16.97823408367838 lng: -83.39999967208846
Date: 2013-04-20T06:57:32.5233428498914Z, lat: -16.978234133245778 lng: -83.39999963245597
Date: 2013-04-20T06:57:32.5233438498914Z, lat: -16.97823418281326 lng: -83.39999959282426
Date: 2013-04-20T06:57:32.5233448498914Z, lat: -16.978234232380828 lng: -83.39999955319168
Date: 2013-04-20T06:57:32.5233458498914Z, lat: -16.9782342819483 lng: -83.39999951331082
Date: 2013-04-20T06:57:32.5233468498914Z, lat: -16.978234331515853 lng: -83.39999947367819
Date: 2013-04-20T06:57:32.5233478498914Z, lat: -16.978234381083336 lng: -83.39999943404648
Date: 2013-04-20T06:57:32.5233488498914Z, lat: -16.978234430650797 lng: -83.39999939441397
Date: 2013-04-20T06:57:32.5233498498914Z, lat: -16.978234480218298 lng: -83.39999935453307
Date: 2013-04-20T06:57:32.5233508498914Z, lat: -16.978234529785844 lng: -83.3999993149005
Date: 2013-04-20T06:57:32.5233518498914Z, lat: -16.978234579353263 lng: -83.39999927526883
Date: 2013-04-20T06:57:32.5233528498914Z, lat: -16.97823462892091 lng: -83.39999923563614
Date: 2013-04-20T06:57:32.5233538498914Z, lat: -16.97823467848831 lng: -83.39999919600369
Date: 2013-04-20T06:57:32.5233548498914Z, lat: -16.978234728055803 lng: -83.39999915612363
Date: 2013-04-20T06:57:32.5233558498914Z, lat: -16.97823477762336 lng: -83.39999911649103
Date: 2013-04-20T06:57:32.5233568498914Z, lat: -16.978234827190846 lng: -83.3999990768593
Date: 2013-04-20T06:57:32.5233578498914Z, lat: -16.97823487675833 lng: -83.39999903722678
...

Do we deduce anything?
Thanks
Alberto

Well, at least we are sure there’s an infinite loop in the event detection :wink:

Are these only the longitude crossing events or also the eclipse detection events?
I wanted to know if somehow the detection loop was bouncing from one to another.
My guess is that the eclipse event happens almost exactly at the same time as the longitude crossing event (but I may be wrong).

Unfortunately not, the two events are not at the same time.
Look at following examples:

Adding print for Eclipse or Longitude (I created different Handlers with different print)

Eclipse Date: 2013-04-20T06:35:24.63528500593921Z, lat: 45.18881517720924 lng: -144.05157878508987
Longitude Date: 2013-04-20T06:57:32.5233335889327Z, lat: -16.97823367420323 lng: -83.40000000009367
Longitude Date: 2013-04-20T06:57:32.5233338498914Z, lat: -16.978233687138246 lng: -83.39999998964318
Longitude Date: 2013-04-20T06:57:32.5233348498914Z, lat: -16.978233736705754 lng: -83.39999995001145
Longitude Date: 2013-04-20T06:57:32.5233358498914Z, lat: -16.978233786273293 lng: -83.39999991037887
Longitude Date: 2013-04-20T06:57:32.5233368498914Z, lat: -16.978233835840733 lng: -83.39999987049805
Longitude Date: 2013-04-20T06:57:32.5233378498914Z, lat: -16.978233885408194 lng: -83.39999983086553
Longitude Date: 2013-04-20T06:57:32.5233388498914Z, lat: -16.978233934975847 lng: -83.39999979123367
Longitude Date: 2013-04-20T06:57:32.5233398498914Z, lat: -16.97823398454325 lng: -83.39999975160119
Longitude Date: 2013-04-20T06:57:32.5233408498914Z, lat: -16.978234034110816 lng: -83.3999997117194
Longitude Date: 2013-04-20T06:57:32.5233418498914Z, lat: -16.97823408367838 lng: -83.39999967208846
Longitude Date: 2013-04-20T06:57:32.5233428498914Z, lat: -16.978234133245778 lng: -83.39999963245597
Longitude Date: 2013-04-20T06:57:32.5233438498914Z, lat: -16.97823418281326 lng: -83.39999959282426
Longitude Date: 2013-04-20T06:57:32.5233448498914Z, lat: -16.978234232380828 lng: -83.39999955319168
Longitude Date: 2013-04-20T06:57:32.5233458498914Z, lat: -16.9782342819483 lng: -83.39999951331082
Longitude Date: 2013-04-20T06:57:32.5233468498914Z, lat: -16.978234331515853 lng: -83.39999947367819
Longitude Date: 2013-04-20T06:57:32.5233478498914Z, lat: -16.978234381083336 lng: -83.39999943404648
Longitude Date: 2013-04-20T06:57:32.5233488498914Z, lat: -16.978234430650797 lng: -83.39999939441397
Longitude Date: 2013-04-20T06:57:32.5233498498914Z, lat: -16.978234480218298 lng: -83.39999935453307
Longitude Date: 2013-04-20T06:57:32.5233508498914Z, lat: -16.978234529785844 lng: -83.3999993149005
Longitude Date: 2013-04-20T06:57:32.5233518498914Z, lat: -16.978234579353263 lng: -83.39999927526883
Longitude Date: 2013-04-20T06:57:32.5233528498914Z, lat: -16.97823462892091 lng: -83.39999923563614
Longitude Date: 2013-04-20T06:57:32.5233538498914Z, lat: -16.97823467848831 lng: -83.39999919600369
Longitude Date: 2013-04-20T06:57:32.5233548498914Z, lat: -16.978234728055803 lng: -83.39999915612363

we have only first event as EclipseDetector

Then I try the combo LongitudeCrossingDetector and LatitudeCrossingDetector (at latitude 0.9 deg), adding print for Latitude or Longitude

Latitude Date: 2013-04-20T06:51:39.66063259058257Z, lat: 0.9000007960137376 lng: -96.5137992055762
Longitude Date: 2013-04-20T06:57:32.51036305411367Z, lat: -16.97759075636164 lng: -83.40051476765022
Longitude Date: 2013-04-20T06:57:32.5233338498914Z, lat: -16.978233687138246 lng: -83.39999998964318
Longitude Date: 2013-04-20T06:57:32.54096167533655Z, lat: -16.97910745287498 lng: -83.39930037977766
Longitude Date: 2013-04-20T06:57:32.55858950078169Z, lat: -16.979981215540178 lng: -83.39860076283318
Longitude Date: 2013-04-20T06:57:32.57621732622683Z, lat: -16.980854975133607 lng: -83.39790113880855
Longitude Date: 2013-04-20T06:57:32.59384515167197Z, lat: -16.981728731655085 lng: -83.39720150745663
Longitude Date: 2013-04-20T06:57:32.61147297711712Z, lat: -16.98260248510426 lng: -83.39650186927219
Longitude Date: 2013-04-20T06:57:32.62910080256226Z, lat: -16.983476235481337 lng: -83.3958022240078
Longitude Date: 2013-04-20T06:57:32.6467286280074Z, lat: -16.9843499827858 lng: -83.39510257166236
Longitude Date: 2013-04-20T06:57:32.66435645345254Z, lat: -16.985223727017477 lng: -83.39440291223556
Longitude Date: 2013-04-20T06:57:32.68198427889769Z, lat: -16.98609746817637 lng: -83.39370324572594
Longitude Date: 2013-04-20T06:57:32.69961210434283Z, lat: -16.986971206262112 lng: -83.3930035718865
Longitude Date: 2013-04-20T06:57:32.71723992978797Z, lat: -16.987844941274528 lng: -83.39230389121188
Longitude Date: 2013-04-20T06:57:32.73486775523311Z, lat: -16.988718673213448 lng: -83.39160420345488
Longitude Date: 2013-04-20T06:57:32.75249558067826Z, lat: -16.98959240207881 lng: -83.39090450861418
Longitude Date: 2013-04-20T06:57:32.7701234061234Z, lat: -16.9904661278704 lng: -83.39020480668856
Longitude Date: 2013-04-20T06:57:32.78775123156854Z, lat: -16.991339850587828 lng: -83.38950509767938
Longitude Date: 2013-04-20T06:57:32.80537905701368Z, lat: -16.99221357023101 lng: -83.38880538133695
Longitude Date: 2013-04-20T06:57:32.82300688245883Z, lat: -16.9930872867998 lng: -83.3881056581567
Longitude Date: 2013-04-20T06:57:32.84063470790397Z, lat: -16.99396100029398 lng: -83.38740592789067
Longitude Date: 2013-04-20T06:57:32.85826253334911Z, lat: -16.994834710713437 lng: -83.38670619054002
Longitude Date: 2013-04-20T06:57:32.87589035879425Z, lat: -16.995708418057855 lng: -83.38600644610112
Longitude Date: 2013-04-20T06:57:32.8935181842394Z, lat: -16.99658212232702 lng: -83.38530669457612
Longitude Date: 2013-04-20T06:57:32.91114600968454Z, lat: -16.99745582352086 lng: -83.38460693571437
Longitude Date: 2013-04-20T06:57:32.92877383512968Z, lat: -16.99832952163916 lng: -83.38390717001391
Longitude Date: 2013-04-20T06:57:32.94640166057482Z, lat: -16.999203216681774 lng: -83.38320739722418

Same case, first event for Latitude then loop for Longitude.

Both examples, if I remove the other detector, leaving only LongitudeCrossingDetector, I don’t have issues.

another detail.
I notice that time of LongitudeCross event is increasing (leaving it to run). Is it because IERS Earth rotates and we have longitude that rotates too?

Longitude Date: 2013-04-20T06:57:32.51036305411367Z, lat: -16.97759075636164 lng: -83.40051476765022
Longitude Date: 2013-04-20T06:57:32.5233338498914Z, lat: -16.978233687138246 lng: -83.39999998964318
Longitude Date: 2013-04-20T06:57:32.54096167533655Z, lat: -16.97910745287498 lng: -83.39930037977766
Longitude Date: 2013-04-20T06:57:32.55858950078169Z, lat: -16.979981215540178 lng: -83.39860076283318
Longitude Date: 2013-04-20T06:57:32.57621732622683Z, lat: -16.980854975133607 lng: -83.39790113880855
Longitude Date: 2013-04-20T06:57:32.59384515167197Z, lat: -16.981728731655085 lng: -83.39720150745663
Longitude Date: 2013-04-20T06:57:32.61147297711712Z, lat: -16.98260248510426 lng: -83.39650186927219
Longitude Date: 2013-04-20T06:57:32.62910080256226Z, lat: -16.983476235481337 lng: -83.3958022240078
Longitude Date: 2013-04-20T06:57:32.6467286280074Z, lat: -16.9843499827858 lng: -83.39510257166236
...
Longitude Date: 2013-04-20T07:27:40.62701758361739Z, lat: -31.41797827867901 lng: 46.3148860360357
Longitude Date: 2013-04-20T07:27:40.64464540906253Z, lat: -31.41719398439919 lng: 46.315777664606564
Longitude Date: 2013-04-20T07:27:40.66227323450768Z, lat: -31.416409682737335 lng: 46.316669277183735
Longitude Date: 2013-04-20T07:27:40.67990105995282Z, lat: -31.415625373693814 lng: 46.31756087376539
Longitude Date: 2013-04-20T07:27:40.69752888539796Z, lat: -31.414841057269054 lng: 46.318452454353626
Longitude Date: 2013-04-20T07:27:40.7151567108431Z, lat: -31.414056733463216 lng: 46.31934401894758
Longitude Date: 2013-04-20T07:27:40.73278453628825Z, lat: -31.4132724022768 lng: 46.320235567797816
Longitude Date: 2013-04-20T07:27:40.75041236173339Z, lat: -31.412488063710043 lng: 46.32112710040739
Longitude Date: 2013-04-20T07:27:40.76804018717853Z, lat: -31.411703717763352 lng: 46.32201861702365
Longitude Date: 2013-04-20T07:27:40.78566801262367Z, lat: -31.410919364437135 lng: 46.3229101176503
Longitude Date: 2013-04-20T07:27:40.80329583806882Z, lat: -31.41013500373155 lng: 46.32380160228585
Longitude Date: 2013-04-20T07:27:40.82092366351396Z, lat: -31.409350635646987 lng: 46.324693070931545
Longitude Date: 2013-04-20T07:27:40.83855148895911Z, lat: -31.408566260183854 lng: 46.325584523837094
Longitude Date: 2013-04-20T07:27:40.85617931440424Z, lat: -31.407781877342526 lng: 46.32647596050559
Longitude Date: 2013-04-20T07:27:40.87380713984939Z, lat: -31.406997487123306 lng: 46.32736738118444

Ok, so something else is happening here.

I don’t know but I wouldn’t say that it’s related to IERS (just a guess).
We definitely need to dig into this one, it will probably take some time…

Hi @alberto-ferrero,

I confirm the bug with Orekit 11.3.3 … but it no longer occurs on the development branch, so it will be fixed for Orekit 12.0 :slight_smile:

Thanks!
Waiting for it :slight_smile:
Alberto

For the record, a similar problem was reported in [Java] Constant event triggering with LongitudeCrossingDetector and led to the opening of issue #997, which has since been resolved. This fix is effective in the develop branch and will be present in version 12.0 to come very soon.