Skip to content
Snippets Groups Projects
Commit 72e490a1 authored by Kristin's avatar Kristin Committed by Jesse Mapel
Browse files

Update State::getState() to handle the case of one state (like a framing camera.) (#364)

* Update format of range conversion coefficients isd output to include a separate list for times. Also update driver, test data, and remove unneeded semicolons

* Fix documentaion error

* fix other documentation error

* Added the case of 1 state (1 position, time, and maybe velocity) to getState()

* Roll back ale version # and accidental json submodule deletion
parent 28a4c5af
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,7 @@ namespace ale {
double time, int order=8);
/**
*@brief Interpolates the spacecrafts position along a path generated from a set of points,
*@brief Interpolates the spacecraft's position along a path generated from a set of points,
times, and a time of observation
*@param points A double vector of points
*@param times A double vector of times
......
......@@ -111,6 +111,7 @@ namespace ale {
State States::getState(double time, PositionInterpolation interp) const {
if (m_ephemTimes.size() > 1) {
int lowerBound = interpolationIndex(m_ephemTimes, time);
// try to copy the surrounding 8 points as that's the most possibly needed
int interpStart = std::max(0, lowerBound - 3);
......@@ -160,6 +161,17 @@ namespace ale {
}
return State(position, velocity);
}
else if (hasVelocity()) {
// Here we have: 1 state (1 time, 1 position, 1 velocity)
// x_f = x_i + v * (t_f - t-i)
Vec3d position = m_states[0].position + m_states[0].velocity*(time - m_ephemTimes[0]);
Vec3d velocity = m_states[0].velocity;
return State(position, velocity);
}
else { // Here we have: only 1 time and 1 state, so just return the only state.
return State(m_states[0]);
}
}
Vec3d States::getPosition(double time, PositionInterpolation interp) const {
......
......@@ -313,6 +313,40 @@ TEST(StatesTest, minimizeCache_false) {
}
TEST(StatesTest, OneStateNoVelocity) {
std::vector<double> ephemTimes = {0.0};
std::vector<Vec3d> positions = {Vec3d(2.0, 3.0, 4.0)};
States testState(ephemTimes, positions);
State result = testState.getState(1.0);
EXPECT_NEAR(result.position.x, 2.0, 1e-5);
EXPECT_NEAR(result.position.y, 3.0, 1e-4);
EXPECT_NEAR(result.position.z, 4.0, 1e-5);
}
TEST(StatesTest, OneStateWithVelocity) {
std::vector<double> ephemTimes = {1.0};
std::vector<Vec3d> positions = {Vec3d(2.0, 3.0, 4.0)};
std::vector<Vec3d> velocities = {Vec3d(5.0, 6.0, -1.0)};
States testState(ephemTimes, positions, velocities);
State result = testState.getState(2.0);
EXPECT_NEAR(result.position.x, 7.0, 1e-5);
EXPECT_NEAR(result.position.y, 9.0, 1e-4);
EXPECT_NEAR(result.position.z, 3.0, 1e-5);
EXPECT_NEAR(result.velocity.x, 5.0, 1e-6);
EXPECT_NEAR(result.velocity.y, 6.0, 1e-6);
EXPECT_NEAR(result.velocity.z, -1.0, 1e-6);
result = testState.getState(-1.0);
EXPECT_NEAR(result.position.x, -8.0, 1e-5);
EXPECT_NEAR(result.position.y, -9.0, 1e-4);
EXPECT_NEAR(result.position.z, 6.0, 1e-5);
EXPECT_NEAR(result.velocity.x, 5.0, 1e-6);
EXPECT_NEAR(result.velocity.y, 6.0, 1e-6);
EXPECT_NEAR(result.velocity.z, -1.0, 1e-6);
}
// This test checks to see if the minimized cache looks identical to ISIS's minimized cache for
// a Dawn IR image VIR_IR_1A_1_362681634_1 (located in dawnvir2isis's IR app test.)
// Values were obtained by adding strategic couts to SpicePosition.cpp, running spiceinit, and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment