Skip to content

Commit

Permalink
fix: fix missing binding for Segment::Solution (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 authored Oct 17, 2023
1 parent d4aae19 commit 8907f7d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&

.def("get_initial_mass", &Segment::Solution::getInitialMass)
.def("get_final_mass", &Segment::Solution::getFinalMass)
.def("get_propagation_duration", &Segment::Solution::getPropagationDuration)

.def("compute_delta_mass", &Segment::Solution::computeDeltaMass)
.def("compute_delta_v", &Segment::Solution::computeDeltaV, arg("specific_impulse"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Segment

Mass getInitialMass() const;
Mass getFinalMass() const;
Duration getPropagationDuration() const;

Real computeDeltaV(const Real& aSpecificImpulse) const;
Mass computeDeltaMass() const;
Expand Down
5 changes: 5 additions & 0 deletions src/OpenSpaceToolkit/Astrodynamics/Trajectory/Segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Mass Segment::Solution::getInitialMass() const
return Mass::Kilograms(states.accessFirst().extractCoordinates(CoordinatesSubset::Mass())[0]);
}

Duration Segment::Solution::getPropagationDuration() const
{
return accessEndInstant() - accessStartInstant();
}

Mass Segment::Solution::getFinalMass() const
{
if (states.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Segment, SegmentSolution_Getter

EXPECT_THROW(segmentSolution.getInitialMass(), ostk::core::error::RuntimeError);
EXPECT_THROW(segmentSolution.getFinalMass(), ostk::core::error::RuntimeError);
EXPECT_THROW(segmentSolution.getPropagationDuration(), ostk::core::error::RuntimeError);
}

{
Expand All @@ -154,6 +155,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Segment, SegmentSolution_Getter

EXPECT_DOUBLE_EQ(200.0, segmentSolution.getInitialMass().inKilograms());
EXPECT_DOUBLE_EQ(180.0, segmentSolution.getFinalMass().inKilograms());
EXPECT_DOUBLE_EQ(0.0, segmentSolution.getPropagationDuration().inSeconds());
}
}

Expand Down

0 comments on commit 8907f7d

Please sign in to comment.