Commit 658dfc48 authored by Andreas Rauschert's avatar Andreas Rauschert
Browse files

Fix time conversion and add spline units

- time conversion didn't compile when used
- Added units for spline sections
parent 2f3630c6
......@@ -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
......
......@@ -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>
......
......@@ -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].
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment