Skip to content
Snippets Groups Projects
Commit d26d8282 authored by Jupp Tscheak's avatar Jupp Tscheak
Browse files

Class "SplineSection" can only be used with unit types.


Revised the control strategies that are spline based accordingly.

Signed-off-by: default avatarJupp Tscheak <jupp.tscheak@daimler.com>
parent 2d1a5c16
No related branches found
No related tags found
1 merge request!11Replaced the types of all physical quantities related members/arguments with SI unit types as provided by the Units library.
...@@ -35,6 +35,7 @@ struct SplineSegment ...@@ -35,6 +35,7 @@ struct SplineSegment
Vec3<T> d; Vec3<T> d;
}; };
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
struct SplineSection struct SplineSection
{ {
Time start_time{0}; Time start_time{0};
...@@ -45,17 +46,18 @@ struct SplineSection ...@@ -45,17 +46,18 @@ struct SplineSection
/// \f[ /// \f[
/// P(x) = \sum_{i=0}^{3} a_{i} x^{i} = a_3 x^3 + a_2 x^2 + a_1 x + a_0 /// P(x) = \sum_{i=0}^{3} a_{i} x^{i} = a_3 x^3 + a_2 x^2 + a_1 x + a_0
/// \f] /// \f]
std::array<double, 4> polynomial{0, 0, 0, 0}; std::array<T, 4> polynomial{0, 0, 0, 0};
}; };
/// @brief Equality comparison for SplineSection. /// @brief Equality comparison for SplineSection.
inline bool operator==(const SplineSection& lhs, const SplineSection& rhs) noexcept template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
inline bool operator==(const SplineSection<T>& lhs, const SplineSection<T>& rhs) noexcept
{ {
return lhs.start_time == rhs.start_time && lhs.end_time == rhs.end_time && return lhs.start_time == rhs.start_time && lhs.end_time == rhs.end_time &&
std::equal(lhs.polynomial.begin(), std::equal(lhs.polynomial.begin(),
lhs.polynomial.end(), lhs.polynomial.end(),
rhs.polynomial.begin(), rhs.polynomial.begin(),
[](const double a, const double b) { return IsEqual(a, b); }); [](const T& a, const T& b) { return IsEqual(a, b); });
} }
} // namespace mantle_api } // namespace mantle_api
......
...@@ -91,7 +91,7 @@ struct FollowHeadingSplineControlStrategy : public ControlStrategy ...@@ -91,7 +91,7 @@ struct FollowHeadingSplineControlStrategy : public ControlStrategy
type = ControlStrategyType::kFollowHeadingSpline; type = ControlStrategyType::kFollowHeadingSpline;
} }
std::vector<mantle_api::SplineSection> heading_splines; std::vector<mantle_api::SplineSection<units::angle::radian_t>> heading_splines;
double default_value{0}; double default_value{0};
}; };
...@@ -103,7 +103,7 @@ struct FollowVelocitySplineControlStrategy : public ControlStrategy ...@@ -103,7 +103,7 @@ struct FollowVelocitySplineControlStrategy : public ControlStrategy
type = ControlStrategyType::kFollowVelocitySpline; type = ControlStrategyType::kFollowVelocitySpline;
} }
std::vector<mantle_api::SplineSection> velocity_splines; std::vector<mantle_api::SplineSection<units::velocity::meters_per_second_t>> velocity_splines;
double default_value{0}; double default_value{0};
}; };
...@@ -127,7 +127,7 @@ struct FollowLateralOffsetSplineControlStrategy : public ControlStrategy ...@@ -127,7 +127,7 @@ struct FollowLateralOffsetSplineControlStrategy : public ControlStrategy
type = ControlStrategyType::kFollowLateralOffsetSpline; type = ControlStrategyType::kFollowLateralOffsetSpline;
} }
std::vector<mantle_api::SplineSection> lateral_offset_splines; std::vector<mantle_api::SplineSection<units::length::meter_t>> lateral_offset_splines;
}; };
// TODO: Create new control strategy for following 3D trajectories with shapes NURBS, polyline, clothoid // TODO: Create new control strategy for following 3D trajectories with shapes NURBS, polyline, clothoid
...@@ -177,7 +177,7 @@ struct AcquireLaneOffsetControlStrategy : public ControlStrategy ...@@ -177,7 +177,7 @@ struct AcquireLaneOffsetControlStrategy : public ControlStrategy
int road_id{}; int road_id{};
int lane_id{}; int lane_id{};
double offset{}; units::length::meter_t offset{};
TransitionDynamics transition_dynamics; TransitionDynamics transition_dynamics;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment