From 446559510632e982e6149f1baa679eae926792e7 Mon Sep 17 00:00:00 2001 From: Vishwa Shah Date: Fri, 6 Oct 2023 06:06:20 -0700 Subject: [PATCH] feat: add bindings for ConstantThrust static constructors (#232) --- .../Dynamics/Thruster/ConstantThrust.cpp | 17 +++++++++++++--- .../dynamics/thruster/test_constant_thrust.py | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Dynamics/Thruster/ConstantThrust.cpp b/bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Dynamics/Thruster/ConstantThrust.cpp index 116f6be20..67a37a7aa 100644 --- a/bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Dynamics/Thruster/ConstantThrust.cpp +++ b/bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Dynamics/Thruster/ConstantThrust.cpp @@ -9,12 +9,13 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Dynamics_Thruster_ConstantThrust(pyb using ostk::core::types::String; using ostk::core::types::Shared; - using ostk::astro::flight::system::SatelliteSystem; - using ostk::astro::trajectory::LocalOrbitalFrameDirection; + using ostk::physics::coord::Frame; using ostk::astro::Dynamics; + using ostk::astro::trajectory::LocalOrbitalFrameDirection; using ostk::astro::dynamics::Thruster; using ostk::astro::dynamics::thruster::ConstantThrust; + using ostk::astro::flight::system::SatelliteSystem; { class_>(aModule, "ConstantThrust") @@ -36,6 +37,16 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Dynamics_Thruster_ConstantThrust(pyb .def("get_read_coordinates_subsets", &ConstantThrust::getReadCoordinatesSubsets) .def("get_write_coordinates_subsets", &ConstantThrust::getWriteCoordinatesSubsets) - .def("compute_contribution", &ConstantThrust::computeContribution, arg("instant"), arg("x"), arg("frame")); + .def("compute_contribution", &ConstantThrust::computeContribution, arg("instant"), arg("x"), arg("frame")) + + .def_static( + "intrack", + &ConstantThrust::Intrack, + arg("satellite_system"), + arg("velocity_direction") = true, + arg("frame") = Frame::GCRF() + ) + + ; } } diff --git a/bindings/python/test/dynamics/thruster/test_constant_thrust.py b/bindings/python/test/dynamics/thruster/test_constant_thrust.py index 7165ab79e..1c9b1002a 100644 --- a/bindings/python/test/dynamics/thruster/test_constant_thrust.py +++ b/bindings/python/test/dynamics/thruster/test_constant_thrust.py @@ -110,6 +110,26 @@ def test_constructors(self, dynamics: ConstantThrust): def test_getters(self, dynamics: ConstantThrust): assert dynamics.get_local_thrust_direction() is not None + def test_static_constructors(self, satellite_system: SatelliteSystem, frame: Frame): + assert ConstantThrust.intrack(satellite_system=satellite_system) is not None + + assert ( + ConstantThrust.intrack( + satellite_system=satellite_system, + velocity_direction=False, + ) + is not None + ) + + assert ( + ConstantThrust.intrack( + satellite_system=satellite_system, + velocity_direction=True, + frame=frame, + ) + is not None + ) + def test_compute_contribution_success(self, dynamics: ConstantThrust, state: State): contribution = dynamics.compute_contribution( state.get_instant(), state.get_coordinates(), state.get_frame()