From 267096159d95accee41c13c46cfa6237589c7e9a Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jam826@nau.edu> Date: Thu, 14 Feb 2019 17:13:04 -0700 Subject: [PATCH] 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 --- src/UsgsAstroLsSensorModel.cpp | 13 --- tests/Fixtures.h | 27 ++++++ tests/LineScanCameraTests.cpp | 60 ++++++++++++- tests/data/constAngularVelocityLineScan.json | 92 ++++++++++++++++++++ tests/data/constVelocityLineScan.json | 3 +- 5 files changed, 177 insertions(+), 18 deletions(-) create mode 100644 tests/data/constAngularVelocityLineScan.json diff --git a/src/UsgsAstroLsSensorModel.cpp b/src/UsgsAstroLsSensorModel.cpp index 7bb0e8a..c476c4c 100644 --- a/src/UsgsAstroLsSensorModel.cpp +++ b/src/UsgsAstroLsSensorModel.cpp @@ -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); } diff --git a/tests/Fixtures.h b/tests/Fixtures.h index e2a95b2..fc61f71 100644 --- a/tests/Fixtures.h +++ b/tests/Fixtures.h @@ -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 diff --git a/tests/LineScanCameraTests.cpp b/tests/LineScanCameraTests.cpp index 3e809a1..025df5c 100644 --- a/tests/LineScanCameraTests.cpp +++ b/tests/LineScanCameraTests.cpp @@ -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); +} diff --git a/tests/data/constAngularVelocityLineScan.json b/tests/data/constAngularVelocityLineScan.json new file mode 100644 index 0000000..cf467fd --- /dev/null +++ b/tests/data/constAngularVelocityLineScan.json @@ -0,0 +1,92 @@ +{ + "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" + } +} diff --git a/tests/data/constVelocityLineScan.json b/tests/data/constVelocityLineScan.json index 4c1b74e..142a4b6 100644 --- a/tests/data/constVelocityLineScan.json +++ b/tests/data/constVelocityLineScan.json @@ -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, -- GitLab