Facing problem while creating "handlers" using "OrekitStepHandler and OrekitFixedStepHandler"

I have been trying to create a step handler in Python by inheriting from the two Java interfaces OrekitStepHandler and OrekitFixedStepHandler.

Here is the code snippet:

class FakeStepHandler(OrekitStepHandler):
    def __init__(self):
        super().__init__()

handler = FakeStepHandler()
propagator.getMultiplexer().add(handler)

System throws error:

NotImplementedError: (‘instantiating java class’, <class ‘main.FakeStepHandler’>)

I was able to compile by replacing the super().__init__() with pass. However, this will result in handler value as <null> and the propagator throws

JavaError: <super: <class ‘JavaError’>, >
Java stacktrace:
java.lang.NullPointerException
at org.orekit.propagation.integration.AbstractIntegratedPropagator$AdaptedStepHandler.init(AbstractIntegratedPropagator.java:1050)
at org.hipparchus.ode.AbstractIntegrator.initIntegration(AbstractIntegrator.java:224)
at org.hipparchus.ode.nonstiff.EmbeddedRungeKuttaIntegrator.integrate(EmbeddedRungeKuttaIntegrator.java:195)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.integrateDynamics(AbstractIntegratedPropagator.java:509)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:440)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:400)

Version specification:
orekit version “12.2”
python version “3.11.8”
openjdk version “1.8.0_412”
OpenJDK Runtime Environment (Zulu 8.78.0.19-CA-win64) (build 1.8.0_412-b08)

Hello @eshwarbhargav and welcome to the Orekit forum !

The issue you are encountering is a common one. In fact, i answered a post with the same problem today : Adding an AdditionalDerivativesProvider using python

In short, you cannot directly subclass Java interfaces with the wrapper, you need to use their Python equivalent PythonOrekitStepHandler and PythonOrekitFixedStepHandler.

Also, do not remove the super().init() in your subclassing classes. It will not work otherwise.

You will find answers to most wrapper issues here : examples/1_The_Basics.ipynb · master · Orekit Labs / Orekit Python Wrapper · GitLab

Cheers,
Vincent

1 Like

Hello @Vincent,

Thank you very much. Didn’t aware that there are Python equivalents to inherit the Java interfaces. I was only looking at the API docs but your reply is helpful and I also had a look at the examples. The issue is resolved now.

Have a nice day :slight_smile:
Eshwar

2 Likes