Skip to content
Snippets Groups Projects
Commit dd1c79a5 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Fixed inverse localization.

parent 0a311912
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
package org.orekit.rugged.api; package org.orekit.rugged.api;
import java.util.ArrayList; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure; import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
...@@ -33,17 +33,17 @@ import org.orekit.utils.PVCoordinates; ...@@ -33,17 +33,17 @@ import org.orekit.utils.PVCoordinates;
/** Class dedicated to when ground point crosses mean sensor plane. */ /** Class dedicated to when ground point crosses mean sensor plane. */
class SensorMeanPlaneCrossing { class SensorMeanPlaneCrossing {
/** Number of points for frames interpolation. */ /** Converter between spacecraft and body. */
private static final int INTERPOLATION_POINTS = 5; private final SpacecraftToObservedBody scToBody;
/** Line numbers of the middle sample point. */ /** Line numbers of the middle sample point. */
private final int midLine; private final double midLine;
/** Transforms sample from observed body frame to inertial frame. */ /** Transforms sample from observed body frame to inertial frame. */
private final List<Transform> bodyToInertial; private final List<Transform> bodyToInertial;
/** Transforms sample from spacecraft frame to inertial frame. */ /** Transform from inertial frame to spacecraft frame, for middle line. */
private final List<Transform> scToInertial; private final Transform midLineScToInert;
/** Minimum line number in the search interval. */ /** Minimum line number in the search interval. */
private final int minLine; private final int minLine;
...@@ -87,6 +87,7 @@ class SensorMeanPlaneCrossing { ...@@ -87,6 +87,7 @@ class SensorMeanPlaneCrossing {
try { try {
this.sensor = sensor; this.sensor = sensor;
this.scToBody = scToBody;
this.minLine = minLine; this.minLine = minLine;
this.maxLine = maxLine; this.maxLine = maxLine;
this.lightTimeCorrection = lightTimeCorrection; this.lightTimeCorrection = lightTimeCorrection;
...@@ -94,21 +95,11 @@ class SensorMeanPlaneCrossing { ...@@ -94,21 +95,11 @@ class SensorMeanPlaneCrossing {
this.maxEval = maxEval; this.maxEval = maxEval;
this.accuracy = accuracy; this.accuracy = accuracy;
// compute one the transforms for middle line, as they will be reused midLine = 0.5 * (minLine + maxLine);
// as the start point for all searches bodyToInertial = Arrays.asList(scToBody.getInertialToBody(sensor.getDate(minLine)).getInverse(),
bodyToInertial = new ArrayList<Transform>(INTERPOLATION_POINTS); scToBody.getInertialToBody(sensor.getDate(midLine)).getInverse(),
scToInertial = new ArrayList<Transform>(INTERPOLATION_POINTS); scToBody.getInertialToBody(sensor.getDate(maxLine)).getInverse());
int middle = -1; midLineScToInert = scToBody.getScToInertial(sensor.getDate(midLine));
for (int i = 0; i < INTERPOLATION_POINTS; ++i) {
final int line = (i * maxLine + (INTERPOLATION_POINTS - i) * minLine) / INTERPOLATION_POINTS;
if (i == INTERPOLATION_POINTS / 2) {
middle = line;
}
final AbsoluteDate date = sensor.getDate(line);
bodyToInertial.add(scToBody.getInertialToBody(date).getInverse());
scToInertial.add(scToBody.getScToInertial(date));
}
midLine = middle;
} catch (OrekitException oe) { } catch (OrekitException oe) {
throw new RuggedException(oe, oe.getSpecifier(), oe.getParts()); throw new RuggedException(oe, oe.getSpecifier(), oe.getParts());
...@@ -184,8 +175,8 @@ class SensorMeanPlaneCrossing { ...@@ -184,8 +175,8 @@ class SensorMeanPlaneCrossing {
// We expect two or three evaluations only. Each new evaluation shows up quickly in // We expect two or three evaluations only. Each new evaluation shows up quickly in
// the performances as it involves frames conversions // the performances as it involves frames conversions
double crossingLine = midLine; double crossingLine = midLine;
Transform bodyToInert = bodyToInertial.get(INTERPOLATION_POINTS / 2); Transform bodyToInert = bodyToInertial.get(1);
Transform scToInert = scToInertial.get(INTERPOLATION_POINTS / 2); Transform scToInert = midLineScToInert;
boolean atMin = false; boolean atMin = false;
boolean atMax = false; boolean atMax = false;
for (int i = 0; i < maxEval; ++i) { for (int i = 0; i < maxEval; ++i) {
...@@ -224,8 +215,8 @@ class SensorMeanPlaneCrossing { ...@@ -224,8 +215,8 @@ class SensorMeanPlaneCrossing {
} }
final AbsoluteDate date = sensor.getDate(crossingLine); final AbsoluteDate date = sensor.getDate(crossingLine);
bodyToInert = Transform.interpolate(date, false, false, bodyToInertial); bodyToInert = Transform.interpolate(date, true, true, bodyToInertial);
scToInert = Transform.interpolate(date, false, false, scToInertial); scToInert = scToBody.getScToInertial(date);
} }
return null; return null;
......
...@@ -431,7 +431,6 @@ public class RuggedTest { ...@@ -431,7 +431,6 @@ public class RuggedTest {
// the following test is disabled by default // the following test is disabled by default
// it is only used to check timings, and also create a small (2M) temporary file // it is only used to check timings, and also create a small (2M) temporary file
@Test @Test
@Ignore
public void testInverseLocalizationTiming() public void testInverseLocalizationTiming()
throws RuggedException, OrekitException, URISyntaxException { throws RuggedException, OrekitException, URISyntaxException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment