Hi all, I would like to implement a custom handler to get sun vector position relative to spacecraft frame. Looking in some examples I am implementing it as shown in the code below.
class SunvectorPosHandler(PythonOrekitFixedStepHandler):
def __init__(self, angle):
# set up Earth model
self.earth = OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
Constants.WGS84_EARTH_FLATTENING,
FramesFactory.getITRF(IERSConventions.IERS_2010, False))
self.sun = CelestialBodyFactory.getSun()
self.sunRadius = Constants.SUN_RADIUS
self.dates = []
self.sunXs = []
self.sunYs = []
self.sunZs = []
# Initialize the superclass as well
super(CorridorHandler, self).__init__()
def init(self, s0:SpacecraftState, t:AbsoluteDate, step: float):
# needs to be stated to fulfill the interface specification
pass
def handleStep(self, currentState: SpacecraftState):
inertToSpacecraft = currentState.toTransform()
date = currentState.getDate()
sunInert = self.sun.getPVCoordinates(date, currentState.getFrame()).getPosition()
#sunSat = inertToSpacecraft.transformPosition(sunInert)
#sunX = sunSat.getX() / sunSat.getNorm()
#sunY = sunSat.getY() / sunSat.getNorm()
#sunZ = sunSat.getZ() / sunSat.getNorm()
#self.dates.append(date)
#self.sunXs.append(sunX)
#self.sunYs.append(sunY)
#self.sunZs.append(sunZ)
def finish(self, finalState: SpacecraftState):
pass
handler = CorridorHandler(ANGULAR_OFFSET)
Propagator.cast_(propagator).setStepHandler(STEP, handler)
start = epochDate
propagator.propagate(start, start.shiftedBy(DURATION))
It throws the following:
JavaError Traceback (most recent call last) Cell In[9], [line 2]
start = epochDate
---->propagator.propagate(start, start.shiftedBy(DURATION)) JavaError: <super: <class
'JavaError'>, <JavaError object>> Java stacktrace: java.lang.RuntimeException: AttributeError
at org.orekit.propagation.sampling.PythonOrekitFixedStepHandler.handleStep(Native Method)
at org.orekit.propagation.sampling.OrekitStepNormalizer.handleStep(OrekitStepNormalizer.java:111)
at org.orekit.propagation.sampling.StepHandlerMultiplexer.handleStep(StepHandlerMultiplexer.java:184)
at org.orekit.propagation.analytical.AbstractAnalyticalPropagator.acceptStep(AbstractAnalyticalPropagator.java:336)
at org.orekit.propagation.analytical.AbstractAnalyticalPropagator.propagate(AbstractAnalyticalPropagator.java:153)
If I comment the line
sunInert = self.sun.getPVCoordinates(date, currentState.getFrame()).getPosition()
Then it runs ok.
Could anyone please guide me on what could be happening here?
Thank you
Sebastian.