Hello everyone,
I am using the EventEnablingPredicateFilter for the first time to keep values *if the spacecraft is in some state.
If the condition is true during all the propagation, I can handle sucessfully the events.
But in the case the condition is false at start at propagation and then becomes true, the events are at the right date but the increasing value is the opposite.
I wrote a unit test in the EventEnablingPredicateFilterTest class so I can reuse some class field. It demonstrates my problem, :
private class RecordIncreasingsHandler implements EventHandler<AbstractDetector<?>> {
Map<AbsoluteDate, Boolean> records = new TreeMap<>();
@Override
public Action eventOccurred(SpacecraftState s, AbstractDetector<?> detector, boolean increasing) {
records.put(s.getDate(), increasing);
return Action.CONTINUE;
}
public boolean findClosest(AbsoluteDate date) {
return records.get(records.keySet().stream().filter(filteredDate -> FastMath.abs(filteredDate.durationFrom(date)) < 1).findAny().get());
}
}
@Test
public void testSign() {
RecordIncreasingsHandler filteredHandler = new RecordIncreasingsHandler();
AbsoluteDate filterStart = orbit.getDate().shiftedBy(12 * 3600);
AbstractDetector filter = new EventEnablingPredicateFilter(new ElevationDetector(new TopocentricFrame(earth, gp, "test")),
(state, eventDetector, g) -> state.getDate().isAfter(filterStart)).withHandler(filteredHandler);
Propagator propagator = new EcksteinHechlerPropagator(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20,
Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
propagator.addEventDetector(filter);
RecordIncreasingsHandler handler = new RecordIncreasingsHandler();
propagator.addEventDetector(new ElevationDetector(new TopocentricFrame(earth, gp, "test")).withHandler(handler));
propagator.propagate(orbit.getDate(), orbit.getDate().shiftedBy(24 * 3600));
Assert.assertFalse(filteredHandler.records.isEmpty());
Assert.assertTrue(filteredHandler.records.keySet().stream().noneMatch(date -> date.isBefore(filterStart)));
handler.records.keySet()
.stream()
.filter(date -> date.isAfter(filterStart))
.forEach(date -> Assert.assertEquals(date.toString(), handler.records.get(date), filteredHandler.findClosest(date)));
}
With the breakpoint at the last line, you can easily view that all booleans values are opposite.
Am I right ? I might have been misused the class ?
Best regards,
Anne-Laure