From 658dfc481c96bfb18c292ec79229b709514e0eec Mon Sep 17 00:00:00 2001
From: Andreas Rauschert <andreas.rb.rauschert@bmw.de>
Date: Fri, 12 Nov 2021 18:05:39 +0100
Subject: [PATCH] Fix time conversion and add spline units

- time conversion didn't compile when used
- Added units for spline sections
---
 .../include/MantleAPI/Common/orientation.h    | 13 ++++++++
 MantleAPI/include/MantleAPI/Common/spline.h   | 31 +++++++++++++++++++
 .../include/MantleAPI/Common/time_utils.h     |  6 ++--
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/MantleAPI/include/MantleAPI/Common/orientation.h b/MantleAPI/include/MantleAPI/Common/orientation.h
index e52df4ad..b64b1fb6 100644
--- a/MantleAPI/include/MantleAPI/Common/orientation.h
+++ b/MantleAPI/include/MantleAPI/Common/orientation.h
@@ -33,6 +33,19 @@ typedef base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-2>, std::ra
 
 UNIT_ADD_CATEGORY_TRAIT(angular_acceleration)
 
+UNIT_ADD(angular_jerk,
+         radians_per_second_cubed,
+         radians_per_second_cubed,
+         rad_per_s_cu,
+         compound_unit<angle::radians, inverse<cubed<time::seconds>>>)
+
+namespace category
+{
+typedef base_unit<detail::meter_ratio<0>, std::ratio<0>, std::ratio<-3>, std::ratio<1>> angular_jerk_unit;
+}
+
+UNIT_ADD_CATEGORY_TRAIT(angular_jerk)
+
 }  // namespace units
 
 namespace mantle_api
diff --git a/MantleAPI/include/MantleAPI/Common/spline.h b/MantleAPI/include/MantleAPI/Common/spline.h
index 32c97bc9..7b91677a 100644
--- a/MantleAPI/include/MantleAPI/Common/spline.h
+++ b/MantleAPI/include/MantleAPI/Common/spline.h
@@ -17,6 +17,7 @@
 #define MANTLEAPI_COMMON_SPLINE_H
 
 #include <MantleAPI/Common/floating_point_helper.h>
+#include <MantleAPI/Common/orientation.h>
 #include <MantleAPI/Common/time_utils.h>
 #include <MantleAPI/Common/vector.h>
 #include <units.h>
@@ -25,6 +26,36 @@
 
 using namespace units;
 
+namespace units
+{
+UNIT_ADD(jerk,
+         meters_per_second_cubed,
+         meters_per_second_cubed,
+         mps_cu,
+         compound_unit<velocity::meters_per_second, inverse<squared<time::seconds>>>)
+
+namespace category
+{
+typedef base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-3>> jerk_unit;
+}
+
+UNIT_ADD_CATEGORY_TRAIT(jerk)
+
+UNIT_ADD(jerk_acceleration,
+         meters_per_second_to_the_power_of_four,
+         meters_per_second_to_the_power_of_four,
+         mps_pow4,
+         compound_unit<velocity::meters_per_second, inverse<cubed<time::seconds>>>)
+
+namespace category
+{
+typedef base_unit<detail::meter_ratio<1>, std::ratio<0>, std::ratio<-4>> jerk_acceleration_unit;
+}
+
+UNIT_ADD_CATEGORY_TRAIT(jerk_acceleration)
+
+}  // namespace units
+
 namespace mantle_api
 {
 template <typename T>
diff --git a/MantleAPI/include/MantleAPI/Common/time_utils.h b/MantleAPI/include/MantleAPI/Common/time_utils.h
index e870485a..6d4ac464 100644
--- a/MantleAPI/include/MantleAPI/Common/time_utils.h
+++ b/MantleAPI/include/MantleAPI/Common/time_utils.h
@@ -22,13 +22,11 @@ namespace mantle_api
 using Time = units::time::millisecond_t;
 
 /// @brief Converts input in [s] to @ref Time.
-/// @tparam T Input type, eg. `double`.
 /// @param duration Input value
 /// @return Duration representing the given input in units of @ref Time.
-template <typename T>
-inline Time SecondsToTime(T duration)
+inline Time SecondsToTime(double duration)
 {
-  return units::convert<units::time::seconds, Time>(duration);
+  return units::time::second_t(duration);
 }
 
 /// @brief Converts input @ref Time to [s].
-- 
GitLab