Question about InterSatellitesRange

Hi,

I met a problem with “InterSatellitesRange”. I’m not sure if it’s a bug or I don’t get it and made some mistakes. I hope you could help me.

I have a constellation with several satellites (assume 60) that connect with each other by ISL. Now I would like to simulate some measurements used for orbit determination. So I created one Generator and registered propagators of all satellites to it (so the propagatorIndex would be 0-59). Then I created the schedulers for each ISL and attached them to the Generator. After generating the measurements, I used BatchLSEstimator to do the estimation.

But when I did estimator.estimate(); I met an error:

Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: 41
	at org.orekit.estimation.measurements.InterSatellitesRange.theoreticalEvaluation(InterSatellitesRange.java:128)
	at org.orekit.estimation.measurements.AbstractMeasurement.estimate(AbstractMeasurement.java:204)
	at org.orekit.estimation.leastsquares.MeasurementHandler.handleStep(MeasurementHandler.java:95)
	at org.orekit.propagation.PropagatorsParallelizer.propagate(PropagatorsParallelizer.java:205)
	at org.orekit.estimation.leastsquares.BatchLSModel.value(BatchLSModel.java:245)
	at org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresFactory$LocalLeastSquaresProblem.evaluate(LeastSquaresFactory.java:440)
	at org.orekit.estimation.leastsquares.BatchLSEstimator$TappedLSProblem.evaluate(BatchLSEstimator.java:602)
	at org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer.optimize(LevenbergMarquardtOptimizer.java:333)
	at org.orekit.estimation.leastsquares.BatchLSEstimator.estimate(BatchLSEstimator.java:422)

I checked the source code of “InterSatellitesRange”. I noticed on the lines 126-132

// coordinates of both satellites
final ObservableSatellite local = getSatellites().get(0);
final SpacecraftState stateL = states[local.getPropagatorIndex()];
final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaL = getCoordinates(stateL, 0, factory);
final ObservableSatellite remote = getSatellites().get(1);
final SpacecraftState stateR = states[remote.getPropagatorIndex()];
final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaR = getCoordinates(stateR, 6, factory);

So I think the problem here is that since it’s an ISL measurement, the size of variable states is 2 (local and remote satellites). But the propagatorIndex it gets from local.getPropagatorIndex() is no longer 0 or 1 (in this case is 41).

image

I think a simple way to solve this problem is just changing the index directly as 0 and 1 (since the line above uses getSatellites().get(0) and getSatellites().get(1) respectively), like

final SpacecraftState stateL = states[0];
final SpacecraftState stateR = states[1];

Or maybe I don’t quite get the reason why it designs like that, and I made some other mistakes led to this? Do you have any suggestion?

Thanks a lot!

Congratulations, you found a bug!
However your proposed fix would not work. In fact, the bug is spread over several classes,
including MeasurementHandler which may not provide the correct states.

Could you open a bug report on https://gitlab.orekit.org/orekit/orekit/issues?

Thanks a lot for your reply!

I’ve opened a report on the website. Hope I did it right.

I hope it could be fixed soon. Many thanks for your great work!

The issue has been fixed, thanks for reporting it!

My pleasure. Thanks a lot for quick fixing!

Hi Luc, sorry to bother you again.

Today I tested the fixed code, it works fine. However, I met the same error with the range measurements again:

Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: 7
	at org.orekit.estimation.measurements.Range.theoreticalEvaluation(Range.java:139)
	at org.orekit.estimation.measurements.AbstractMeasurement.estimate(AbstractMeasurement.java:204)
	at org.orekit.estimation.measurements.generation.RangeBuilder.build(RangeBuilder.java:83)
	at org.orekit.estimation.measurements.generation.RangeBuilder.build(RangeBuilder.java:33)
	at org.orekit.estimation.measurements.generation.EventBasedScheduler.generate(EventBasedScheduler.java:124)
	at org.orekit.estimation.measurements.generation.Generator$GeneratorHandler.handleStep(Generator.java:130)
	at org.orekit.propagation.PropagatorsParallelizer.propagate(PropagatorsParallelizer.java:205)
	at org.orekit.estimation.measurements.generation.Generator.generate(Generator.java:95)

I checked the source code of “Range” and I think it might be the same problem. Would you mind to check it too? Thanks a lot!

You are right.
I thought I had modified everything but obviously forgot some parts.
I will reopen the issue and provide a new fix soon.

Sorry for the mishap.

It’s OK. Many thanks for your work!

I hope it is fixed now, could you check it?

Yes, it works well now. Thanks a lot for the fixing!