Skip to content

Commit 2027395

Browse files
author
Pau Hebrero
committed
refactor: apply MR suggestions
1 parent c138ea8 commit 2027395

File tree

9 files changed

+136
-137
lines changed

9 files changed

+136
-137
lines changed

bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Flight/Profile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Flight_Profile(pybind11::module& aMo
191191
Constructor.
192192
193193
Args:
194-
orientation_profile (list[Tuple[Instant, Vector3d]]): The orientation profile.
194+
orientation_profile (list[tuple[Instant, Vector3d]]): The orientation profile.
195195
axis (Profile.Axis): The axis.
196196
anti_direction (bool): True if the direction is flipped, False otherwise. Defaults to False.
197197
)doc",

bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <OpenSpaceToolkit/Astrodynamics/GuidanceLaw.hpp>
44

55
#include <OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/ConstantThrust.cpp>
6+
#include <OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/HeterogeneousGuidanceLaw.cpp>
67
#include <OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/QLaw.cpp>
7-
#include <OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/SequentialGuidanceLaw.cpp>
88

99
using namespace pybind11;
1010

@@ -121,5 +121,5 @@ void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw(pybind11::module& aModule)
121121
// Add objects to "guidance_law" submodule
122122
OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_ConstantThrust(guidance_law);
123123
OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_QLaw(guidance_law);
124-
OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(guidance_law);
124+
OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_HeterogeneousGuidanceLaw(guidance_law);
125125
}

bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/SequentialGuidanceLaw.cpp renamed to bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/GuidanceLaw/HeterogeneousGuidanceLaw.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/// Apache License 2.0
22

3-
#include <OpenSpaceToolkit/Astrodynamics/GuidanceLaw/SequentialGuidanceLaw.hpp>
3+
#include <OpenSpaceToolkit/Astrodynamics/GuidanceLaw/HeterogeneousGuidanceLaw.hpp>
44

55
using namespace pybind11;
66

77
using ostk::core::container::Array;
8-
using ostk::core::type::Real;
8+
using ostk::core::container::Pair;
99
using ostk::core::type::Shared;
10-
using ostk::core::type::String;
1110

1211
using ostk::mathematics::object::Vector3d;
1312

@@ -16,13 +15,13 @@ using ostk::physics::time::Instant;
1615
using ostk::physics::time::Interval;
1716

1817
using ostk::astrodynamics::GuidanceLaw;
19-
using ostk::astrodynamics::guidancelaw::SequentialGuidanceLaw;
18+
using ostk::astrodynamics::guidancelaw::HeterogeneousGuidanceLaw;
2019

21-
inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(pybind11::module& aModule)
20+
inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_HeterogeneousGuidanceLaw(pybind11::module& aModule)
2221
{
23-
class_<SequentialGuidanceLaw, GuidanceLaw, Shared<SequentialGuidanceLaw>>(
22+
class_<HeterogeneousGuidanceLaw, GuidanceLaw, Shared<HeterogeneousGuidanceLaw>>(
2423
aModule,
25-
"SequentialGuidanceLaw",
24+
"HeterogeneousGuidanceLaw",
2625
R"doc(
2726
A guidance law that sequences multiple guidance laws over specific time intervals.
2827
@@ -34,13 +33,13 @@ inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(py
3433
)
3534

3635
.def(
37-
init<const Array<Tuple<Shared<GuidanceLaw>, Interval>>&>(),
38-
arg_v("guidance_laws_with_intervals", Array<Tuple<Shared<GuidanceLaw>, Interval>>::Empty(), "[]"),
36+
init<const Array<Pair<Shared<GuidanceLaw>, Interval>>&>(),
37+
arg_v("guidance_laws_with_intervals", Array<Pair<Shared<GuidanceLaw>, Interval>>::Empty(), "[]"),
3938
R"doc(
4039
Constructor.
4140
4241
Args:
43-
guidance_laws_with_intervals (List[Tuple[GuidanceLaw, Interval]], optional): Array of tuples containing the guidance laws and their corresponding intervals. Defaults to empty array.
42+
guidance_laws_with_intervals (list[tuple[GuidanceLaw, Interval]], optional): Array of tuples containing the guidance laws and their corresponding intervals. Defaults to empty array.
4443
4544
Raises:
4645
RuntimeError: If any interval is undefined, if the guidance law is null or if the interval intersects with an existing interval.
@@ -49,18 +48,18 @@ inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(py
4948

5049
.def(
5150
"get_guidance_laws_with_intervals",
52-
&SequentialGuidanceLaw::getGuidanceLawsWithIntervals,
51+
&HeterogeneousGuidanceLaw::getGuidanceLawsWithIntervals,
5352
R"doc(
5453
Get the guidance laws with their corresponding intervals.
5554
5655
Returns:
57-
List[Tuple[GuidanceLaw, Interval]]: Array of tuples containing the guidance laws and their corresponding intervals.
56+
list[tuple[GuidanceLaw, Interval]]: Array of tuples containing the guidance laws and their corresponding intervals.
5857
)doc"
5958
)
6059

6160
.def(
6261
"add_guidance_law",
63-
&SequentialGuidanceLaw::addGuidanceLaw,
62+
&HeterogeneousGuidanceLaw::addGuidanceLaw,
6463
arg("guidance_law"),
6564
arg("interval"),
6665
R"doc(
@@ -77,7 +76,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(py
7776

7877
.def(
7978
"calculate_thrust_acceleration_at",
80-
&SequentialGuidanceLaw::calculateThrustAccelerationAt,
79+
&HeterogeneousGuidanceLaw::calculateThrustAccelerationAt,
8180
arg("instant"),
8281
arg("position_coordinates"),
8382
arg("velocity_coordinates"),
@@ -98,8 +97,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_GuidanceLaw_SequentialGuidanceLaw(py
9897
)doc"
9998
)
10099

101-
.def("__str__", &(shiftToString<SequentialGuidanceLaw>))
102-
.def("__repr__", &(shiftToString<SequentialGuidanceLaw>))
100+
.def("__str__", &(shiftToString<HeterogeneousGuidanceLaw>))
101+
.def("__repr__", &(shiftToString<HeterogeneousGuidanceLaw>))
103102

104103
;
105104
}

bindings/python/test/guidance_law/test_sequential_guidance_law.py renamed to bindings/python/test/guidance_law/test_heterogeneous_guidance_law.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ostk.physics.time import Duration
1010
from ostk.physics.time import Interval
1111
from ostk.astrodynamics import GuidanceLaw
12-
from ostk.astrodynamics.guidance_law import SequentialGuidanceLaw
12+
from ostk.astrodynamics.guidance_law import HeterogeneousGuidanceLaw
1313

1414

1515
@pytest.fixture
@@ -75,37 +75,37 @@ def calculate_thrust_acceleration_at(
7575

7676

7777
@pytest.fixture
78-
def sequential_guidance_law(
78+
def heterogeneous_guidance_law(
7979
interval_1: Interval,
8080
guidance_law_1: GuidanceLaw,
8181
interval_2: Interval,
8282
guidance_law_2: GuidanceLaw,
83-
) -> SequentialGuidanceLaw:
84-
return SequentialGuidanceLaw(
83+
) -> HeterogeneousGuidanceLaw:
84+
return HeterogeneousGuidanceLaw(
8585
guidance_laws_with_intervals=[
8686
(guidance_law_1, interval_1),
8787
(guidance_law_2, interval_2),
8888
],
8989
)
9090

9191

92-
class TestSequentialGuidanceLaw:
92+
class TestHeterogeneousGuidanceLaw:
9393
def test_constructor_and_getters(
9494
self,
9595
interval_1: Interval,
9696
guidance_law_1: GuidanceLaw,
9797
interval_2: Interval,
9898
guidance_law_2: GuidanceLaw,
9999
):
100-
sequential_guidance_law = SequentialGuidanceLaw(
100+
heterogeneous_guidance_law = HeterogeneousGuidanceLaw(
101101
guidance_laws_with_intervals=[
102102
(guidance_law_1, interval_1),
103103
(guidance_law_2, interval_2),
104104
],
105105
)
106-
assert sequential_guidance_law is not None
107-
assert isinstance(sequential_guidance_law, SequentialGuidanceLaw)
108-
assert sequential_guidance_law.get_guidance_laws_with_intervals() == [
106+
assert heterogeneous_guidance_law is not None
107+
assert isinstance(heterogeneous_guidance_law, HeterogeneousGuidanceLaw)
108+
assert heterogeneous_guidance_law.get_guidance_laws_with_intervals() == [
109109
(guidance_law_1, interval_1),
110110
(guidance_law_2, interval_2),
111111
]
@@ -117,18 +117,18 @@ def test_add_guidance_law(
117117
interval_2: Interval,
118118
guidance_law_2: GuidanceLaw,
119119
):
120-
sequential_guidance_law = SequentialGuidanceLaw()
120+
heterogeneous_guidance_law = HeterogeneousGuidanceLaw()
121121

122-
assert isinstance(sequential_guidance_law, SequentialGuidanceLaw)
123-
assert sequential_guidance_law.get_guidance_laws_with_intervals() == []
122+
assert isinstance(heterogeneous_guidance_law, HeterogeneousGuidanceLaw)
123+
assert heterogeneous_guidance_law.get_guidance_laws_with_intervals() == []
124124

125-
sequential_guidance_law.add_guidance_law(guidance_law_1, interval_1)
126-
assert sequential_guidance_law.get_guidance_laws_with_intervals() == [
125+
heterogeneous_guidance_law.add_guidance_law(guidance_law_1, interval_1)
126+
assert heterogeneous_guidance_law.get_guidance_laws_with_intervals() == [
127127
(guidance_law_1, interval_1),
128128
]
129129

130-
sequential_guidance_law.add_guidance_law(guidance_law_2, interval_2)
131-
assert sequential_guidance_law.get_guidance_laws_with_intervals() == [
130+
heterogeneous_guidance_law.add_guidance_law(guidance_law_2, interval_2)
131+
assert heterogeneous_guidance_law.get_guidance_laws_with_intervals() == [
132132
(guidance_law_1, interval_1),
133133
(guidance_law_2, interval_2),
134134
]
@@ -148,12 +148,12 @@ def test_add_guidance_law(
148148
)
149149
def test_calculate_thrust_acceleration_at(
150150
self,
151-
sequential_guidance_law: SequentialGuidanceLaw,
151+
heterogeneous_guidance_law: HeterogeneousGuidanceLaw,
152152
instant: Instant,
153153
expected_thrust_acceleration: np.array,
154154
):
155155
assert np.array_equal(
156-
sequential_guidance_law.calculate_thrust_acceleration_at(
156+
heterogeneous_guidance_law.calculate_thrust_acceleration_at(
157157
instant=instant,
158158
position_coordinates=np.array([0.0, 0.0, 0.0]),
159159
velocity_coordinates=np.array([0.0, 0.0, 0.0]),

include/OpenSpaceToolkit/Astrodynamics/GuidanceLaw/SequentialGuidanceLaw.hpp renamed to include/OpenSpaceToolkit/Astrodynamics/GuidanceLaw/HeterogeneousGuidanceLaw.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/// Apache License 2.0
22

3-
#ifndef __OpenSpaceToolkit_Astrodynamics_GuidanceLaw_SequentialGuidanceLaw__
4-
#define __OpenSpaceToolkit_Astrodynamics_GuidanceLaw_SequentialGuidanceLaw__
3+
#ifndef __OpenSpaceToolkit_Astrodynamics_GuidanceLaw_HeterogeneousGuidanceLaw__
4+
#define __OpenSpaceToolkit_Astrodynamics_GuidanceLaw_HeterogeneousGuidanceLaw__
55

66
#include <OpenSpaceToolkit/Core/Container/Array.hpp>
7-
#include <OpenSpaceToolkit/Core/Container/Tuple.hpp>
7+
#include <OpenSpaceToolkit/Core/Container/Pair.hpp>
88
#include <OpenSpaceToolkit/Core/Type/Real.hpp>
99
#include <OpenSpaceToolkit/Core/Type/Shared.hpp>
1010

@@ -23,7 +23,7 @@ namespace guidancelaw
2323
{
2424

2525
using ostk::core::container::Array;
26-
using ostk::core::container::Tuple;
26+
using ostk::core::container::Pair;
2727
using ostk::core::type::Real;
2828
using ostk::core::type::Shared;
2929

@@ -33,27 +33,27 @@ using ostk::physics::coordinate::Frame;
3333
using ostk::physics::time::Instant;
3434
using ostk::physics::time::Interval;
3535

36-
/// @brief The Sequential Guidance Law encompasses a sequence of one or more guidance laws to be used over specific
37-
/// time intervals.
36+
/// @brief The Heterogeneous Guidance Law encompasses a sequence of one or more guidance laws to be used over
37+
/// specific time intervals.
3838
/// At each point in time, the applicable guidance law is selected and used to calculate the thrust acceleration.
3939
/// Guidance laws don't need to be contiguous, and can be added in any order. If the instant does not fall within any
4040
/// of the intervals, the thrust acceleration is zero. The guidance law intervals must not intersect each other.
41-
class SequentialGuidanceLaw : public GuidanceLaw
41+
class HeterogeneousGuidanceLaw : public GuidanceLaw
4242
{
4343
public:
4444
/// @brief Default constructor
4545
///
4646
/// @param aGuidanceLawWithIntervalArray Array of tuples containing the guidance law and their corresponding
4747
/// interval. Defaults to empty.
48-
SequentialGuidanceLaw(
49-
const Array<Tuple<Shared<GuidanceLaw>, Interval>>& aGuidanceLawWithIntervalArray =
50-
Array<Tuple<Shared<GuidanceLaw>, Interval>>::Empty()
48+
HeterogeneousGuidanceLaw(
49+
const Array<Pair<Shared<GuidanceLaw>, Interval>>& aGuidanceLawWithIntervalArray =
50+
Array<Pair<Shared<GuidanceLaw>, Interval>>::Empty()
5151
);
5252

5353
/// @brief Get guidance laws with their corresponding intervals
5454
///
5555
/// @return Array of tuples containing the guidance laws and their corresponding intervals
56-
Array<Tuple<Shared<GuidanceLaw>, Interval>> getGuidanceLawsWithIntervals() const;
56+
Array<Pair<Shared<GuidanceLaw>, Interval>> getGuidanceLawsWithIntervals() const;
5757

5858
/// @brief Add a guidance law with its corresponding interval
5959
///

src/OpenSpaceToolkit/Astrodynamics/GuidanceLaw/SequentialGuidanceLaw.cpp renamed to src/OpenSpaceToolkit/Astrodynamics/GuidanceLaw/HeterogeneousGuidanceLaw.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <OpenSpaceToolkit/Core/Type/Size.hpp>
55
#include <OpenSpaceToolkit/Core/Utility.hpp>
66

7-
#include <OpenSpaceToolkit/Astrodynamics/GuidanceLaw/SequentialGuidanceLaw.hpp>
7+
#include <OpenSpaceToolkit/Astrodynamics/GuidanceLaw/HeterogeneousGuidanceLaw.hpp>
88

99
namespace ostk
1010
{
@@ -14,7 +14,7 @@ namespace guidancelaw
1414
{
1515

1616
using ostk::core::container::Array;
17-
using ostk::core::container::Tuple;
17+
using ostk::core::container::Pair;
1818
using ostk::core::type::Real;
1919
using ostk::core::type::Shared;
2020
using ostk::core::type::Size;
@@ -27,31 +27,31 @@ using ostk::physics::time::Interval;
2727

2828
using ostk::astrodynamics::GuidanceLaw;
2929

30-
SequentialGuidanceLaw::SequentialGuidanceLaw(
31-
const Array<Tuple<Shared<GuidanceLaw>, Interval>>& aGuidanceLawWithIntervalArray
30+
HeterogeneousGuidanceLaw::HeterogeneousGuidanceLaw(
31+
const Array<Pair<Shared<GuidanceLaw>, Interval>>& aGuidanceLawWithIntervalArray
3232
)
33-
: GuidanceLaw("Sequential Guidance Law"),
33+
: GuidanceLaw("Heterogeneous Guidance Law"),
3434
intervals_(Array<Interval>::Empty()),
3535
guidanceLaws_(Array<Shared<GuidanceLaw>>::Empty())
3636
{
37-
for (const Tuple<Shared<GuidanceLaw>, Interval>& guidanceLawWithInterval : aGuidanceLawWithIntervalArray)
37+
for (const Pair<Shared<GuidanceLaw>, Interval>& guidanceLawWithInterval : aGuidanceLawWithIntervalArray)
3838
{
39-
this->addGuidanceLaw(std::get<0>(guidanceLawWithInterval), std::get<1>(guidanceLawWithInterval));
39+
this->addGuidanceLaw(guidanceLawWithInterval.first, guidanceLawWithInterval.second);
4040
}
4141
}
4242

43-
Array<Tuple<Shared<GuidanceLaw>, Interval>> SequentialGuidanceLaw::getGuidanceLawsWithIntervals() const
43+
Array<Pair<Shared<GuidanceLaw>, Interval>> HeterogeneousGuidanceLaw::getGuidanceLawsWithIntervals() const
4444
{
45-
Array<Tuple<Shared<GuidanceLaw>, Interval>> guidanceLawsWithIntervals =
46-
Array<Tuple<Shared<GuidanceLaw>, Interval>>::Empty();
45+
Array<Pair<Shared<GuidanceLaw>, Interval>> guidanceLawsWithIntervals =
46+
Array<Pair<Shared<GuidanceLaw>, Interval>>::Empty();
4747
for (Size i = 0; i < intervals_.getSize(); ++i)
4848
{
49-
guidanceLawsWithIntervals.add(Tuple<Shared<GuidanceLaw>, Interval>(guidanceLaws_[i], intervals_[i]));
49+
guidanceLawsWithIntervals.add(Pair<Shared<GuidanceLaw>, Interval>(guidanceLaws_[i], intervals_[i]));
5050
}
5151
return guidanceLawsWithIntervals;
5252
}
5353

54-
void SequentialGuidanceLaw::addGuidanceLaw(const Shared<GuidanceLaw>& aGuidanceLawSPtr, const Interval& anInterval)
54+
void HeterogeneousGuidanceLaw::addGuidanceLaw(const Shared<GuidanceLaw>& aGuidanceLawSPtr, const Interval& anInterval)
5555
{
5656
if (aGuidanceLawSPtr == nullptr)
5757
{
@@ -77,7 +77,7 @@ void SequentialGuidanceLaw::addGuidanceLaw(const Shared<GuidanceLaw>& aGuidanceL
7777
guidanceLaws_.add(aGuidanceLawSPtr);
7878
}
7979

80-
Vector3d SequentialGuidanceLaw::calculateThrustAccelerationAt(
80+
Vector3d HeterogeneousGuidanceLaw::calculateThrustAccelerationAt(
8181
const Instant& anInstant,
8282
const Vector3d& aPositionCoordinates,
8383
const Vector3d& aVelocityCoordinates,

0 commit comments

Comments
 (0)