Commit 51bc20aa authored by Jesse Mapel's avatar Jesse Mapel Committed by Jesse Mapel
Browse files

Added precision setting in locus methods

parent b8e7a387
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -276,12 +276,32 @@ csm::EcefLocus UsgsAstroFrameSensorModel::imageToProximateImagingLocus(
    const csm::ImageCoord &imagePt, const csm::EcefCoord &groundPt,
    double desiredPrecision, double *achievedPrecision,
    csm::WarningList *warnings) const {
  // Ignore the ground point?
  MESSAGE_LOG(
      "Computing imageToProximateImagingLocus(No ground) for point {}, {}, {}, "
      "with desired precision {}",
      imagePt.line, imagePt.samp, desiredPrecision);
  return imageToRemoteImagingLocus(imagePt);

  // The locus is a straight line so we can just use the remote locus to
  // get the direction
  csm::EcefLocus remoteLocus = imageToRemoteImagingLocus(
      imagePt, desiredPrecision, achievedPrecision, warnings);

  // Find the point on the locus closest to the input ground point
  // The direction vector is already normalized so we can skip a division
  csm::EcefVector positionToGround(
      groundPt.x - remoteLocus.point.x,
      groundPt.y - remoteLocus.point.y,
      groundPt.z - remoteLocus.point.z);
  csm::EcefVector positionToClosest =
      dot(remoteLocus.direction, positionToGround) * remoteLocus.direction;

  return csm::EcefLocus(
      remoteLocus.point.x + positionToClosest.x,
      remoteLocus.point.y + positionToClosest.y,
      remoteLocus.point.z + positionToClosest.z,
      remoteLocus.direction.x,
      remoteLocus.direction.y,
      remoteLocus.direction.z);
}

csm::EcefLocus UsgsAstroFrameSensorModel::imageToRemoteImagingLocus(
@@ -320,6 +340,10 @@ csm::EcefLocus UsgsAstroFrameSensorModel::imageToRemoteImagingLocus(
      sqrt(lookB[0] * lookB[0] + lookB[1] * lookB[1] + lookB[2] * lookB[2]);
  std::vector<double> lookBUnit{lookB[0] / mag, lookB[1] / mag, lookB[2] / mag};

  if (achievedPrecision) {
    *achievedPrecision = 0.0;
  }

  return csm::EcefLocus(m_currentParameterValue[0], m_currentParameterValue[1],
                        m_currentParameterValue[2], lookBUnit[0], lookBUnit[1],
                        lookBUnit[2]);
+4 −0
Original line number Diff line number Diff line
@@ -1010,6 +1010,10 @@ csm::EcefLocus UsgsAstroLsSensorModel::imageToRemoteImagingLocus(
  locus.direction.x = -locus.direction.x;
  locus.direction.y = -locus.direction.y;
  locus.direction.z = -locus.direction.z;

  if (achieved_precision) {
    *achieved_precision = 0.0;
  }
  return locus;
}

+8 −0
Original line number Diff line number Diff line
@@ -658,6 +658,10 @@ csm::EcefLocus UsgsAstroSarSensorModel::imageToProximateImagingLocus(
  }
  tangent = normalized(tangent);

  if (achievedPrecision) {
    *achievedPrecision = 0.0;
  }

  return csm::EcefLocus(closestVec.x, closestVec.y, closestVec.z, tangent.x,
                        tangent.y, tangent.z);
}
@@ -689,6 +693,10 @@ csm::EcefLocus UsgsAstroSarSensorModel::imageToRemoteImagingLocus(
  }
  tangent = normalized(tangent);

  if (achievedPrecision) {
    *achievedPrecision = 0.0;
  }

  return csm::EcefLocus(closestVec.x, closestVec.y, closestVec.z, tangent.x,
                        tangent.y, tangent.z);
}
+46 −0
Original line number Diff line number Diff line
@@ -130,6 +130,52 @@ TEST_F(OrbitalFrameSensorModel, GroundPartials) {
  EXPECT_DOUBLE_EQ(partials[5], 0.0);
}

TEST_F(OrbitalFrameSensorModel, ImageToRemoteImagingLocus) {
  csm::ImageCoord imagePt(8.0, 8.0);
  double precision;
  csm::WarningList warnings;
  csm::EcefLocus locus = sensorModel->imageToRemoteImagingLocus(
      imagePt, 0.001, &precision, &warnings);
  csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
  double lookX = groundPt.x - locus.point.x;
  double lookY = groundPt.y - locus.point.y;
  double lookZ = groundPt.z - locus.point.z;
  double lookMag = sqrt(lookX * lookX + lookY * lookY + lookZ * lookZ);
  lookX /= lookMag;
  lookY /= lookMag;
  lookZ /= lookMag;
  EXPECT_NEAR(locus.direction.x, lookX, 1e-10);
  EXPECT_NEAR(locus.direction.y, lookY, 1e-10);
  EXPECT_NEAR(locus.direction.z, lookZ, 1e-10);
  EXPECT_NEAR(locus.point.x, 1050000.0, 1e-10);
  EXPECT_NEAR(locus.point.y, 0.0, 1e-10);
  EXPECT_NEAR(locus.point.z, 0.0, 1e-10);
  EXPECT_LT(precision, 0.001);
  EXPECT_TRUE(warnings.empty());
}

TEST_F(OrbitalFrameSensorModel, ImageToProximateImagingLocus) {
  csm::ImageCoord imagePt(8.0, 8.0);
  csm::EcefCoord groundPt(1005000.0, 1000.0, 2000.0);
  double precision;
  csm::WarningList warnings;
  csm::EcefLocus remoteLocus = sensorModel->imageToRemoteImagingLocus(imagePt);
  csm::EcefLocus locus = sensorModel->imageToProximateImagingLocus(
      imagePt, groundPt, 0.001, &precision, &warnings);
  // The locus is a straight line so the proximate and remote should have the
  // same direction
  EXPECT_DOUBLE_EQ(locus.direction.x, remoteLocus.direction.x);
  EXPECT_DOUBLE_EQ(locus.direction.y, remoteLocus.direction.y);
  EXPECT_DOUBLE_EQ(locus.direction.z, remoteLocus.direction.z);
  // The locus is the X-axis so the closest point is just the X component of
  // the ground point.
  EXPECT_NEAR(locus.point.x, 1005000.0, 1e-10);
  EXPECT_NEAR(locus.point.y, 0.0, 1e-10);
  EXPECT_NEAR(locus.point.z, 0.0, 1e-10);
  EXPECT_LT(precision, 0.001);
  EXPECT_TRUE(warnings.empty());
}

// ****************************************************************************
//   Modified sensor model tests
// ****************************************************************************
+12 −3
Original line number Diff line number Diff line
@@ -55,9 +55,11 @@ TEST_F(ConstVelocityLineScanSensorModel, OffBody) {
TEST_F(ConstVelocityLineScanSensorModel, ProximateImageLocus) {
  csm::ImageCoord imagePt(8.0, 8.0);
  csm::EcefCoord groundPt(10, 2, 1);
  double precision;
  csm::WarningList warnings;
  csm::EcefLocus remoteLocus = sensorModel->imageToRemoteImagingLocus(imagePt);
  csm::EcefLocus locus =
      sensorModel->imageToProximateImagingLocus(imagePt, groundPt);
  csm::EcefLocus locus = sensorModel->imageToProximateImagingLocus(
      imagePt, groundPt, 0.001, &precision, &warnings);
  double locusToGroundX = locus.point.x - groundPt.x;
  double locusToGroundY = locus.point.y - groundPt.y;
  double locusToGroundZ = locus.point.z - groundPt.z;
@@ -68,11 +70,16 @@ TEST_F(ConstVelocityLineScanSensorModel, ProximateImageLocus) {
                  locusToGroundY * locus.direction.y +
                  locusToGroundZ * locus.direction.z,
              0.0, 1e-10);
  EXPECT_LT(precision, 0.001);
  EXPECT_TRUE(warnings.empty());
}

TEST_F(ConstVelocityLineScanSensorModel, RemoteImageLocus) {
  csm::ImageCoord imagePt(8.5, 8.0);
  csm::EcefLocus locus = sensorModel->imageToRemoteImagingLocus(imagePt);
  double precision;
  csm::WarningList warnings;
  csm::EcefLocus locus = sensorModel->imageToRemoteImagingLocus(
      imagePt, 0.001, &precision, &warnings);
  csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
  double lookX = groundPt.x - locus.point.x;
  double lookY = groundPt.y - locus.point.y;
@@ -87,6 +94,8 @@ TEST_F(ConstVelocityLineScanSensorModel, RemoteImageLocus) {
  EXPECT_NEAR(locus.point.x, 1000.0, 1e-10);
  EXPECT_NEAR(locus.point.y, 0.0, 1e-10);
  EXPECT_NEAR(locus.point.z, 0.0, 1e-10);
  EXPECT_LT(precision, 0.001);
  EXPECT_TRUE(warnings.empty());
}

TEST_F(ConstVelocityLineScanSensorModel, calculateAttitudeCorrection) {
Loading