Measurement Generation not generating

Hey All,

I am working on an IOD project and I want to create measurements using the measurement generation method. I have written the following code, but it does not generate a range. When I print the last line, it says that it is a None type. Any help would be appreciated!

Cheers,

Niek

import datetime
from org.hipparchus.geometry.euclidean.threed import Vector3D
from org.orekit.utils import PVCoordinates, Constants, IERSConventions, TimeStampedPVCoordinates
import orekit
from org.orekit.frames import TopocentricFrame
from orekit.pyhelpers import setup_orekit_curdir, datetime_to_absolutedate
from org.orekit.time import TimeScalesFactory
from org.orekit.frames import FramesFactory
from org.orekit.estimation.measurements import ObservableSatellite, GroundStation
from org.orekit.estimation.measurements.generation import RangeBuilder, Generator, ContinuousScheduler
from org.orekit.time import FixedStepSelector
from org.orekit.propagation.conversion import ClassicalRungeKuttaIntegratorBuilder
from org.orekit.propagation.conversion import NumericalPropagatorBuilder
from org.orekit.orbits import CartesianOrbit, PositionAngleType
from math import radians
from org.orekit.bodies import OneAxisEllipsoid, GeodeticPoint
from org.orekit.forces.gravity import NewtonianAttraction


orekit.initVM()
setup_orekit_curdir()

#   Define initial conditions
intTime = 60.0 * 60.0 * 4
initPosition = Vector3D(5582294.559435759, 4349734.869382537, -13170.494688864354)
initVelocity = Vector3D(666.6371386727922, -847.3937617778438, 7428.834894791059)
initPV = PVCoordinates(initPosition, initVelocity)
initTime =  datetime.datetime(2024, 1, 29, 3, 3, 55, 960127)
initTimeAbsolute = datetime_to_absolutedate(initTime)
endTimeAbsolute = initTimeAbsolute.shiftedBy(intTime)
initTPV = TimeStampedPVCoordinates(initTimeAbsolute, initPV)



#   Define constants
equatorialRadius = Constants.WGS84_EARTH_EQUATORIAL_RADIUS
flattening = Constants.WGS84_EARTH_FLATTENING
mu = Constants.WGS84_EARTH_MU
utc = TimeScalesFactory.getUTC()

dt = 5.0

#   Define frames
lat_gs = radians(...)
lon_gs = radians(...)
alt_gs = 100.0
eci = FramesFactory.getEME2000()
ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, True)
earthShape = OneAxisEllipsoid(equatorialRadius, flattening, ecef)

geoPoint = GeodeticPoint(lat_gs, lon_gs, alt_gs)
topo = TopocentricFrame(earthShape, geoPoint, 'GroundStation')

#   Create Scheduler
noiseSource = None
groundStation = GroundStation(topo)
twoWay = True
std = 0.0
baseWeight = 1.0
sat = ObservableSatellite(0)

rangeBuilder = RangeBuilder(noiseSource, groundStation, twoWay, std, baseWeight, sat)
dataSelector = FixedStepSelector(dt,utc)
rangeScheduler = ContinuousScheduler(rangeBuilder, dataSelector)

#   Create Propagator
angleType = PositionAngleType.TRUE
ODESolverBuilder = ClassicalRungeKuttaIntegratorBuilder(dt)
orbit = CartesianOrbit(initTPV, eci, mu)
propagatorBuilder = NumericalPropagatorBuilder(orbit, ODESolverBuilder, angleType, 1.0)
propagatorBuilder.addForceModel(NewtonianAttraction(mu))
prop = propagatorBuilder.buildPropagator(propagatorBuilder.getSelectedNormalizedParameters())

#   Create Generator
gen = Generator()
gen.addPropagator(prop)
gen.addScheduler(rangeScheduler)
ranges = gen.generate(initTimeAbsolute, endTimeAbsolute)

print(ranges)

Hi @Niek,

What version of Orekit are you using?

Since 12, measurements Generator needs one or several “suscribers” that will store the measurements.
And the function generate(...) has void as return type

Your code should look like this.

#   Create Generator
gen = Generator()
gen.addPropagator(prop)
gen.addScheduler(rangeScheduler)

# Add suscriber
suscriber = GatheringSubscriber()
generator.addSubscriber(suscriber);

# Generate
gen.generate(initTimeAbsolute, endTimeAbsolute)

# Get the measurements
ranges = suscriber.getGeneratedMeasurements()

Cheers,
Maxime