Commit 059716a6 authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Allowed custom setting of state to TLE conversion in propagator builder.

parent 8954339e
Pipeline #1517 passed with stages
in 19 minutes and 47 seconds
......@@ -269,6 +269,9 @@
<contributor>
<name>Lars N&#230;sbye Christensen</name>
</contributor>
<contributor>
<name>Emmanuel Papanagiotou</name>
</contributor>
<contributor>
<name>Thomas Paulet</name>
</contributor>
......
......@@ -46,12 +46,24 @@ import org.orekit.utils.ParameterDriversList;
*/
public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements OrbitDeterminationPropagatorBuilder {
/** Default value for epsilon. */
private static final double EPSILON_DEFAULT = 1.0e-10;
/** Default value for maxIterations. */
private static final int MAX_ITERATIONS_DEFAULT = 100;
/** Data context used to access frames and time scales. */
private final DataContext dataContext;
/** Template TLE. */
private final TLE templateTLE;
/** Threshold for convergence used in TLE generation. */
private final double epsilon;
/** Maximum number of iterations for convergence used in TLE generation. */
private final int maxIterations;
/** Build a new instance. This constructor uses the {@link DataContext#getDefault()
* default data context}.
* <p>
......@@ -61,6 +73,9 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
* classification, .... and is also used together with the {@code positionScale} to
* convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
* parameters used by the callers of this builder to the real orbital parameters.
* </p><p>
* Using this constructor, {@link #EPSILON_DEFAULT} and {@link #MAX_ITERATIONS_DEFAULT}
* are used for spacecraft's state to TLE transformation
* </p>
* @param templateTLE reference TLE from which real orbits will be built
* @param positionAngle position angle type to use
......@@ -83,6 +98,9 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
* classification, .... and is also used together with the {@code positionScale} to
* convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
* parameters used by the callers of this builder to the real orbital parameters.
* </p><p>
* Using this constructor, {@link #EPSILON_DEFAULT} and {@link #MAX_ITERATIONS_DEFAULT}
* are used for spacecraft's state to TLE transformation
* </p>
* @param templateTLE reference TLE from which real orbits will be built
* @param positionAngle position angle type to use
......@@ -90,11 +108,65 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
* (typically set to the expected standard deviation of the position)
* @param dataContext used to access frames and time scales.
* @since 10.1
* @see #TLEPropagatorBuilder(TLE, PositionAngle, double, DataContext, double, int)
*/
public TLEPropagatorBuilder(final TLE templateTLE,
final PositionAngle positionAngle,
final double positionScale,
final DataContext dataContext) {
this(templateTLE, positionAngle, positionScale, dataContext, EPSILON_DEFAULT, MAX_ITERATIONS_DEFAULT);
}
/** Build a new instance. This constructor uses the {@link DataContext#getDefault()
* default data context}.
* <p>
* The template TLE is used as a model to {@link
* #createInitialOrbit() create initial orbit}. It defines the
* inertial frame, the central attraction coefficient, orbit type, satellite number,
* classification, .... and is also used together with the {@code positionScale} to
* convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
* parameters used by the callers of this builder to the real orbital parameters.
* </p>
* @param templateTLE reference TLE from which real orbits will be built
* @param positionAngle position angle type to use
* @param positionScale scaling factor used for orbital parameters normalization
* (typically set to the expected standard deviation of the position)
* @param epsilon used to compute threshold for convergence check
* @param maxIterations maximum number of iterations for convergence
* @since 11.0.2
* @see #TLEPropagatorBuilder(TLE, PositionAngle, double, DataContext, double, int)
*/
@DefaultDataContext
public TLEPropagatorBuilder(final TLE templateTLE, final PositionAngle positionAngle,
final double positionScale, final double epsilon,
final int maxIterations) {
this(templateTLE, positionAngle, positionScale, DataContext.getDefault(), epsilon, maxIterations);
}
/** Build a new instance.
* <p>
* The template TLE is used as a model to {@link
* #createInitialOrbit() create initial orbit}. It defines the
* inertial frame, the central attraction coefficient, orbit type, satellite number,
* classification, .... and is also used together with the {@code positionScale} to
* convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
* parameters used by the callers of this builder to the real orbital parameters.
* </p>
* @param templateTLE reference TLE from which real orbits will be built
* @param positionAngle position angle type to use
* @param positionScale scaling factor used for orbital parameters normalization
* (typically set to the expected standard deviation of the position)
* @param dataContext used to access frames and time scales.
* @param epsilon used to compute threshold for convergence check
* @param maxIterations maximum number of iterations for convergence
* @since 11.0.2
*/
public TLEPropagatorBuilder(final TLE templateTLE,
final PositionAngle positionAngle,
final double positionScale,
final DataContext dataContext,
final double epsilon,
final int maxIterations) {
super(TLEPropagator.selectExtrapolator(templateTLE, dataContext.getFrames())
.getInitialState().getOrbit(),
positionAngle, positionScale, false,
......@@ -102,9 +174,10 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
for (final ParameterDriver driver : templateTLE.getParametersDrivers()) {
addSupportedParameter(driver);
}
this.templateTLE = templateTLE;
this.dataContext = dataContext;
this.templateTLE = templateTLE;
this.dataContext = dataContext;
this.epsilon = epsilon;
this.maxIterations = maxIterations;
}
/** {@inheritDoc} */
......@@ -119,7 +192,7 @@ public class TLEPropagatorBuilder extends AbstractPropagatorBuilder implements O
final TimeScale utc = dataContext.getTimeScales().getUTC();
// TLE related to the orbit
final TLE tle = TLE.stateToTLE(state, templateTLE, utc, teme);
final TLE tle = TLE.stateToTLE(state, templateTLE, utc, teme, epsilon, maxIterations);
final List<ParameterDriver> drivers = templateTLE.getParametersDrivers();
for (int index = 0; index < drivers.size(); index++) {
if (drivers.get(index).isSelected()) {
......
......@@ -17,10 +17,14 @@
package org.orekit.propagation.conversion;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.orekit.Utils;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.orbits.PositionAngle;
import org.orekit.propagation.analytical.tle.TLE;
import org.orekit.propagation.analytical.tle.TLEPropagator;
import org.orekit.utils.ParameterDriver;
public class TLEConverterTest {
......@@ -28,7 +32,6 @@ public class TLEConverterTest {
@Test
public void testDeselectOrbitals() {
Utils.setDataRoot("regular-data");
final TLE tle = new TLE("1 27508U 02040A 12021.25695307 -.00000113 00000-0 10000-3 0 7326",
"2 27508 0.0571 356.7800 0005033 344.4621 218.7816 1.00271798 34501");
......@@ -41,4 +44,37 @@ public class TLEConverterTest {
Assert.assertFalse(driver.isSelected());
}
}
@Test
public void testIssue859() {
// INTELSAT 25 TLE taken from Celestrak the 2021-11-24T07:45:00.000
// Because the satellite eccentricity and inclination are closed to zero, this satellite
// reach convergence issues when converting the spacecraft's state to TLE.
final TLE tle = new TLE("1 33153U 08034A 21327.46310733 -.00000207 00000+0 00000+0 0 9990",
"2 33153 0.0042 20.7353 0003042 213.9370 323.2156 1.00270917 48929");
// Verify convergence issue
final TLEPropagatorBuilder propagatorBuilderError = new TLEPropagatorBuilder(tle, PositionAngle.MEAN, 1.);
try {
propagatorBuilderError.buildPropagator(propagatorBuilderError.getSelectedNormalizedParameters());
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.UNABLE_TO_COMPUTE_TLE, oe.getSpecifier());
}
// Now try using different convergence threshold
final TLEPropagatorBuilder propagatorBuilder = new TLEPropagatorBuilder(tle, PositionAngle.MEAN, 1., 2.0e-4, 10000);
final TLEPropagator propagator = propagatorBuilder.buildPropagator(propagatorBuilderError.getSelectedNormalizedParameters());
final TLE newTLE = propagator.getTLE();
// Verify
Assert.assertEquals(0.0, newTLE.getDate().durationFrom(tle.getDate()), Utils.epsilonTest);
}
@Before
public void setUp() {
Utils.setDataRoot("regular-data");
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment