SensorToSensorMapping.java

  1. /* Copyright 2013-2022 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.rugged.adjustment.measurements;

  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import java.util.Map;
  21. import java.util.Set;

  22. import org.orekit.rugged.linesensor.SensorPixel;

  23. /** Container for mapping sensors pixels of two viewing models.
  24.  * Store the distance between both lines of sight computed with
  25.  * {@link org.orekit.rugged.api.Rugged#distanceBetweenLOS(org.orekit.rugged.linesensor.LineSensor, org.orekit.time.AbsoluteDate, double, org.orekit.rugged.utils.SpacecraftToObservedBody, org.orekit.rugged.linesensor.LineSensor, org.orekit.time.AbsoluteDate, double)}
  26.  * <p> Constraints in relation to central body distance can be added.
  27.  * @see SensorMapping
  28.  * @author Lucie LabatAllee
  29.  * @author Guylaine Prat
  30.  * @since 2.0
  31.  */
  32. public class SensorToSensorMapping {

  33.     /** Default name for Rugged. */
  34.     private static final String RUGGED = "Rugged";

  35.     /** Name of the sensor B to which mapping applies. */
  36.     private final String sensorNameB;

  37.     /** Name of the Rugged B to which mapping applies. */
  38.     private final String ruggedNameB;

  39.     /** Mapping from sensor A to sensor B. */
  40.     private final SensorMapping<SensorPixel> interMapping;

  41.     /** Distances between two LOS. */
  42.     private final List<Double> losDistances;

  43.     /** Central body distances associated with pixel A. */
  44.     private final List<Double> bodyDistances;

  45.     /** Body constraint weight. */
  46.     private double bodyConstraintWeight;


  47.     /** Build a new instance without central body constraint (with default Rugged names).
  48.      * @param sensorNameA name of the sensor A to which mapping applies
  49.      * @param sensorNameB name of the sensor B to which mapping applies
  50.      */
  51.     public SensorToSensorMapping(final String sensorNameA, final String sensorNameB) {

  52.         this(sensorNameA, RUGGED, sensorNameB, RUGGED, 0.0);
  53.     }

  54.     /** Build a new instance with central body constraint.
  55.      * @param sensorNameA name of the sensor A to which mapping applies
  56.      * @param ruggedNameA name of the Rugged A to which mapping applies
  57.      * @param sensorNameB name of the sensor B to which mapping applies
  58.      * @param ruggedNameB name of the Rugged B to which mapping applies
  59.      * @param bodyConstraintWeight weight given to the central body distance constraint
  60.      * with respect to the LOS distance (between 0 and 1).
  61.      * <br>Weighting will be applied as follow :
  62.      * <ul>
  63.      *    <li>(1 - bodyConstraintWeight) for LOS distance weighting</li>
  64.      *    <li>bodyConstraintWeight for central body distance weighting</li>
  65.      * </ul>
  66.      */
  67.     public SensorToSensorMapping(final String sensorNameA, final String ruggedNameA,
  68.                                  final String sensorNameB, final String ruggedNameB,
  69.                                  final double bodyConstraintWeight) {

  70.         this.interMapping = new SensorMapping<>(sensorNameA, ruggedNameA);
  71.         this.sensorNameB = sensorNameB;
  72.         this.ruggedNameB = ruggedNameB;
  73.         this.losDistances = new ArrayList<>();
  74.         this.bodyDistances = new ArrayList<>();
  75.         this.bodyConstraintWeight = bodyConstraintWeight;
  76.     }

  77.     /** Build a new instance without central body constraints.
  78.      * @param sensorNameA name of the sensor A to which mapping applies
  79.      * @param ruggedNameA name of the Rugged A to which mapping applies
  80.      * @param sensorNameB name of the sensor B to which mapping applies
  81.      * @param ruggedNameB name of the Rugged B to which mapping applies
  82.      */
  83.     public SensorToSensorMapping(final String sensorNameA, final String ruggedNameA,
  84.                                  final String sensorNameB, final String ruggedNameB) {

  85.         this(sensorNameA, ruggedNameA, sensorNameB, ruggedNameB, 0.0);
  86.     }

  87.     /** Build a new instance with central body constraints  (with default Rugged names):
  88.      * we want to minimize the distance between pixel A and central body.
  89.      * @param sensorNameA name of the sensor A to which mapping applies
  90.      * @param sensorNameB name of the sensor B to which mapping applies
  91.      * @param bodyConstraintWeight weight given to the central body distance constraint
  92.      * with respect to the LOS distance (between 0 and 1).
  93.      * <br>Weighting will be applied as follow :
  94.      * <ul>
  95.      *    <li>(1 - bodyConstraintWeight) for LOS distance weighting</li>
  96.      *    <li>bodyConstraintWeight for central body distance weighting</li>
  97.      * </ul>
  98.      */
  99.     public SensorToSensorMapping(final String sensorNameA, final String sensorNameB,
  100.                                  final double bodyConstraintWeight) {

  101.         this(sensorNameA, RUGGED, sensorNameB, RUGGED, bodyConstraintWeight);
  102.     }

  103.     /** Get the name of the sensor B to which mapping applies.
  104.      * @return name of the sensor B to which mapping applies
  105.      */
  106.     public String getSensorNameB() {
  107.         return sensorNameB;
  108.     }

  109.     /** Get the name of the sensor A to which mapping applies.
  110.      * @return name of the sensor A to which mapping applies
  111.      */
  112.     public String getSensorNameA() {
  113.         return interMapping.getSensorName();
  114.     }

  115.     /** Get the name of the Rugged B to which mapping applies.
  116.      * @return name of the Rugged B to which mapping applies
  117.      */
  118.     public String getRuggedNameB() {
  119.         return ruggedNameB;
  120.     }

  121.     /** Get the name of the Rugged A to which mapping applies.
  122.      * @return name of the Rugged A to which mapping applies
  123.      */
  124.     public String getRuggedNameA() {
  125.         return interMapping.getRuggedName();
  126.     }

  127.     /** Get all the inter-mapping entries.
  128.      * @return an unmodifiable view of all mapping entries
  129.      */
  130.     public Set<Map.Entry<SensorPixel, SensorPixel>> getMapping() {
  131.         return interMapping.getMapping();
  132.     }

  133.     /** Get distances between lines of sight (from both view).
  134.      * @return the LOS distances
  135.      */
  136.     public  List<Double> getLosDistances() {
  137.         return losDistances;
  138.     }

  139.     /** Get distances between central body and pixel A (mapping with constraints).
  140.      * @return the central body distances
  141.      */
  142.     public List<Double> getBodyDistances() {
  143.         return bodyDistances;
  144.     }

  145.     /** Get the weight given to the central body distance constraint with respect to the LOS distance.
  146.      * @return the central body constraint weight
  147.      */
  148.     public double getBodyConstraintWeight() {
  149.         return bodyConstraintWeight;
  150.     }

  151.     /** Get distance between central body and pixel A, corresponding to the inter-mapping index.
  152.      * @param idx inter-mapping index
  153.      * @return the central body distances at index idx
  154.      */
  155.     public Double getBodyDistance(final int idx) {
  156.         return getBodyDistances().get(idx);
  157.     }

  158.     /** Get distance between LOS, corresponding to the inter-mapping index.
  159.      * @param idx inter-mapping index
  160.      * @return the LOS distance at index idx
  161.      */
  162.     public Double getLosDistance(final int idx) {
  163.         return getLosDistances().get(idx);
  164.     }

  165.     /** Add a mapping between two sensor pixels (A and B) and corresponding distance between the LOS.
  166.      * @param pixelA sensor pixel A
  167.      * @param pixelB sensor pixel B corresponding to the sensor pixel A (by direct then inverse location)
  168.      * @param losDistance distance between the two lines of sight
  169.      */
  170.     public void addMapping(final SensorPixel pixelA, final SensorPixel pixelB, final Double losDistance) {

  171.         interMapping.addMapping(pixelA, pixelB);
  172.         losDistances.add(losDistance);
  173.     }

  174.     /** Add a mapping between two sensor pixels (A and B) and corresponding distance between the LOS
  175.      *  and the central body distance constraint associated with pixel A.
  176.      * @param pixelA sensor pixel A
  177.      * @param pixelB sensor pixel B corresponding to the sensor pixel A (by direct then inverse location)
  178.      * @param losDistance distance between the two lines of sight
  179.      * @param bodyDistance elevation to central body
  180.      */
  181.     public void addMapping(final SensorPixel pixelA, final SensorPixel pixelB,
  182.                            final Double losDistance, final Double bodyDistance) {

  183.         interMapping.addMapping(pixelA, pixelB);
  184.         losDistances.add(losDistance);
  185.         bodyDistances.add(bodyDistance);
  186.     }

  187.     /** Set the central body constraint weight.
  188.      * @param bodyConstraintWeight the central body constraint weight to set
  189.      */
  190.     public void setBodyConstraintWeight(final double bodyConstraintWeight) {
  191.         this.bodyConstraintWeight = bodyConstraintWeight;
  192.     }
  193. }