InterSatellitesRangeBuilder.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.estimation.measurements.generation;

  18. import org.hipparchus.random.CorrelatedRandomVectorGenerator;
  19. import org.orekit.estimation.measurements.EstimationModifier;
  20. import org.orekit.estimation.measurements.InterSatellitesRange;
  21. import org.orekit.estimation.measurements.ObservableSatellite;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.utils.ParameterDriver;


  25. /** Builder for {@link InterSatellitesRange} measurements.
  26.  * @author Luc Maisonobe
  27.  * @since 9.3
  28.  */
  29. public class InterSatellitesRangeBuilder extends AbstractMeasurementBuilder<InterSatellitesRange> {

  30.     /** Flag indicating whether it is a two-way measurement. */
  31.     private final boolean twoway;

  32.     /** Simple constructor.
  33.      * @param noiseSource noise source, may be null for generating perfect measurements
  34.      * @param local satellite which receives the signal and performs the measurement
  35.      * @param remote satellite which simply emits the signal in the one-way case,
  36.      * or reflects the signal in the two-way case
  37.      * @param twoWay flag indicating whether it is a two-way measurement
  38.      * @param sigma theoretical standard deviation
  39.      * @param baseWeight base weight
  40.      */
  41.     public InterSatellitesRangeBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  42.                                        final ObservableSatellite local, final ObservableSatellite remote,
  43.                                        final boolean twoWay, final double sigma, final double baseWeight) {
  44.         super(noiseSource, sigma, baseWeight, local, remote);
  45.         this.twoway  = twoWay;
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public InterSatellitesRange build(final SpacecraftState[] states) {

  50.         final ObservableSatellite[] satellites = getSatellites();
  51.         final double sigma                     = getTheoreticalStandardDeviation()[0];
  52.         final double baseWeight                = getBaseWeight()[0];
  53.         final SpacecraftState state            = states[satellites[0].getPropagatorIndex()];

  54.         // create a dummy measurement
  55.         final InterSatellitesRange dummy = new InterSatellitesRange(satellites[0], satellites[1], twoway, state.getDate(),
  56.                                                                     Double.NaN, sigma, baseWeight);
  57.         for (final EstimationModifier<InterSatellitesRange> modifier : getModifiers()) {
  58.             dummy.addModifier(modifier);
  59.         }

  60.         // set a reference date for parameters missing one
  61.         for (final ParameterDriver driver : dummy.getParametersDrivers()) {
  62.             if (driver.getReferenceDate() == null) {
  63.                 final AbsoluteDate start = getStart();
  64.                 final AbsoluteDate end   = getEnd();
  65.                 driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
  66.             }
  67.         }

  68.         // estimate the perfect value of the measurement
  69.         double range = dummy.estimate(0, 0, states).getEstimatedValue()[0];

  70.         // add the noise
  71.         final double[] noise = getNoise();
  72.         if (noise != null) {
  73.             range += noise[0];
  74.         }

  75.         // generate measurement
  76.         final InterSatellitesRange measurement = new InterSatellitesRange(satellites[0], satellites[1], twoway, state.getDate(),
  77.                                                                           range, sigma, baseWeight);
  78.         for (final EstimationModifier<InterSatellitesRange> modifier : getModifiers()) {
  79.             measurement.addModifier(modifier);
  80.         }
  81.         return measurement;

  82.     }

  83. }