Control Libraries 6.3.4
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
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_filled();
155}
156
157template<typename T>
158std::ostream& operator<<(std::ostream& os, const Parameter<T>& parameter) {
159 if (parameter.is_empty()) {
160 os << "Parameter " << parameter.get_name() << " is empty";
161 } else {
162 os << "Parameter " << parameter.get_name() << ": " << parameter.get_value();
163 }
164 return os;
165}
166
167template std::ostream& operator<<(std::ostream& os, const Parameter<int>& parameter);
168template std::ostream& operator<<(std::ostream& os, const Parameter<double>& parameter);
169template std::ostream& operator<<(std::ostream& os, const Parameter<bool>& parameter);
170template std::ostream& operator<<(std::ostream& os, const Parameter<std::string>& parameter);
171template std::ostream& operator<<(std::ostream& os, const Parameter<CartesianState>& parameter);
172template std::ostream& operator<<(std::ostream& os, const Parameter<CartesianPose>& parameter);
173template std::ostream& operator<<(std::ostream& os, const Parameter<JointState>& parameter);
174template std::ostream& operator<<(std::ostream& os, const Parameter<JointPositions>& parameter);
175template std::ostream& operator<<(std::ostream& os, const Parameter<Ellipsoid>& parameter);
176template std::ostream& operator<<(std::ostream& os, const Parameter<Eigen::MatrixXd>& parameter);
177template std::ostream& operator<<(std::ostream& os, const Parameter<Eigen::VectorXd>& parameter);
178
179template<>
180std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<int>>& parameter) {
181 if (parameter.is_empty()) {
182 os << "Parameter " << parameter.get_name() << " is empty" << std::endl;
183 } else {
184 os << "Parameter " << parameter.get_name() << ": ";
185 for (auto& v: parameter.get_value()) {
186 os << v << " | ";
187 }
188 os << std::endl;
189 }
190 return os;
191}
192
193template<>
194std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<double>>& parameter) {
195 if (parameter.is_empty()) {
196 os << "Parameter " << parameter.get_name() << " is empty" << std::endl;
197 } else {
198 os << "Parameter " << parameter.get_name() << ": ";
199 for (auto& v: parameter.get_value()) {
200 os << v << " | ";
201 }
202 os << std::endl;
203 }
204 return os;
205}
206
207template<>
208std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<bool>>& parameter) {
209 if (parameter.is_empty()) {
210 os << "Parameter " << parameter.get_name() << " is empty" << std::endl;
211 } else {
212 os << "Parameter " << parameter.get_name() << ": ";
213 for (auto v: parameter.get_value()) {
214 os << v << " | ";
215 }
216 os << std::endl;
217 }
218 return os;
219}
220
221template<>
222std::ostream& operator<<(std::ostream& os, const Parameter<std::vector<std::string>>& parameter) {
223 if (parameter.is_empty()) {
224 os << "Parameter " << parameter.get_name() << " is empty" << std::endl;
225 } else {
226 os << "Parameter " << parameter.get_name() << ": ";
227 for (auto& v: parameter.get_value()) {
228 os << v << " | ";
229 }
230 os << std::endl;
231 }
232 return os;
233}
234}// namespace state_representation
Parameter(const std::string &name)
Constructor with name of the parameter.
Core state variables and objects.
ParameterType
The parameter value types.
std::ostream & operator<<(std::ostream &os, const Ellipsoid &ellipsoid)
Definition: Ellipsoid.cpp:185
StateType
The class types inheriting from State.
Definition: StateType.hpp:13