I was trying to create a “custom” ConstantThrustManeuver class and just copied and pasted what I found on GitHub but it seems like two methods are not working and I don’t understand why… I just downloaded Orekit 10.1 and Hipparchus 1.6 and I’m taking the source code from here…
Would any one be able to tell me if I’m picking the wrong version of the class?
It does not seem to like how the handler is written…
The two classes are:
/** {@inheritDoc} */
@Override
public <T extends RealFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(final Field<T> field) {
// in forward propagation direction, firing must be enabled
// at start time and disabled at end time; in backward
// propagation direction, firing must be enabled
// at end time and disabled at start time
final FieldDateDetector<T> startDetector = new FieldDateDetector<>(new FieldAbsoluteDate<>(field, startDate)).
withHandler((FieldSpacecraftState<T> state, FieldDateDetector<T> d, boolean increasing) -> {
triggeredStart = state.getDate().toAbsoluteDate();
return Action.RESET_DERIVATIVES;
});
final FieldDateDetector<T> endDetector = new FieldDateDetector<>(new FieldAbsoluteDate<>(field, endDate)).
withHandler((FieldSpacecraftState<T> state, FieldDateDetector<T> d, boolean increasing) -> {
triggeredEnd = state.getDate().toAbsoluteDate();
return Action.RESET_DERIVATIVES;
});
return Stream.of(startDetector, endDetector);
}
/** {@inheritDoc} */
@Override
public Stream<EventDetector> getEventsDetectors() {
// in forward propagation direction, firing must be enabled
// at start time and disabled at end time; in backward
// propagation direction, firing must be enabled
// at end time and disabled at start time
final DateDetector startDetector = new DateDetector(startDate).
withHandler((SpacecraftState state, DateDetector d, boolean increasing) -> {
triggeredStart = state.getDate();
return Action.RESET_DERIVATIVES;
});
final DateDetector endDetector = new DateDetector(endDate).
withHandler((SpacecraftState state, DateDetector d, boolean increasing) -> {
triggeredEnd = state.getDate();
return Action.RESET_DERIVATIVES;
});
return Stream.of(startDetector, endDetector);
}
I’m receiving the following error when trying to run my application:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "SpacecraftState", ( expected after this token
state cannot be resolved to a variable
DateDetector cannot be resolved to a variable
Syntax error on token "d", delete this token
Syntax error on token "boolean", delete this token
increasing cannot be resolved to a variable
Syntax error on tokens, ( expected instead
state cannot be resolved
Syntax error, insert ")" to complete Expression
Syntax error, insert ")" to complete Expression
Syntax error, insert ")" to complete VariableInitializer
Type mismatch: cannot convert from Action to Stream<EventDetector>
Syntax error on tokens, delete these tokens
Syntax error on token "SpacecraftState", ( expected after this token
state cannot be resolved to a variable
DateDetector cannot be resolved to a variable
Syntax error on token "d", delete this token
Syntax error on token "boolean", delete this token
increasing cannot be resolved to a variable
Syntax error on tokens, ( expected instead
state cannot be resolved
Syntax error, insert ")" to complete Expression
Syntax error, insert ")" to complete Expression
Syntax error, insert ")" to complete VariableInitializer
Type mismatch: cannot convert from Action to Stream<EventDetector>
Syntax error on tokens, delete these tokens
Type mismatch: cannot convert from Stream<DateDetector> to Stream<EventDetector>
at environment.CustomConstantThrustManeuver.getEventsDetectors(CustomConstantThrustManeuver.java:456)
at org.orekit.propagation.numerical.NumericalPropagator$Main.<init>(NumericalPropagator.java:491)
at org.orekit.propagation.numerical.NumericalPropagator.getMainStateEquations(NumericalPropagator.java:467)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.createODE(AbstractIntegratedPropagator.java:535)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:457)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:414)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:397)
Yes I’ve checked that but no missing bracket. I’ve even tried adding pieces by pieces to make sure each bracket had its counterpart.
When just entering this line in the getFieldEventsDetectors method:
final FieldDateDetector<T> startDetector = new FieldDateDetector<>(new FieldAbsoluteDate<>(field, startDate)).withHandler((FieldSpacecraftState<T> state, FieldDateDetector<T> d, boolean increasing)->{triggeredStart = state.getDate().toAbsoluteDate();return Action.RESET_DERIVATIVES;});
It logs errors on what is contained in withHandler() asking me to create local variables (errors on state, T, d, increasing), to change the return type of the method to Action (error on Action), and unexpected token errors (even though they’re all here).
I downloaded the orekit-10.1.jar file from the link you provided and linked it in a new project in Eclipse-2019-03, wrote a small test… and everything works fine.
I can’t tell where your compilation error is coming from. Which IDE are you using ?
I don’t know if it comes from there but you could definitely try upgrading Java to the latest OpenJDK 8 and Eclipse (I suggest 2019-03 for Eclipse, the latest version was buggy on my machine).
As a guess, the IDE from 2013 doesn’t probably have support for JDK8 which was released in 2014 and has many new not backward compatible features like lambdas, default methods etc.
Try newer versions of Eclipse or another (more modern) Java IDE - IntelliJ IDEA which is de-facto a “standard” IDE nowadays with support from big companies like Google (similar to how Eclipse was such an IDE 10 years ago).