[Java] Constant event triggering with LongitudeCrossingDetector

I’m trying to find the periods of a satellite when the satellite is above the coordinates. But when I propagate to a time further than the tle’s date LongitudeCrossingDetector is triggered excessively and single coordinate prediction does not complete

This problem doesn’t happen on python

Here is the relevant code:

    public static OneAxisEllipsoid EARTH;

    @BeforeAll
    static void beforeAll() {
        Utils.setDataRoot();    //load orekit data
        EARTH = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING,
                FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    }

    @Test
    void test(){

        String[] tle = new String[]{
                "Test tle",
                "1 25544U 98067A   22257.49623145  .00008872  00000-0  16209-3 0  9998",
                "2 25544  51.6424 254.1285 0002269 232.3655 233.3422 15.50204391359035"
        };
        ZonedDateTime startDate = ZonedDateTime.parse("2022-09-14T17:51:34.39728Z");
        ZonedDateTime finalDate = ZonedDateTime.parse("2022-09-14T21:54:34.39728Z");

        //when
        getIntervals2(tle, startDate, finalDate, 0, 0, 10, 10);
    }

    private List<Pair<ZonedDateTime, ZonedDateTime>> getIntervals2(
            String[] tle,
            ZonedDateTime startDate, ZonedDateTime finalDate,
            int startLat, int startLon,
            int endLat, int endLon
    ) {
        var orekitTle = new org.orekit.propagation.analytical.tle.TLE(tle[1], tle[2]);
        var attitudeProvider = new NadirPointing(FramesFactory.getTEME(), EARTH);
        var sgp4 = TLEPropagator.selectExtrapolator(orekitTle, attitudeProvider, 466615.0);

        var lonEntryDetector = new LongitudeCrossingDetector(EARTH, FastMath.toRadians(startLon))
                .withHandler((s, detector, increasing) -> {
                    System.out.println(s + " " + increasing);
                    return Action.CONTINUE;
                });
        var lonExitDetector = new LongitudeCrossingDetector(EARTH, FastMath.toRadians(endLon))
                .withHandler((s, detector, increasing) -> {
                    System.out.println(s + " " + increasing);
                    return Action.CONTINUE;
                });
        sgp4.addEventDetector(lonEntryDetector);
        sgp4.addEventDetector(lonExitDetector);

        sgp4.propagate(toAbs(startDate), toAbs(finalDate));
        return null;
    }

    private AbsoluteDate toAbs(ZonedDateTime zdt){
        var utc = TimeScalesFactory.getUTC();
        long millis = zdt.toEpochSecond() * TimeUnit.SECONDS.toMillis(1);
        return new AbsoluteDate(new Date(millis), utc);
    }

Hi @Aytackydln

Welcome to the Orekit forum! :slight_smile:

I don’t know if it will fix your issue but I see one error. I think you initialize the
new LongitudeCrossingDetector(EARTH, endLon) with a longitude in radians. However, Orekit uses SI units. Could you convert the angles in radians? You can use FastMath.toRadians(...) for that.

Regards,
Bryan

Sorry about that, in my original code conversion is already applied. Just fixed and the issue still persists. Also edited my post

Did you try using directly the propagate method of sgp4 propagator?

Instead of

TemporalAmount timeStep = Duration.of(10, ChronoUnit.SECONDS);
        var itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        var utc = TimeScalesFactory.getUTC();
        var date = startDate;
        while (date.isBefore(finalDate)) {
            long millis = date.toEpochSecond() * TimeUnit.SECONDS.toMillis(1);
            var absoluteDate = new AbsoluteDate(new Date(millis), utc);

            var sgp4Pv = sgp4.getPVCoordinates(absoluteDate, itrf);
            sgp4Pv.getPosition();

            date = date.plus(timeStep);
        }

Use

sgp4.propagate(finalDate);

Please note that you can also use EventsLogger class to save all the event detections during propagation and at the end of the propagation, access a lot of useful information for the detected events like the SpacecraftState at detection.

EventsLogger loggerStart = new EventsLogger();
sgp4.addEventDetector(logger.monitorDetector(lonEntryDetector));
... 
sgp4.propagate(finalDate);
List<EventsLogger.LoggedEvent> loggedEvents = logger.getLoggedEvents();
int numberDetection = loggedEvents.size();
PVCoordinates pvFirstDetection = loggedEvents.get(0).getState().getPVCoordinates();

Bryan

Behaviour is same. I’ve edited my code in the post to make it simpler

The point was for a single propagation, crossing event is triggered for each millisecond predicted. Since I can’t predict when it would happen this becomes unusable

The problem is not that the event is detected every millisecond, it is that when there are two longitude detectors, it keeps triggering pairs of events entry/exit at the first event date, and cannot proceed further.
The problem does not appear when only one detector is registered.

I have yet to find the reason of the problem.

Could you open an issue on the forge?