TLEPropagatorBuilder.java

  1. /* Copyright 2002-2025 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.propagation.conversion;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.attitudes.AttitudeProvider;
  20. import org.orekit.attitudes.FrameAlignedProvider;
  21. import org.orekit.data.DataContext;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.orbits.Orbit;
  24. import org.orekit.orbits.PositionAngleType;
  25. import org.orekit.propagation.Propagator;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.propagation.analytical.tle.TLE;
  28. import org.orekit.propagation.analytical.tle.TLEPropagator;
  29. import org.orekit.propagation.analytical.tle.generation.TleGenerationAlgorithm;
  30. import org.orekit.utils.ParameterDriver;

  31. import java.util.List;

  32. /** Builder for TLEPropagator.
  33.  * @author Pascal Parraud
  34.  * @author Thomas Paulet
  35.  * @since 6.0
  36.  */
  37. public class TLEPropagatorBuilder extends AbstractAnalyticalPropagatorBuilder<TLEPropagator> {

  38.     /** Data context used to access frames and time scales. */
  39.     private final DataContext dataContext;

  40.     /** Template TLE. */
  41.     private final TLE templateTLE;

  42.     /** TLE generation algorithm. */
  43.     private final TleGenerationAlgorithm generationAlgorithm;

  44.     /** Build a new instance. This constructor uses the {@link DataContext#getDefault()
  45.      * default data context}.
  46.      * <p>
  47.      * The template TLE is used as a model to {@link
  48.      * #createInitialOrbit() create initial orbit}. It defines the
  49.      * inertial frame, the central attraction coefficient, orbit type, satellite number,
  50.      * classification, .... and is also used together with the {@code positionScale} to
  51.      * convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
  52.      * parameters used by the callers of this builder to the real orbital parameters.
  53.      * </p>
  54.      * @param templateTLE reference TLE from which real orbits will be built
  55.      * @param positionAngleType position angle type to use
  56.      * @param positionScale scaling factor used for orbital parameters normalization
  57.      * (typically set to the expected standard deviation of the position)
  58.      * @param generationAlgorithm TLE generation algorithm
  59.      * @since 12.0
  60.      * @see #TLEPropagatorBuilder(TLE, PositionAngleType, double, DataContext, TleGenerationAlgorithm)
  61.      * @see #TLEPropagatorBuilder(TLE, PositionAngleType, double, DataContext, TleGenerationAlgorithm, AttitudeProvider)
  62.      */
  63.     @DefaultDataContext
  64.     public TLEPropagatorBuilder(final TLE templateTLE, final PositionAngleType positionAngleType,
  65.                                 final double positionScale, final TleGenerationAlgorithm generationAlgorithm) {
  66.         this(templateTLE, positionAngleType, positionScale, DataContext.getDefault(), generationAlgorithm);
  67.     }

  68.     /** Build a new instance.
  69.      * <p>
  70.      * The template TLE is used as a model to {@link
  71.      * #createInitialOrbit() create initial orbit}. It defines the
  72.      * inertial frame, the central attraction coefficient, orbit type, satellite number,
  73.      * classification, .... and is also used together with the {@code positionScale} to
  74.      * convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
  75.      * parameters used by the callers of this builder to the real orbital parameters.
  76.      * The default attitude provider is aligned with the orbit's inertial frame.
  77.      * </p>
  78.      * @param templateTLE reference TLE from which real orbits will be built
  79.      * @param positionAngleType position angle type to use
  80.      * @param positionScale scaling factor used for orbital parameters normalization
  81.      * (typically set to the expected standard deviation of the position)
  82.      * @param dataContext used to access frames and time scales.
  83.      * @param generationAlgorithm TLE generation algorithm
  84.      * @since 12.0
  85.      * @see #TLEPropagatorBuilder(TLE, PositionAngleType, double, DataContext, TleGenerationAlgorithm, AttitudeProvider)
  86.      */
  87.     public TLEPropagatorBuilder(final TLE templateTLE, final PositionAngleType positionAngleType,
  88.                                 final double positionScale, final DataContext dataContext,
  89.                                 final TleGenerationAlgorithm generationAlgorithm) {
  90.         this(templateTLE, positionAngleType, positionScale, dataContext, generationAlgorithm, FrameAlignedProvider.of(dataContext.getFrames().getTEME()));
  91.     }

  92.     /** Build a new instance.
  93.      * <p>
  94.      * The template TLE is used as a model to {@link
  95.      * #createInitialOrbit() create initial orbit}. It defines the
  96.      * inertial frame, the central attraction coefficient, orbit type, satellite number,
  97.      * classification, .... and is also used together with the {@code positionScale} to
  98.      * convert from the {@link ParameterDriver#setNormalizedValue(double) normalized}
  99.      * parameters used by the callers of this builder to the real orbital parameters.
  100.      * </p>
  101.      * @param templateTLE reference TLE from which real orbits will be built
  102.      * @param positionAngleType position angle type to use
  103.      * @param positionScale scaling factor used for orbital parameters normalization
  104.      * (typically set to the expected standard deviation of the position)
  105.      * @param dataContext used to access frames and time scales.
  106.      * @param generationAlgorithm TLE generation algorithm
  107.      * @param attitudeProvider attitude law to use
  108.      * @since 12.2
  109.      */
  110.     public TLEPropagatorBuilder(final TLE templateTLE, final PositionAngleType positionAngleType,
  111.                                 final double positionScale, final DataContext dataContext,
  112.                                 final TleGenerationAlgorithm generationAlgorithm, final AttitudeProvider attitudeProvider) {
  113.         super(TLEPropagator.selectExtrapolator(templateTLE, dataContext.getFrames().getTEME(), attitudeProvider).getInitialState().getOrbit(),
  114.               positionAngleType, positionScale, false, attitudeProvider, Propagator.DEFAULT_MASS);

  115.         // Supported parameters: Bstar
  116.         addSupportedParameters(templateTLE.getParametersDrivers());

  117.         this.templateTLE         = templateTLE;
  118.         this.dataContext         = dataContext;
  119.         this.generationAlgorithm = generationAlgorithm;
  120.     }


  121.     /** {@inheritDoc} */
  122.     @Override
  123.     public TLEPropagator buildPropagator(final double[] normalizedParameters) {

  124.         // create the orbit
  125.         setParameters(normalizedParameters);
  126.         final Orbit           orbit = createInitialOrbit();
  127.         final SpacecraftState state = new SpacecraftState(orbit);
  128.         final Frame           teme  = dataContext.getFrames().getTEME();

  129.         // TLE related to the orbit
  130.         final TLE tle = generationAlgorithm.generate(state, templateTLE);
  131.         final List<ParameterDriver> drivers = templateTLE.getParametersDrivers();
  132.         for (int index = 0; index < drivers.size(); index++) {
  133.             if (drivers.get(index).isSelected()) {
  134.                 tle.getParametersDrivers().get(index).setSelected(true);
  135.             }
  136.         }

  137.         // propagator
  138.         final TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle, getAttitudeProvider(), getMass(), teme);
  139.         getImpulseManeuvers().forEach(propagator::addEventDetector);
  140.         return propagator;
  141.     }

  142.     /** Getter for the template TLE.
  143.      * @return the template TLE
  144.      */
  145.     public TLE getTemplateTLE() {
  146.         return templateTLE;
  147.     }
  148. }