Skip to content

Commit

Permalink
fix: fix extra state being observed in integrating with conditions (#256
Browse files Browse the repository at this point in the history
)

* fix: fix extra state logging in integrating with conditions

* chore: add test
  • Loading branch information
vishwa2710 authored Oct 18, 2023
1 parent 901d005 commit 6c2058e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&

class_<Segment::Solution>(aModule, "SegmentSolution")

.def("__str__", &(shiftToString<Segment::Solution>))
.def("__repr__", &(shiftToString<Segment::Solution>))

.def_readonly("name", &Segment::Solution::name)
.def_readonly("dynamics", &Segment::Solution::dynamics)
.def_readonly("states", &Segment::Solution::states)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module

class_<Sequence::Solution>(aModule, "SequenceSolution")

.def("__str__", &(shiftToString<Sequence::Solution>))
.def("__repr__", &(shiftToString<Sequence::Solution>))

.def_readonly("segment_solutions", &Sequence::Solution::segmentSolutions)
.def_readonly("execution_is_complete", &Sequence::Solution::executionIsComplete)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ NumericalSolver::ConditionSolution NumericalSolver::integrateTime(
// initialize stepper
double currentTime = 0.0;
stepper.initialize(aState.accessCoordinates(), currentTime, signedTimeStep);
observeState(aState);

// do first step
double previousTime;
Expand Down
10 changes: 8 additions & 2 deletions test/OpenSpaceToolkit/Astrodynamics/Trajectory/Sequence.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using ostk::core::ctnr::Array;
using ostk::core::types::Shared;
using ostk::core::types::Size;
using ostk::core::types::Index;
using ostk::core::types::Real;

using ostk::math::geom::d3::objects::Composite;
Expand Down Expand Up @@ -430,11 +431,18 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Sequence, Solve_2)
EXPECT_EQ(solution.accessStartInstant(), Instant::J2000());
EXPECT_EQ(solution.accessEndInstant(), solution.segmentSolutions.accessLast().states.accessLast().accessInstant());

const Array<State> solutionStates = solution.getStates();

for (Index i = 1; i < solutionStates.getSize(); ++i)
{
EXPECT_TRUE(solutionStates[i].accessInstant() > solutionStates[i - 1].accessInstant());
}
EXPECT_DOUBLE_EQ(solution.getInitialMass().inKilograms(), mass + 100.0);
EXPECT_DOUBLE_EQ(
solution.getFinalMass().inKilograms(),
solution.segmentSolutions.accessLast().states.accessLast().accessCoordinates()[6]
);
EXPECT_EQ(solution.getPropagationDuration(), solution.accessEndInstant() - solution.accessStartInstant());

EXPECT_DOUBLE_EQ(
solution.computeDeltaMass().inKilograms(),
Expand All @@ -446,8 +454,6 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Sequence, Solve_2)
std::log(solution.getInitialMass().inKilograms() / solution.getFinalMass().inKilograms()),
1e-3
);

EXPECT_EQ(solution.getPropagationDuration(), solution.accessEndInstant() - solution.accessStartInstant());
}

TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Sequence, Print)
Expand Down

0 comments on commit 6c2058e

Please sign in to comment.