Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
using namespace pybind11;

using ostk::core::container::Array;
using ostk::core::type::Integer;
using ostk::core::type::Shared;
using ostk::core::type::String;

Expand Down Expand Up @@ -216,6 +217,21 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
)doc"
)

.def(
"get_maneuver_intervals",
&Segment::Solution::getManeuverIntervals,
R"doc(
Get the intervals of maneuvers in the segment.

If maneuvers are already cached, returns their intervals directly.
Otherwise, extracts maneuvers using the GCRF frame and returns the intervals.

Returns:
list[Interval]: The list of maneuver intervals.

)doc"
)

.def(
"calculate_states_at",
&Segment::Solution::calculateStatesAt,
Expand Down Expand Up @@ -407,6 +423,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
arg("thruster_dynamics"),
arg("dynamics"),
arg("numerical_solver"),
arg_v("minimum_maneuver_duration", Duration::Undefined(), "Duration.undefined()"),
arg_v("minimum_maneuver_gap", Duration::Undefined(), "Duration.undefined()"),
arg_v("maximum_maneuver_count", Integer::Undefined(), "Integer.undefined()"),
R"doc(
Create a maneuver segment.

Expand All @@ -416,6 +435,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
thruster_dynamics (ThrusterDynamics): The thruster dynamics.
dynamics (Dynamics): The dynamics.
numerical_solver (NumericalSolver): The numerical solver.
minimum_maneuver_duration (Duration, optional): The minimum maneuver duration. Defaults to Duration.undefined().
minimum_maneuver_gap (Duration, optional): The minimum gap between maneuvers. Defaults to Duration.undefined().
maximum_maneuver_count (Integer, optional): The maximum maneuver count. Defaults to Integer.undefined().

Returns:
Segment: The maneuver segment.
Expand All @@ -432,6 +454,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
arg("numerical_solver"),
arg("local_orbital_frame_factory"),
arg_v("maximum_allowed_angular_offset", Angle::Undefined(), "Angle.Undefined()"),
arg_v("minimum_maneuver_duration", Duration::Undefined(), "Duration.undefined()"),
arg_v("minimum_maneuver_gap", Duration::Undefined(), "Duration.undefined()"),
arg_v("maximum_maneuver_count", Integer::Undefined(), "Integer.undefined()"),
R"doc(
Create a maneuvering segment that produces maneuvers with a constant direction in the local orbital frame.

Expand All @@ -450,6 +475,9 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Segment(pybind11::module&
numerical_solver (NumericalSolver): The numerical solver.
local_orbital_frame_factory (LocalOrbitalFrameFactory): The local orbital frame factory.
maximum_allowed_angular_offset (Angle, optional): The maximum allowed angular offset to consider (if any). Defaults to Angle.undefined().
minimum_maneuver_duration (Duration, optional): The minimum maneuver duration. Defaults to Duration.undefined().
minimum_maneuver_gap (Duration, optional): The minimum gap between maneuvers. Defaults to Duration.undefined().
maximum_maneuver_count (Integer, optional): The maximum maneuver count. Defaults to Integer.undefined().

Returns:
Segment: The maneuver segment.
Expand Down
44 changes: 41 additions & 3 deletions include/OpenSpaceToolkit/Astrodynamics/Trajectory/Segment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <OpenSpaceToolkit/Core/Container/Array.hpp>
#include <OpenSpaceToolkit/Core/Container/Map.hpp>
#include <OpenSpaceToolkit/Core/Container/Pair.hpp>
#include <OpenSpaceToolkit/Core/Type/Integer.hpp>
#include <OpenSpaceToolkit/Core/Type/Shared.hpp>
#include <OpenSpaceToolkit/Core/Type/String.hpp>
Expand All @@ -25,6 +26,8 @@
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/State.hpp>
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/State/NumericalSolver.hpp>

#include <OpenSpaceToolkit/Physics/Coordinate/Frame.hpp>

namespace ostk
{
namespace astrodynamics
Expand All @@ -34,12 +37,14 @@ namespace trajectory

using ostk::core::container::Array;
using ostk::core::container::Map;
using ostk::core::container::Pair;
using ostk::core::type::Integer;
using ostk::core::type::Shared;
using ostk::core::type::String;

using ostk::mathematics::object::MatrixXd;

using ostk::physics::coordinate::Frame;
using ostk::physics::time::Duration;
using ostk::physics::time::Instant;
using ostk::physics::time::Interval;
Expand Down Expand Up @@ -124,6 +129,11 @@ class Segment
/// @return Array of maneuvers
Array<flightManeuver> extractManeuvers(const Shared<const Frame>& aFrameSPtr) const;

/// @brief Get maneuver intervals
///
/// @return Array of intervals
Array<Interval> getManeuverIntervals() const;

/// @brief Calculate intermediate states at specified Instants using the provided Numerical Solver
///
/// @param aNumericalSolver a numerical solver to use for the propagation between states
Expand Down Expand Up @@ -178,6 +188,9 @@ class Segment
Array<State> states; // Array of states for the segment.
bool conditionIsSatisfied; // True if the event condition is satisfied.
Segment::Type segmentType; // Type of segment.

private:
mutable Pair<Shared<const Frame>, Array<flightManeuver>> cachedManeuvers_; // Cached maneuvers with frame
};

/// @brief Output stream operator
Expand Down Expand Up @@ -253,13 +266,19 @@ class Segment
/// @param aThrusterDynamics Dynamics for the thruster
/// @param aDynamicsArray Array of dynamics
/// @param aNumericalSolver Numerical solver
/// @param aMinimumManeuverDuration Minimum maneuver duration (optional)
/// @param aMinimumManeuverGap Minimum gap between maneuvers (optional)
/// @param aMaximumManeuverCount Maximum maneuver count (optional)
/// @return A Segment for maneuvering
static Segment Maneuver(
const String& aName,
const Shared<EventCondition>& anEventConditionSPtr,
const Shared<Thruster>& aThrusterDynamics,
const Array<Shared<Dynamics>>& aDynamicsArray,
const NumericalSolver& aNumericalSolver
const NumericalSolver& aNumericalSolver,
const Duration& aMinimumManeuverDuration = Duration::Undefined(),
const Duration& aMinimumManeuverGap = Duration::Undefined(),
const Integer& aMaximumManeuverCount = Integer::Undefined()
);

/// @brief Create a maneuvering segment that produces maneuvers with a constant direction in the local orbital
Expand All @@ -280,14 +299,20 @@ class Segment
/// @param aLocalOrbitalFrameFactory A local orbital frame factory.
/// @param aMaximumAllowedAngularOffset A maximum allowed angular offset to consider (if any). Defaults
/// to Undefined.
/// @param aMinimumManeuverDuration Minimum maneuver duration (optional)
/// @param aMinimumManeuverGap Minimum gap between maneuvers (optional)
/// @param aMaximumManeuverCount Maximum maneuver count (optional)
static Segment ConstantLocalOrbitalFrameDirectionManeuver(
const String& aName,
const Shared<EventCondition>& anEventConditionSPtr,
const Shared<Thruster>& aThrusterDynamics,
const Array<Shared<Dynamics>>& aDynamicsArray,
const NumericalSolver& aNumericalSolver,
const Shared<const LocalOrbitalFrameFactory>& aLocalOrbitalFrameFactory,
const Angle& aMaximumAllowedAngularOffset = Angle::Undefined()
const Angle& aMaximumAllowedAngularOffset = Angle::Undefined(),
const Duration& aMinimumManeuverDuration = Duration::Undefined(),
const Duration& aMinimumManeuverGap = Duration::Undefined(),
const Integer& aMaximumManeuverCount = Integer::Undefined()
);

private:
Expand All @@ -298,6 +323,9 @@ class Segment
NumericalSolver numericalSolver_;
Shared<const LocalOrbitalFrameFactory> constantManeuverDirectionLocalOrbitalFrameFactory_;
Angle constantManeuverDirectionMaximumAllowedAngularOffset_;
Duration minimumManeuverDuration_;
Duration minimumManeuverGap_;
Integer maximumManeuverCount_;

/// @brief Constructor
///
Expand All @@ -306,12 +334,22 @@ class Segment
/// @param anEventConditionSPtr The event condition
/// @param aDynamicsArray The dynamics array
/// @param aNumericalSolver The numerical solver
/// @param aLocalOrbitalFrameFactory Local orbital frame factory for constant maneuver direction (optional)
/// @param aMaximumAllowedAngularOffset Maximum allowed angular offset for constant maneuver direction (optional)
/// @param aMinimumManeuverDuration Minimum maneuver duration (optional)
/// @param aMinimumManeuverGap Minimum gap between maneuvers (optional)
/// @param aMaximumManeuverCount Maximum maneuver count (optional)
Segment(
const String& aName,
const Type& aType,
const Shared<EventCondition>& anEventConditionSPtr,
const Array<Shared<Dynamics>>& aDynamicsArray,
const NumericalSolver& aNumericalSolver
const NumericalSolver& aNumericalSolver,
const Shared<const LocalOrbitalFrameFactory>& aLocalOrbitalFrameFactory = nullptr,
const Angle& aMaximumAllowedAngularOffset = Angle::Undefined(),
const Duration& aMinimumManeuverDuration = Duration::Undefined(),
const Duration& aMinimumManeuverGap = Duration::Undefined(),
const Integer& aMaximumManeuverCount = Integer::Undefined()
);

/// @brief Solve the segment using the given dynamics and event condition
Expand Down
16 changes: 16 additions & 0 deletions include/OpenSpaceToolkit/Astrodynamics/Trajectory/Sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ class Sequence
Array<Shared<Dynamics>> dynamics_;
Duration segmentPropagationDurationLimit_;
Duration minimumManeuverDuration_;

/// @brief Process a single segment and add it to the solution array
///
/// @param aSegment The segment to process
/// @param aSegmentSolutions Array to add the segment solution to
/// @param anInitialState The initial state for the segment
/// @param aSegmentPropagationLimit The propagation duration limit for this segment
/// @param aSegmentNameSuffix Suffix to add to the segment solution name
/// @return True if segment was processed successfully, false if segment condition not satisfied
bool solve_(
const Segment& aSegment,
Array<Segment::Solution>& aSegmentSolutions,
State& anInitialState,
const Duration& aSegmentPropagationLimit,
const String& aSegmentNameSuffix
) const;
Comment on lines +246 to +252
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Missing include for String (compile-time break).

solve_ takes const String& aSegmentNameSuffix but this header doesn’t include OpenSpaceToolkit/Core/Type/String.hpp. Add it to avoid relying on transitive includes.

Apply this diff near the top includes:

 #include <OpenSpaceToolkit/Core/Container/Array.hpp>
 #include <OpenSpaceToolkit/Core/Type/Size.hpp>
+#include <OpenSpaceToolkit/Core/Type/String.hpp>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In include/OpenSpaceToolkit/Astrodynamics/Trajectory/Sequence.hpp around lines
246 to 252, the declaration of solve_ uses const String& aSegmentNameSuffix but
this header doesn't include OpenSpaceToolkit/Core/Type/String.hpp; add the
include for OpenSpaceToolkit/Core/Type/String.hpp near the top of the include
block so the String type is declared explicitly (avoid relying on transitive
includes).

};

} // namespace trajectory
Expand Down
Loading
Loading