Skip to content

Commit

Permalink
feat: Tabulated dynamics for custom contribution profiles (#317)
Browse files Browse the repository at this point in the history
* feat: Tabulated dynamics for custom contribution profiles

* feat: add print and ostream

* test: add simple python tests

* chore: args type in python fixed

* feat: add access and get instants methods

* fix: attempt to fix eigen in the CI

* fix: use full path on load data files in test cpp

* feat: fix test

* feat: remove extra test

* feat: address remaining feedback

* feat: add frame getters

---------

Co-authored-by: Remy Derollez <remy@loftorbital.com>
  • Loading branch information
vishwa2710 and Derollez authored Jan 11, 2024
1 parent 2bb01de commit 7032be1
Show file tree
Hide file tree
Showing 12 changed files with 2,254 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/AtmosphericDrag.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/CentralBodyGravity.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/PositionDerivative.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/Tabulated.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/ThirdBodyGravity.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Dynamics/Thruster.cpp>

Expand Down Expand Up @@ -196,4 +197,5 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Dynamics(pybind11::module& aModule)
OpenSpaceToolkitAstrodynamicsPy_Dynamics_ThirdBodyGravity(dynamics);
OpenSpaceToolkitAstrodynamicsPy_Dynamics_AtmosphericDrag(dynamics);
OpenSpaceToolkitAstrodynamicsPy_Dynamics_Thruster(dynamics);
OpenSpaceToolkitAstrodynamicsPy_Dynamics_Tabulated(dynamics);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/// Apache License 2.0

#include <OpenSpaceToolkit/Astrodynamics/Dynamics/Tabulated.hpp>

inline void OpenSpaceToolkitAstrodynamicsPy_Dynamics_Tabulated(pybind11::module& aModule)
{
using namespace pybind11;

using ostk::core::types::Shared;
using ostk::core::ctnr::Array;

using ostk::math::object::MatrixXd;

using ostk::physics::time::Instant;
using ostk::physics::coord::Frame;

using ostk::astro::Dynamics;
using ostk::astro::dynamics::Tabulated;
using ostk::astro::trajectory::state::CoordinatesSubset;

{
class_<Tabulated, Dynamics, Shared<Tabulated>>(
aModule,
"Tabulated",
R"doc(
The tabulated dynamics.
Group:
dynamics
)doc"
)
.def(
init<
const Array<Instant>&,
const MatrixXd&,
const Array<Shared<const CoordinatesSubset>>&,
const Shared<const Frame>>(),
arg("instants"),
arg("contribution_profile"),
arg("coordinates_subsets"),
arg("frame"),
R"doc(
Constructor.
Args:
instants (list[Instant]): An array of instants.
contribution_profile (numpy.ndarray): A contribution profile.
coordinates_subsets (list[CoordinatesSubset]): An array of coordinates subsets related to the contribution profile.
frame (Frame): A frame.
)doc"
)

.def("__str__", &(shiftToString<Tabulated>))
.def("__repr__", &(shiftToString<Tabulated>))

.def(
"is_defined",
&Tabulated::isDefined,
R"doc(
Check if the tabulated dynamics is defined.
Returns:
bool: True if the tabulated dynamics is defined, False otherwise.
)doc"
)

.def(
"get_instants",
&Tabulated::getInstants,
R"doc(
Get the contribution instants.
Returns:
list[Instant]: The contribution instants.
)doc"
)

.def(
"get_contribution_profile",
&Tabulated::getContributionProfile,
R"doc(
Get the contribution profile.
Returns:
np.ndarray: The contribution profile.
)doc"
)

.def(
"get_frame",
&Tabulated::getFrame,
R"doc(
Get the reference frame.
Returns:
Frame: The reference frame.
)doc"
)

.def(
"compute_contribution",
&Tabulated::computeContribution,
arg("instant"),
arg("x"),
arg("frame"),
R"doc(
Compute the contribution from the contribution profile to the state vector.
Args:
instant (Instant): The instant of the state vector.
x (numpy.ndarray): The state vector.
frame (Frame): The reference frame.
Returns:
numpy.ndarray: The contribution from the contribution profile to the state vector.
)doc"
);
}
}
Loading

0 comments on commit 7032be1

Please sign in to comment.