Usage of ConfigurableLowThrustManeuver with PositionAngleDetector

Hi everyone,

First, I wish an happy new year to all of you.

I am trying to use the ConfigurableLowThrustManeuver with two PositionAngleDetector: one for the beginning and another for the end of the maneuver. Bellow an example:

initial_state = get_initial_state(date_start)
propagator = get_propagator(initial_state, rso)

isp = 318.0
direction = Vector3D(float(0), float(1), float(0))
thrust = 0.06
thruster_axis = Vector3D(float(0), float(1), float(0))

thrust_direction_provider = ConstantThrustDirectionProvider(direction)
thrust_direction_and_attitude_provider = ThrustDirectionAndAttitudeProvider.buildFromDirectionInLOF(
    LOFType.QSW,
    thrust_direction_provider,
    thruster_axis)
trigger_start = PositionAngleDetector(OrbitType.EQUINOCTIAL, PositionAngle.MEAN, float(np.radians(0.0)))
#trigger_start.init(propagator.getInitialState(), date_end)
trigger_end = PositionAngleDetector(OrbitType.EQUINOCTIAL, PositionAngle.MEAN, float(np.radians(90.0)))
#trigger_end.init(propagator.getInitialState(), date_end)
configurable_low_thrust_maneuver = ConfigurableLowThrustManeuver(thrust_direction_and_attitude_provider,
                                                                 trigger_start,
                                                                 trigger_end,
                                                                 thrust,
                                                                 isp)
propagator.addForceModel(configurable_low_thrust_maneuver)

list_spacecraft_state = propagator.propagate(date_end)

Unfortunately, I encounter the following error message:

---------------------------------------------------------------------------
JavaError                                 Traceback (most recent call last)
<ipython-input-39-8c3ffcccd0ab> in <module>
     23 propagator.addForceModel(configurable_low_thrust_maneuver)
     24 
---> 25 list_spacecraft_state = propagator.propagate(date_end)

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
java.lang.NullPointerException
	at org.orekit.propagation.events.PositionAngleDetector.g(PositionAngleDetector.java:203)
	at org.orekit.forces.maneuvers.trigger.EventBasedManeuverTriggers.isFiringOnInitialState(EventBasedManeuverTriggers.java:152)
	at org.orekit.forces.maneuvers.trigger.EventBasedManeuverTriggers.checkInitialFiringState(EventBasedManeuverTriggers.java:138)
	at org.orekit.forces.maneuvers.trigger.EventBasedManeuverTriggers.init(EventBasedManeuverTriggers.java:126)
	at org.orekit.forces.maneuvers.Maneuver.init(Maneuver.java:131)
	at org.orekit.propagation.numerical.NumericalPropagator$Main.init(NumericalPropagator.java:506)
	at org.orekit.propagation.integration.AbstractIntegratedPropagator$ConvertedMainStateEquations.init(AbstractIntegratedPropagator.java:656)
	at org.hipparchus.ode.ExpandableODE.init(ExpandableODE.java:110)
	at org.hipparchus.ode.AbstractIntegrator.initIntegration(AbstractIntegrator.java:212)
	at org.hipparchus.ode.nonstiff.EmbeddedRungeKuttaIntegrator.integrate(EmbeddedRungeKuttaIntegrator.java:196)
	at org.orekit.propagation.integration.AbstractIntegratedPropagator.integrateDynamics(AbstractIntegratedPropagator.java:416)
	at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:372)
	at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:340)

This error seems to be similar to the one in [Python] Error using ImpulseManeuver with PositionAngleDetector - Orekit usage - Orekit. However, even when I try to init the detector as suggest in the mentioned topic, it does not help.

Could someone help me with this issue?

Kind regards,
Stéfan

Hi @sbaudier

Welcome to the Orekit forum! :slight_smile:

Congratulations! I think you found a bug in Orekit.
The post you highlighted was related to a bug in ImpulseManeuver. You have the same problem but with ConfigurableLowThrustManeuver.

The fix to apply in Orekit is straightforward. In the init method of the EventBasedManeuverTriggers class, the following implementation

/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target) {

    if (!initialized) {

        initialized = true;
        forward     = target.isAfterOrEqualTo(initialState);
        if (!forward && !allowBackwardPropagation) {
            // backward propagation was forbidden
            throw new OrekitException(OrekitMessages.BACKWARD_PROPAGATION_NOT_ALLOWED);
        }

        checkInitialFiringState(initialState);

    } // multiples calls to init : because it is a force model and by each detector
}

must be improved by

/** {@inheritDoc} */
@Override
public void init(final SpacecraftState initialState, final AbsoluteDate target) {

    if (!initialized) {

        initialized = true;
        forward     = target.isAfterOrEqualTo(initialState);
        if (!forward && !allowBackwardPropagation) {
            // backward propagation was forbidden
            throw new OrekitException(OrekitMessages.BACKWARD_PROPAGATION_NOT_ALLOWED);
        }
        startFiringDetector.init(initialState, target);
        stopFiringDetector.init(initialState, target);

        checkInitialFiringState(initialState);

    } // multiples calls to init : because it is a force model and by each detector
}

In other words, the start and stop firing detectors must be initialized.
I reproduced your problem, applied the above fix locally and it works without regression in the Orekit’s tests.
Could you open an issue in our GitLab repository? After that, I will officially fix it and the fix will be available in the next Orekit version.

Best regards,
Bryan

1 Like

Hi @bcazabonne,

Thank you for the answer.

I opened an issue in the Gitlab repository

As I work with python, is there a way for me to correct the issue without waiting for the next Orekit update ?

Kind regards,
Stéfan

Issue is fixed in Orekit. Thank you for reporting it.

Unfortunately, I didn’t find a way to correct the issue without waiting for the next Orekit update. Calling init method of both detectors before initializing the ConfigurableLowThrustManeuver doesn’t solve the issue. The good news is that we will release Orekit 11.1 very soon, probably by the end of the month.

Best regards,
Bryan

1 Like