Skip to content

Commit

Permalink
Fixed seg fault when using an ISD without angular velocities (DOI-USG…
Browse files Browse the repository at this point in the history
…S#327)

* Updated embedded ALE to get orientations fix

* Added workaround for old ALE versions
  • Loading branch information
jessemapel authored Feb 12, 2021
1 parent d002088 commit b8e7a38
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ale
Submodule ale updated from 37bb56 to 7bd256
24 changes: 24 additions & 0 deletions src/UsgsAstroFrameSensorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,30 @@ std::string UsgsAstroFrameSensorModel::constructStateFromIsd(

// get sensor_orientation quaternion
ale::Orientations j2000_to_sensor = ale::getInstrumentPointing(parsedIsd);

// Work-around for issues in ALE <=0.8.5 where Orientations without angular
// velocities seg fault when you multiply them. This will make the angular
// velocities in the final Orientations dubious but they are not used
// in any calculations so this is okay.
if (j2000_to_sensor.getAngularVelocities().empty()) {
j2000_to_sensor = ale::Orientations(
j2000_to_sensor.getRotations(),
j2000_to_sensor.getTimes(),
std::vector<ale::Vec3d>(j2000_to_sensor.getTimes().size()),
j2000_to_sensor.getConstantRotation(),
j2000_to_sensor.getConstantFrames(),
j2000_to_sensor.getTimeDependentFrames());
}
if (j2000_to_target.getAngularVelocities().empty()) {
j2000_to_target = ale::Orientations(
j2000_to_target.getRotations(),
j2000_to_target.getTimes(),
std::vector<ale::Vec3d>(j2000_to_target.getTimes().size()),
j2000_to_target.getConstantRotation(),
j2000_to_target.getConstantFrames(),
j2000_to_target.getTimeDependentFrames());
}

ale::Orientations sensor_to_j2000 = j2000_to_sensor.inverse();
ale::Orientations sensor_to_target = j2000_to_target * sensor_to_j2000;
ephemTime = sensor_to_target.getTimes();
Expand Down
23 changes: 23 additions & 0 deletions src/UsgsAstroLsSensorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,29 @@ std::string UsgsAstroLsSensorModel::constructStateFromIsd(
state["m_velocities"] = velocities;
MESSAGE_LOG("m_velocities: {}", state["m_velocities"].dump())

// Work-around for issues in ALE <=0.8.5 where Orientations without angular
// velocities seg fault when you multiply them. This will make the angular
// velocities in the final Orientations dubious but they are not used
// in any calculations so this is okay.
if (j2000_to_sensor.getAngularVelocities().empty()) {
j2000_to_sensor = ale::Orientations(
j2000_to_sensor.getRotations(),
j2000_to_sensor.getTimes(),
std::vector<ale::Vec3d>(j2000_to_sensor.getTimes().size()),
j2000_to_sensor.getConstantRotation(),
j2000_to_sensor.getConstantFrames(),
j2000_to_sensor.getTimeDependentFrames());
}
if (j2000_to_target.getAngularVelocities().empty()) {
j2000_to_target = ale::Orientations(
j2000_to_target.getRotations(),
j2000_to_target.getTimes(),
std::vector<ale::Vec3d>(j2000_to_target.getTimes().size()),
j2000_to_target.getConstantRotation(),
j2000_to_target.getConstantFrames(),
j2000_to_target.getTimeDependentFrames());
}

ale::Orientations sensor_to_j2000 = j2000_to_sensor.inverse();
ale::Orientations sensor_to_target = j2000_to_target * sensor_to_j2000;
ephemTime = sensor_to_target.getTimes();
Expand Down

0 comments on commit b8e7a38

Please sign in to comment.