mc_rtc  2.14.0
Default.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <string>
6 #include <type_traits>
7 #include <variant>
8 
9 namespace mc_rtc
10 {
11 
18 template<typename T, typename Enable = void>
19 struct Default
20 {
21  static_assert(!std::is_same_v<T, T>, "Must be specialized");
22 };
23 
24 template<typename T>
25 struct Default<T, std::enable_if_t<std::is_arithmetic_v<T>>>
26 {
27  inline static constexpr T value = 0;
28 };
29 
30 template<typename Scalar, int N, int Options, int MaxRows, int MaxCols>
31 struct Default<Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols>, std::enable_if_t<(N > 0)>>
32 {
33  inline static const Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols> value =
34  Eigen::Matrix<Scalar, N, 1, Options, MaxRows, MaxCols>::Zero();
35 };
36 
37 template<typename Scalar, int N, int Options, int MaxRows, int MaxCols>
38 struct Default<Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols>, std::enable_if_t<(N > 1)>>
39 {
40  inline static const Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols> value =
41  Eigen::Matrix<Scalar, N, N, Options, MaxRows, MaxCols>::Identity();
42 };
43 
44 template<>
46 {
48 };
49 
50 template<>
52 {
53  inline static const sva::MotionVecd value = sva::MotionVecd::Zero();
54 };
55 
56 template<>
58 {
59  inline static const sva::ForceVecd value = sva::ForceVecd::Zero();
60 };
61 
62 template<>
64 {
66 };
67 
68 template<>
70 {
72 };
73 
74 template<>
75 struct Default<std::string>
76 {
77  inline static const std::string value;
78 };
79 
80 template<typename T, typename... Others>
81 struct Default<std::variant<T, Others...>> : public Default<T>
82 {
83 };
84 
85 } // namespace mc_rtc
static AdmittanceVec< T > Zero()
static ForceVec< T > Zero()
static ImpedanceVec< T > Zero()
static MotionVec< T > Zero()
static PTransform< T > Identity()
std::optional< Eigen::VectorXd > value
Definition: Contact.h:88
PTransform< double > PTransformd
ForceVec< double > ForceVecd
AdmittanceVec< double > AdmittanceVecd
ImpedanceVec< double > ImpedanceVecd
MotionVec< double > MotionVecd
static const std::string value
Definition: Default.h:77
Definition: Default.h:20