Commit 26709615 authored by Jesse Mapel's avatar Jesse Mapel Committed by Kristin
Browse files

Example for LS testing (#171)

* Removed odd height gradient descent search from image to ground when not intersecting.

* Added first off body test.

* Added angular velocity line scan test

* Added failing, copy paste tests

* Commented out line scan pan tests until 0 velocity bug is addressed

* Removed extraneous focal epsilon from LS test ISDs
parent 4e46d45f
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -2213,19 +2213,6 @@ void UsgsAstroLsSensorModel::losEllipsoidIntersect(
   computeElevation(x, y, z, h, aPrec, desired_precision);
   slope = -1;

   while (MKTR > ktr && fabs(height - h) > desired_precision)
   {
      sprev = scale;
      scale += slope * (height - h);
      x = xc + scale * xl;
      y = yc + scale * yl;
      z = zc + scale * zl;
      hprev = h;
      computeElevation(x, y, z, h, aPrec, desired_precision);
      slope = (sprev - scale) / (hprev - h);
      ktr++;
   }

   achieved_precision = fabs(height - h);
}

+27 −0
Original line number Diff line number Diff line
@@ -171,6 +171,33 @@ class ConstVelocityLineScanSensorModel : public ::testing::Test {
      }
};

class ConstAngularVelocityLineScanSensorModel : public ::testing::Test {
   protected:
      csm::Isd isd;
      UsgsAstroLsSensorModel *sensorModel;

      void SetUp() override {
         sensorModel = NULL;

         isd.setFilename("data/constAngularVelocityLineScan.img");
         UsgsAstroPlugin cameraPlugin;

         csm::Model *model = cameraPlugin.constructModelFromISD(
               isd,
               "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL");
         sensorModel = dynamic_cast<UsgsAstroLsSensorModel *>(model);

         ASSERT_NE(sensorModel, nullptr);
      }

      void TearDown() override {
         if (sensorModel) {
            delete sensorModel;
            sensorModel = NULL;
         }
      }
};



#endif
+57 −3
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ TEST_F(ConstVelocityLineScanSensorModel, State) {
   // EXPECT_EQ(sensorModel->getModelState(), modelState);
}

// Fly by tests

TEST_F(ConstVelocityLineScanSensorModel, Center) {
   csm::ImageCoord imagePt(8.5, 8.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
@@ -45,9 +47,9 @@ TEST_F(ConstVelocityLineScanSensorModel, Inversion) {
TEST_F(ConstVelocityLineScanSensorModel, OffBody1) {
   csm::ImageCoord imagePt(4.5, 4.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
   // EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8);
   // EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8);
   EXPECT_NEAR(groundPt.x, 0.063995905, 1e-8);
   EXPECT_NEAR(groundPt.y, -7.999488033, 1e-8);
   EXPECT_NEAR(groundPt.z, 8, 1e-8);
}
TEST_F(ConstVelocityLineScanSensorModel, OffBody2) {
   csm::ImageCoord imagePt(4.5, 12.0);
@@ -72,3 +74,55 @@ TEST_F(ConstVelocityLineScanSensorModel, OffBody4) {
   // EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8);
   // EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8);
}

// Pan tests

TEST_F(ConstAngularVelocityLineScanSensorModel, Center) {
   csm::ImageCoord imagePt(8.5, 8.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_DOUBLE_EQ(groundPt.x, 10.0);
   // EXPECT_DOUBLE_EQ(groundPt.y, 0.0);
   // EXPECT_DOUBLE_EQ(groundPt.z, 0.0);

   std::cerr << sensorModel->getModelState() << std::endl;
}

TEST_F(ConstAngularVelocityLineScanSensorModel, Inversion) {
  csm::ImageCoord imagePt(8.5, 8);
  csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
  csm::ImageCoord imageReprojPt = sensorModel->groundToImage(groundPt);

  // EXPECT_DOUBLE_EQ(imagePt.line, imageReprojPt.line);
  // EXPECT_DOUBLE_EQ(imagePt.samp, imageReprojPt.samp);
}

TEST_F(ConstAngularVelocityLineScanSensorModel, OffBody1) {
   csm::ImageCoord imagePt(4.5, 4.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_NEAR(groundPt.x, 0.063995905, 1e-8);
   // EXPECT_NEAR(groundPt.y, -7.999488033, 1e-8);
   // EXPECT_NEAR(groundPt.z, 8, 1e-8);
}
TEST_F(ConstAngularVelocityLineScanSensorModel, OffBody2) {
   csm::ImageCoord imagePt(4.5, 12.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
   // EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8);
   // EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8);
}

TEST_F(ConstAngularVelocityLineScanSensorModel, OffBody3) {
   csm::ImageCoord imagePt(12.5, 4.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
   // EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8);
   // EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8);
}

TEST_F(ConstAngularVelocityLineScanSensorModel, OffBody4) {
   csm::ImageCoord imagePt(12.0, 12.0);
   csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0);
   // EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8);
   // EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8);
   // EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8);
}
+92 −0
Original line number Diff line number Diff line
{
  "name_model" : "USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL",
  "name_platform" : "TEST_PLATFORM",
  "name_sensor" : "TEST_SENSOR",
  "center_ephemeris_time": 1000.0,
  "starting_ephemeris_time": 999.2,
  "line_scan_rate": [
    [0.5, -0.8, 0.1]
  ],
  "detector_sample_summing": 1,
  "detector_line_summing": 1,
  "t0_ephemeris": -0.8,
  "dt_ephemeris": 0.2,
  "t0_quaternion": -0.8,
  "dt_quaternion": 0.2,
  "focal2pixel_lines": [0.0, 10.0, 0.0],
  "focal2pixel_samples": [0.0, 0.0, 10.0],
  "focal_length_model": {
    "focal_length": 50
  },
  "image_lines": 16,
  "image_samples": 16,
  "detector_center" : {
    "line" : 0.5,
    "sample" : 8.0
  },
  "interpolation_method": "lagrange",
  "optical_distortion": {
    "radial": {
      "coefficients": [0.0, 0.0, 0.0]
    }
  },
  "radii": {
    "semimajor": 10,
    "semiminor": 10,
    "unit":"m"
  },
  "reference_height": {
    "maxheight": 1,
    "minheight": -1,
    "unit": "m"
  },
  "sensor_position": {
    "unit": "m",
    "positions": [
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0],
      [1000.0, 0.0, 0.0]
    ],
    "velocities": [
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0]
    ]
  },
  "sensor_orientation": {
    "quaternions": [
      [0.0, -0.660435174378928, 0, 0.750883067090392],
      [0.0, -0.672364256957188, 0, 0.740220444169444],
      [0.0, -0.68412121795764, 0, 0.729368328857344],
      [0.0, -0.695703047662478, 0, 0.718329499236346],
      [0.0, -0.707106781186547, 0.0, 0.707106781186547],
      [0.0, -0.718329499236346, 0, 0.695703047662478],
      [0.0, -0.729368328857344, 0, 0.68412121795764],
      [0.0, -0.740220444169444, 0, 0.672364256957188],
      [0.0, -0.750883067090392, 0, 0.660435174378928]
    ]
  },
  "starting_detector_line": 0,
  "starting_detector_sample": 0,
  "sun_position": {
    "positions": [
      [100.0, 100.0, 0.0]
    ],
    "velocities": [
      [0.0, 0.0, 0.0]
    ],
    "unit": "m"
  }
}
+1 −2
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@
  "focal2pixel_lines": [0.0, 10.0, 0.0],
  "focal2pixel_samples": [0.0, 0.0, 10.0],
  "focal_length_model": {
    "focal_length": 50,
    "focal_epsilon": 1.0
    "focal_length": 50
  },
  "image_lines": 16,
  "image_samples": 16,