PV.java

  1. /* Copyright 2002-2017 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;

  18. import java.util.Arrays;

  19. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.TimeStampedPVCoordinates;

  24. /** Class modeling a position-velocity state.
  25.  * @author Luc Maisonobe
  26.  * @since 8.0
  27.  */
  28. public class PV extends AbstractMeasurement<PV> {

  29.     /** Identity matrix, for states derivatives. */
  30.     private static final double[][] IDENTITY = new double[][] {
  31.         {
  32.             1, 0, 0, 0, 0, 0
  33.         }, {
  34.             0, 1, 0, 0, 0, 0
  35.         }, {
  36.             0, 0, 1, 0, 0, 0
  37.         }, {
  38.             0, 0, 0, 1, 0, 0
  39.         }, {
  40.             0, 0, 0, 0, 1, 0
  41.         }, {
  42.             0, 0, 0, 0, 0, 1
  43.         }
  44.     };

  45.     /** Simple constructor.
  46.      * <p>
  47.      * The measurement must be in the orbit propagation frame.
  48.      * </p>
  49.      * <p>
  50.      * This constructor uses 0 as the index of the propagator related
  51.      * to this measurement, thus being well suited for mono-satellite
  52.      * orbit determination.
  53.      * </p>
  54.      * @param date date of the measurement
  55.      * @param position position
  56.      * @param velocity velocity
  57.      * @param sigmaPosition theoretical standard deviation on position components
  58.      * @param sigmaVelocity theoretical standard deviation on velocity components
  59.      * @param baseWeight base weight
  60.      */
  61.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  62.               final double sigmaPosition, final double sigmaVelocity, final double baseWeight) {
  63.         this(date, position, velocity, sigmaPosition, sigmaVelocity, baseWeight, 0);
  64.     }

  65.     /** Simple constructor.
  66.      * <p>
  67.      * The measurement must be in the orbit propagation frame.
  68.      * </p>
  69.      * @param date date of the measurement
  70.      * @param position position
  71.      * @param velocity velocity
  72.      * @param sigmaPosition theoretical standard deviation on position components
  73.      * @param sigmaVelocity theoretical standard deviation on velocity components
  74.      * @param baseWeight base weight
  75.      * @param propagatorIndex index of the propagator related to this measurement
  76.      * @since 9.0
  77.      */
  78.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  79.               final double sigmaPosition, final double sigmaVelocity, final double baseWeight,
  80.               final int propagatorIndex) {
  81.         super(date,
  82.               new double[] {
  83.                   position.getX(), position.getY(), position.getZ(),
  84.                   velocity.getX(), velocity.getY(), velocity.getZ()
  85.               }, new double[] {
  86.                   sigmaPosition, sigmaPosition, sigmaPosition,
  87.                   sigmaVelocity, sigmaVelocity, sigmaVelocity
  88.               }, new double[] {
  89.                   baseWeight, baseWeight, baseWeight,
  90.                   baseWeight, baseWeight, baseWeight
  91.               }, Arrays.asList(propagatorIndex));
  92.     }

  93.     /** Get the position.
  94.      * @return position
  95.      */
  96.     public Vector3D getPosition() {
  97.         final double[] pv = getObservedValue();
  98.         return new Vector3D(pv[0], pv[1], pv[2]);
  99.     }

  100.     /** Get the velocity.
  101.      * @return velocity
  102.      */
  103.     public Vector3D getVelocity() {
  104.         final double[] pv = getObservedValue();
  105.         return new Vector3D(pv[3], pv[4], pv[5]);
  106.     }

  107.     /** {@inheritDoc} */
  108.     @Override
  109.     protected EstimatedMeasurement<PV> theoreticalEvaluation(final int iteration, final int evaluation,
  110.                                                              final SpacecraftState[] states)
  111.         throws OrekitException {

  112.         // PV value
  113.         final TimeStampedPVCoordinates pv = states[getPropagatorsIndices().get(0)].getPVCoordinates();

  114.         // prepare the evaluation
  115.         final EstimatedMeasurement<PV> estimated =
  116.                         new EstimatedMeasurement<>(this, iteration, evaluation, states,
  117.                                                    new TimeStampedPVCoordinates[] {
  118.                                                        pv
  119.                                                    });

  120.         estimated.setEstimatedValue(new double[] {
  121.             pv.getPosition().getX(), pv.getPosition().getY(), pv.getPosition().getZ(),
  122.             pv.getVelocity().getX(), pv.getVelocity().getY(), pv.getVelocity().getZ()
  123.         });

  124.         // partial derivatives with respect to state
  125.         estimated.setStateDerivatives(0, IDENTITY);

  126.         return estimated;

  127.     }

  128. }