Control Libraries 7.4.0
Loading...
Searching...
No Matches
Parameter.cpp
1#include "state_representation/parameters/Parameter.hpp"
2
3namespace state_representation {
4
5template<>
6Parameter<int>::Parameter(const std::string& name) :
7 ParameterInterface(name, ParameterType::INT), value_() {}
8
9template<>
10Parameter<int>::Parameter(const std::string& name, const int& value) :
11 ParameterInterface(name, ParameterType::INT), value_(value) {
12 this->set_empty(false);
13}
14
15template<>
16Parameter<std::vector<int>>::Parameter(const std::string& name) :
17 ParameterInterface(name, ParameterType::INT_ARRAY), value_() {}
18
19template<>
20Parameter<std::vector<int>>::Parameter(const std::string& name, const std::vector<int>& value) :
21 ParameterInterface(name, ParameterType::INT_ARRAY), value_(value) {
22 this->set_empty(false);
23}
24
25template<>
26Parameter<double>::Parameter(const std::string& name) :
27 ParameterInterface(name, ParameterType::DOUBLE), value_() {}
28
29template<>
30Parameter<double>::Parameter(const std::string& name, const double& value) :
31 ParameterInterface(name, ParameterType::DOUBLE), value_(value) {
32 this->set_empty(false);
33}
34
35template<>
36Parameter<std::vector<double>>::Parameter(const std::string& name) :
37 ParameterInterface(name, ParameterType::DOUBLE_ARRAY), value_() {}
38
39template<>
40Parameter<std::vector<double>>::Parameter(const std::string& name, const std::vector<double>& value) :
41 ParameterInterface(name, ParameterType::DOUBLE_ARRAY), value_(value) {
42 this->set_empty(false);
43}
44
45template<>
46Parameter<bool>::Parameter(const std::string& name) :
47 ParameterInterface(name, ParameterType::BOOL), value_() {}
48
49template<>
50Parameter<bool>::Parameter(const std::string& name, const bool& value) :
51 ParameterInterface(name, ParameterType::BOOL), value_(value) {
52 this->set_empty(false);
53}
54
55template<>
56Parameter<std::vector<bool>>::Parameter(const std::string& name) :
57 ParameterInterface(name, ParameterType::BOOL_ARRAY), value_() {
58}
59
60template<>
61Parameter<std::vector<bool>>::Parameter(const std::string& name, const std::vector<bool>& value) :
62 ParameterInterface(name, ParameterType::BOOL_ARRAY), value_(value) {
63 this->set_empty(false);
64}
65
66template<>
67Parameter<std::string>::Parameter(const std::string& name) :
68 ParameterInterface(name, ParameterType::STRING), value_() {}
69
70template<>
71Parameter<std::string>::Parameter(const std::string& name, const std::string& value) :
72 ParameterInterface(name, ParameterType::STRING), value_(value) {
73 this->set_empty(false);
74}
75
76template<>
77Parameter<std::vector<std::string>>::Parameter(const std::string& name) :
78 ParameterInterface(name, ParameterType::STRING_ARRAY), value_() {}
79
80template<>
81Parameter<std::vector<std::string>>::Parameter(const std::string& name, const std::vector<std::string>& value) :
82 ParameterInterface(name, ParameterType::STRING_ARRAY), value_(value) {
83 this->set_empty(false);
84}
85
86template<>
87Parameter<CartesianState>::Parameter(const std::string& name) :
88 ParameterInterface(name, ParameterType::STATE, StateType::CARTESIAN_STATE), value_() {}
89
90template<>
91Parameter<CartesianState>::Parameter(const std::string& name, const CartesianState& value) :
92 ParameterInterface(name, ParameterType::STATE, StateType::CARTESIAN_STATE), value_(value) {
93 this->set_empty(false);
94}
95
96template<>
97Parameter<CartesianPose>::Parameter(const std::string& name) :
98 ParameterInterface(name, ParameterType::STATE, StateType::CARTESIAN_POSE), value_() {}
99
100template<>
101Parameter<CartesianPose>::Parameter(const std::string& name, const CartesianPose& value) :
102 ParameterInterface(name, ParameterType::STATE, StateType::CARTESIAN_POSE), value_(value) {
103 this->set_empty(false);
104}
105
106template<>
107Parameter<JointState>::Parameter(const std::string& name) :
108 ParameterInterface(name, ParameterType::STATE, StateType::JOINT_STATE), value_() {}
109
110template<>
111Parameter<JointState>::Parameter(const std::string& name, const JointState& value) :
112 ParameterInterface(name, ParameterType::STATE, StateType::JOINT_STATE), value_(value) {
113 this->set_empty(false);
114}
115
116template<>
117Parameter<JointPositions>::Parameter(const std::string& name) :
118 ParameterInterface(name, ParameterType::STATE, StateType::JOINT_POSITIONS), value_() {}
119
120template<>
121Parameter<JointPositions>::Parameter(const std::string& name, const JointPositions& value) :
122 ParameterInterface(name, ParameterType::STATE, StateType::JOINT_POSITIONS), value_(value) {
123 this->set_empty(false);
124}
125
126template<>
127Parameter<Ellipsoid>::Parameter(const std::string& name) :
128 ParameterInterface(name, ParameterType::STATE, StateType::GEOMETRY_ELLIPSOID), value_() {
129}
130
131template<>
132Parameter<Ellipsoid>::Parameter(const std::string& name, const Ellipsoid& value) :
133 ParameterInterface(name, ParameterType::STATE, StateType::GEOMETRY_ELLIPSOID), value_(value) {
134 this->set_empty(false);
135}
136
137template<>
138Parameter<Eigen::MatrixXd>::Parameter(const std::string& name) :
139 ParameterInterface(name, ParameterType::MATRIX), value_() {}
140
141template<>
142Parameter<Eigen::MatrixXd>::Parameter(const std::string& name, const Eigen::MatrixXd& value) :
143 ParameterInterface(name, ParameterType::MATRIX), value_(value) {
144 this->set_empty(false);
145}
146
147template<>
148Parameter<Eigen::VectorXd>::Parameter(const std::string& name) :
149 ParameterInterface(name, ParameterType::VECTOR), value_() {}
150
151template<>
152Parameter<Eigen::VectorXd>::Parameter(const std::string& name, const Eigen::VectorXd& value) :
153 ParameterInterface(name, ParameterType::VECTOR), value_(value) {
154 this->set_empty(false);
155}
156
157template<typename T>
158std::ostream& operator<<(std::ostream& os, const Parameter<T>& parameter) {
159 os << parameter.to_string();
160 if (parameter) {
161 os << ", " << parameter.get_value();
162 }
163 return os;
164}
165
166template std::ostream& operator<<(std::ostream& os, const Parameter<int>& parameter);
167template std::ostream& operator<<(std::ostream& os, const Parameter<double>& parameter);
168template std::ostream& operator<<(std::ostream& os, const Parameter<bool>& parameter);
169template std::ostream& operator<<(std::ostream& os, const Parameter<std::string>& parameter);
170template std::ostream& operator<<(std::ostream& os, const Parameter<CartesianState>& parameter);
171template std::ostream& operator<<(std::ostream& os, const Parameter<CartesianPose>& parameter);
172template std::ostream& operator<<(std::ostream& os, const Parameter<JointState>& parameter);
173template std::ostream& operator<<(std::ostream& os, const Parameter<JointPositions>& parameter);
174template std::ostream& operator<<(std::ostream& os, const Parameter<Ellipsoid>& parameter);
175template std::ostream& operator<<(std::ostream& os, const Parameter<Eigen::MatrixXd>& parameter);
176template std::ostream& operator<<(std::ostream& os, const Parameter<Eigen::VectorXd>& parameter);
177
178template<>
179std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<int>>& parameter) {
180 os << parameter.to_string();
181 if (parameter) {
182 os << ", [";
183 for (auto& v: parameter.get_value()) {
184 os << v << ", ";
185 }
186 os << "]";
187 }
188 return os;
189}
190
191template<>
192std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<double>>& parameter) {
193 os << parameter.to_string();
194 if (parameter) {
195 os << ", [";
196 for (auto& v: parameter.get_value()) {
197 os << v << ", ";
198 }
199 os << "]";
200 }
201 return os;
202}
203
204template<>
205std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<bool>>& parameter) {
206 os << parameter.to_string();
207 if (parameter) {
208 os << ", [";
209 for (auto v: parameter.get_value()) {
210 os << v << ", ";
211 }
212 os << "]";
213 }
214 return os;
215}
216
217template<>
218std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<std::string>>& parameter) {
219 os << parameter.to_string();
220 if (parameter) {
221 os << ", [";
222 for (auto& v: parameter.get_value()) {
223 os << v << ", ";
224 }
225 os << "]";
226 }
227 return os;
228}
229}// namespace state_representation
Parameter(const std::string &name="")
Constructor with the name of the parameter.
Core state variables and objects.
ParameterType
The parameter value types.
std::ostream & operator<<(std::ostream &os, const AnalogIOState &state)
StateType
The class types inheriting from State.
Definition StateType.hpp:13