Get SpacecraftState After Event Occurs

I’m trying to set up event handlers to access spacecraft state data both before and after an event occurs. I have a few use cases for this, but an example use case is a simple impulsive maneuver, using ImpulseManeuver with a DateDetector trigger. I added a custom event handler, to fire when the maneuver occurs, but within the handler, I only have the SpacecraftState BEFORE the maneuver is performed. I would like to also be able to get the SpacecraftState immediately after the maneuver occurs. Basically, right after the step occurs.

I’d like to be able to get the spacecraft mass, for example, before and after the maneuver so that I can know how much was used by the maneuver. Of course I could calculate the mass myself with the pre-maneuver mass, delta-V and Isp, but I was wondering if there is an out of the box “Orekit way” of getting the SpacecraftState before and after the event.

Another use case would be for ephemeris writing to an OEM file. When I encounter the maneuver during propagation, I’d like to be able to write the pre-maneuver state to the file, create a new OEM segment, and then write the post maneuver state at the start of the new segment (but at the same epoch since it’s an impulsive maneuver). Again, I could keep track of all my maneuver times myself, propagate to those times and get my pre- and post-maneuver states that way, but I’m looking for a more elegant way of doing that.

There are similar use cases for attitude events, so it would be useful to be able to get a full SpacecraftState before and after instantaneous events occur.

Any thoughts or suggestions? Thanks!

Maybe overwrite the resetState method in a dedicated handler and wrap the call to the base resetState to store both states?


@luc Great suggestion! That’ll work perfectly. Thanks for the quick reply.