Control Libraries 7.4.0
Loading...
Searching...
No Matches
JointState.cpp
1#include "state_representation/space/joint/JointState.hpp"
2
3#include "state_representation/exceptions/EmptyStateException.hpp"
4#include "state_representation/exceptions/IncompatibleStatesException.hpp"
5#include "state_representation/exceptions/InvalidCastException.hpp"
6#include "state_representation/exceptions/JointNotFoundException.hpp"
7
8namespace state_representation {
9
10using namespace exceptions;
11
12static void assert_index_in_range(unsigned int joint_index, unsigned int size) {
13 if (joint_index > size) {
14 throw JointNotFoundException(
15 "Index '" + std::to_string(joint_index) + "' is out of range for joint state with size" + std::to_string(size));
16 }
17}
18
19static unsigned int get_state_variable_size_factor(const JointStateVariable& state_variable_type) {
20 switch (state_variable_type) {
21 case JointStateVariable::POSITIONS:
22 case JointStateVariable::VELOCITIES:
23 case JointStateVariable::ACCELERATIONS:
24 case JointStateVariable::TORQUES:
25 return 1;
26 case JointStateVariable::ALL:
27 return 4;
28 default:
29 return 0;
30 }
31}
32
34 this->set_type(StateType::JOINT_STATE);
35}
36
37JointState::JointState(const std::string& robot_name, unsigned int nb_joints) :
38 State(robot_name),
39 names_(nb_joints),
40 positions_(Eigen::VectorXd::Zero(nb_joints)),
41 velocities_(Eigen::VectorXd::Zero(nb_joints)),
42 accelerations_(Eigen::VectorXd::Zero(nb_joints)),
43 torques_(Eigen::VectorXd::Zero(nb_joints)) {
44 this->set_type(StateType::JOINT_STATE);
45 this->set_names(nb_joints);
46}
47
48JointState::JointState(const std::string& robot_name, const std::vector<std::string>& joint_names) :
49 JointState(robot_name, joint_names.size()) {
50 this->set_names(joint_names);
51}
52
53JointState::JointState(const JointState& state) : JointState(state.get_name(), state.names_) {
54 if (state) {
55 this->set_state_variable(state.get_state_variable(JointStateVariable::ALL), JointStateVariable::ALL);
56 }
57}
58
59JointState JointState::Zero(const std::string& robot_name, unsigned int nb_joints) {
60 JointState zero = JointState(robot_name, nb_joints);
61 // as opposed to the constructor specify this state to be filled
62 zero.set_empty(false);
63 return zero;
64}
65
66JointState JointState::Zero(const std::string& robot_name, const std::vector<std::string>& joint_names) {
67 JointState zero = JointState(robot_name, joint_names);
68 // as opposed to the constructor specify this state to be filled
69 zero.set_empty(false);
70 return zero;
71}
72
73JointState JointState::Random(const std::string& robot_name, unsigned int nb_joints) {
74 JointState random = JointState(robot_name, nb_joints);
75 // set all the state variables to random
76 random.set_state_variable(Eigen::VectorXd::Random(random.get_size() * 4), JointStateVariable::ALL);
77 return random;
78}
79
80JointState JointState::Random(const std::string& robot_name, const std::vector<std::string>& joint_names) {
81 JointState random = JointState(robot_name, joint_names);
82 // set all the state variables to random
83 random.set_state_variable(Eigen::VectorXd::Random(random.get_size() * 4), JointStateVariable::ALL);
84 return random;
85}
86
88 JointState tmp(state);
89 swap(*this, tmp);
90 return *this;
91}
92
93Eigen::VectorXd JointState::get_state_variable(const JointStateVariable& state_variable_type) const {
94 this->assert_not_empty();
95 switch (state_variable_type) {
96 case JointStateVariable::POSITIONS:
97 return this->positions_;
98 case JointStateVariable::VELOCITIES:
99 return this->velocities_;
100 case JointStateVariable::ACCELERATIONS:
101 return this->accelerations_;
102 case JointStateVariable::TORQUES:
103 return this->torques_;
104 case JointStateVariable::ALL: {
105 Eigen::VectorXd all_fields(this->get_size() * 4);
106 all_fields << this->positions_, this->velocities_, this->accelerations_, this->torques_;
107 return all_fields;
108 }
109 default:
110 return {};
111 }
112}
113
114unsigned int JointState::get_size() const {
115 return this->names_.size();
116}
117
118const std::vector<std::string>& JointState::get_names() const {
119 return this->names_;
120}
121
122unsigned int JointState::get_joint_index(const std::string& joint_name) const {
123 auto finder = std::find(this->names_.begin(), this->names_.end(), joint_name);
124 if (finder == this->names_.end()) {
125 throw JointNotFoundException("The joint with name '" + joint_name + "' could not be found in the joint state.");
126 }
127 return std::distance(this->names_.begin(), finder);
128}
129
130const Eigen::VectorXd& JointState::get_positions() const {
131 this->assert_not_empty();
132 return this->positions_;
133}
134
135double JointState::get_position(const std::string& joint_name) const {
136 return this->positions_(this->get_joint_index(joint_name));
137}
138
139double JointState::get_position(unsigned int joint_index) const {
140 this->assert_not_empty();
141 assert_index_in_range(joint_index, this->get_size());
142 return this->positions_(joint_index);
143}
144
145const Eigen::VectorXd& JointState::get_velocities() const {
146 this->assert_not_empty();
147 return this->velocities_;
148}
149
150double JointState::get_velocity(const std::string& joint_name) const {
151 return this->velocities_(this->get_joint_index(joint_name));
152}
153
154double JointState::get_velocity(unsigned int joint_index) const {
155 this->assert_not_empty();
156 assert_index_in_range(joint_index, this->get_size());
157 return this->velocities_(joint_index);
158}
159
160const Eigen::VectorXd& JointState::get_accelerations() const {
161 this->assert_not_empty();
162 return this->accelerations_;
163}
164
165double JointState::get_acceleration(const std::string& joint_name) const {
166 return this->accelerations_(this->get_joint_index(joint_name));
167}
168
169double JointState::get_acceleration(unsigned int joint_index) const {
170 this->assert_not_empty();
171 assert_index_in_range(joint_index, this->get_size());
172 return this->accelerations_(joint_index);
173}
174
175const Eigen::VectorXd& JointState::get_torques() const {
176 this->assert_not_empty();
177 return this->torques_;
178}
179
180double JointState::get_torque(const std::string& joint_name) const {
181 return this->torques_(this->get_joint_index(joint_name));
182}
183
184double JointState::get_torque(unsigned int joint_index) const {
185 this->assert_not_empty();
186 assert_index_in_range(joint_index, this->get_size());
187 return this->torques_(joint_index);
188}
189
190Eigen::VectorXd JointState::data() const {
191 return this->get_state_variable(JointStateVariable::ALL);
192}
193
194Eigen::ArrayXd JointState::array() const {
195 return this->data().array();
196}
197
199 const std::vector<double>& new_value, const JointStateVariable& state_variable_type
200) {
201 this->set_state_variable(Eigen::VectorXd::Map(new_value.data(), new_value.size()), state_variable_type);
202}
203
204void JointState::set_state_variable(const Eigen::VectorXd& new_value, const JointStateVariable& state_variable_type) {
205 auto expected_size = get_state_variable_size_factor(state_variable_type) * this->get_size();
206 if (new_value.size() != expected_size) {
208 "Input is of incorrect size, expected " + std::to_string(expected_size) + ", got "
209 + std::to_string(new_value.size()));
210 }
211 switch (state_variable_type) {
212 case JointStateVariable::POSITIONS:
213 this->positions_ = new_value;
214 break;
215 case JointStateVariable::VELOCITIES:
216 this->velocities_ = new_value;
217 break;
218 case JointStateVariable::ACCELERATIONS:
219 this->accelerations_ = new_value;
220 break;
221 case JointStateVariable::TORQUES:
222 this->torques_ = new_value;
223 break;
224 case JointStateVariable::ALL: {
225 auto size = this->get_size();
226 this->positions_ = new_value.head(size);
227 this->velocities_ = new_value.segment(size, size);
228 this->accelerations_ = new_value.segment(2 * size, size);
229 this->torques_ = new_value.tail(size);
230 break;
231 }
232 }
233 this->set_empty(false);
234}
235
237 double new_value, unsigned int joint_index, const JointStateVariable& state_variable_type
238) {
239 assert_index_in_range(joint_index, this->get_size());
240 switch (state_variable_type) {
241 case JointStateVariable::POSITIONS:
242 this->positions_(joint_index) = new_value;
243 break;
244 case JointStateVariable::VELOCITIES:
245 this->velocities_(joint_index) = new_value;
246 break;
247 case JointStateVariable::ACCELERATIONS:
248 this->accelerations_(joint_index) = new_value;
249 break;
250 case JointStateVariable::TORQUES:
251 this->torques_(joint_index) = new_value;
252 break;
253 case JointStateVariable::ALL:
254 this->positions_(joint_index) = new_value;
255 this->velocities_(joint_index) = new_value;
256 this->accelerations_(joint_index) = new_value;
257 this->torques_(joint_index) = new_value;
258 }
259 this->set_empty(false);
260}
261
262void JointState::set_names(unsigned int nb_joints) {
263 if (this->get_size() != nb_joints) {
265 "Input number of joints is of incorrect size, expected " + std::to_string(this->get_size()) + " got "
266 + std::to_string(nb_joints));
267 }
268 for (unsigned int i = 0; i < nb_joints; ++i) {
269 this->names_[i] = "joint" + std::to_string(i);
270 }
271 this->reset_timestamp();
272}
273
274void JointState::set_names(const std::vector<std::string>& names) {
275 if (this->get_size() != names.size()) {
277 "Input number of joints is of incorrect size, expected " + std::to_string(this->get_size()) + " got "
278 + std::to_string(names.size()));
279 }
280 this->names_ = names;
281 this->reset_timestamp();
282}
283
284void JointState::set_positions(const Eigen::VectorXd& positions) {
285 this->set_state_variable(positions, JointStateVariable::POSITIONS);
286}
287
288void JointState::set_positions(const std::vector<double>& positions) {
289 this->set_state_variable(positions, JointStateVariable::POSITIONS);
290}
291
292void JointState::set_position(double position, const std::string& joint_name) {
293 this->set_state_variable(position, this->get_joint_index(joint_name), JointStateVariable::POSITIONS);
294}
295
296void JointState::set_position(double position, unsigned int joint_index) {
297 this->set_state_variable(position, joint_index, JointStateVariable::POSITIONS);
298}
299
300void JointState::set_velocities(const Eigen::VectorXd& velocities) {
301 this->set_state_variable(velocities, JointStateVariable::VELOCITIES);
302}
303
304void JointState::set_velocities(const std::vector<double>& velocities) {
305 this->set_state_variable(velocities, JointStateVariable::VELOCITIES);
306}
307
308void JointState::set_velocity(double velocity, const std::string& joint_name) {
309 this->set_state_variable(velocity, this->get_joint_index(joint_name), JointStateVariable::VELOCITIES);
310}
311
312void JointState::set_velocity(double velocity, unsigned int joint_index) {
313 this->set_state_variable(velocity, joint_index, JointStateVariable::VELOCITIES);
314}
315
316void JointState::set_accelerations(const Eigen::VectorXd& accelerations) {
317 this->set_state_variable(accelerations, JointStateVariable::ACCELERATIONS);
318}
319
320void JointState::set_accelerations(const std::vector<double>& accelerations) {
321 this->set_state_variable(accelerations, JointStateVariable::ACCELERATIONS);
322}
323
324void JointState::set_acceleration(double acceleration, const std::string& joint_name) {
325 this->set_state_variable(acceleration, this->get_joint_index(joint_name), JointStateVariable::ACCELERATIONS);
326}
327
328void JointState::set_acceleration(double acceleration, unsigned int joint_index) {
329 this->set_state_variable(acceleration, joint_index, JointStateVariable::ACCELERATIONS);
330}
331
332void JointState::set_torques(const Eigen::VectorXd& torques) {
333 this->set_state_variable(torques, JointStateVariable::TORQUES);
334}
335
336void JointState::set_torques(const std::vector<double>& torques) {
337 this->set_state_variable(torques, JointStateVariable::TORQUES);
338}
339
340void JointState::set_torque(double torque, const std::string& joint_name) {
341 this->set_state_variable(torque, this->get_joint_index(joint_name), JointStateVariable::TORQUES);
342}
343
344void JointState::set_torque(double torque, unsigned int joint_index) {
345 this->set_state_variable(torque, joint_index, JointStateVariable::TORQUES);
346}
347
348void JointState::set_data(const Eigen::VectorXd& data) {
349 this->set_state_variable(data, JointStateVariable::ALL);
350}
351
352void JointState::set_data(const std::vector<double>& data) {
353 this->set_state_variable(data, JointStateVariable::ALL);
354}
355
357 const Eigen::ArrayXd& max_absolute_value_array, const JointStateVariable& state_variable_type,
358 const Eigen::ArrayXd& noise_ratio_array
359) {
360 Eigen::VectorXd state_variable = this->get_state_variable(state_variable_type);
361 long expected_size = state_variable.size();
362 if (max_absolute_value_array.size() != expected_size) {
364 "Array of max values is of incorrect size: expected " + std::to_string(expected_size) + ", given "
365 + std::to_string(max_absolute_value_array.size()));
366 }
367
368 if (noise_ratio_array.size() != expected_size) {
370 "Array of max values is of incorrect size: expected " + std::to_string(expected_size) + ", given "
371 + std::to_string(noise_ratio_array.size()));
372 }
373 for (int i = 0; i < expected_size; ++i) {
374 if (noise_ratio_array(i) != 0.0 && abs(state_variable(i)) < noise_ratio_array(i) * max_absolute_value_array(i)) {
375 // apply dead zone
376 state_variable(i) = 0.0;
377 } else if (abs(state_variable(i)) > max_absolute_value_array(i)) {
378 // clamp to max value
379 state_variable(i) *= max_absolute_value_array(i) / abs(state_variable(i));
380 }
381 }
382 this->set_state_variable(state_variable, state_variable_type);
383}
384
386 double max_absolute_value, const JointStateVariable& state_variable_type, double noise_ratio
387) {
388 Eigen::VectorXd state_variable = this->get_state_variable(state_variable_type);
389 long expected_size = state_variable.size();
391 max_absolute_value * Eigen::ArrayXd::Ones(expected_size), state_variable_type,
392 noise_ratio * Eigen::ArrayXd::Ones(expected_size));
393}
394
396 JointState result(*this);
397 return result;
398}
399
400double JointState::dist(const JointState& state, const JointStateVariable& state_variable_type) const {
401 if (this->is_incompatible(state)) {
403 "The two joint states are incompatible, check name, joint names and order or size"
404 );
405 }
406 // calculation
407 double result = 0;
408 if (state_variable_type == JointStateVariable::POSITIONS || state_variable_type == JointStateVariable::ALL) {
409 result += (this->get_positions() - state.get_positions()).norm();
410 }
411 if (state_variable_type == JointStateVariable::VELOCITIES || state_variable_type == JointStateVariable::ALL) {
412 result += (this->get_velocities() - state.get_velocities()).norm();
413 }
414 if (state_variable_type == JointStateVariable::ACCELERATIONS || state_variable_type == JointStateVariable::ALL) {
415 result += (this->get_accelerations() - state.get_accelerations()).norm();
416 }
417 if (state_variable_type == JointStateVariable::TORQUES || state_variable_type == JointStateVariable::ALL) {
418 result += (this->get_torques() - state.get_torques()).norm();
419 }
420 return result;
421}
422
423double dist(const JointState& s1, const JointState& s2, const JointStateVariable& state_variable_type) {
424 return s1.dist(s2, state_variable_type);
425}
426
428 this->set_zero();
429 this->State::reset();
430}
431
432bool JointState::is_incompatible(const State& state) const {
433 try {
434 auto other = dynamic_cast<const JointState&>(state);
435 if (this->names_.size() != other.names_.size()) {
436 return true;
437 }
438 for (unsigned int i = 0; i < this->names_.size(); ++i) {
439 if (this->names_[i] != other.names_[i]) {
440 return true;
441 }
442 }
443 return false;
444 } catch (const std::bad_cast& ex) {
446 std::string("Could not cast the given object to a JointState: ") + ex.what());
447 }
448}
449
451 if (this->get_size() > 0) {
452 this->positions_.setZero();
453 this->velocities_.setZero();
454 this->accelerations_.setZero();
455 this->torques_.setZero();
456 this->set_empty(false);
457 }
458}
459
460std::vector<double> JointState::to_std_vector() const {
461 Eigen::VectorXd data = this->data();
462 return {data.data(), data.data() + data.size()};
463}
464
465void JointState::multiply_state_variable(const Eigen::MatrixXd& lambda, const JointStateVariable& state_variable_type) {
466 Eigen::VectorXd state_variable = this->get_state_variable(state_variable_type);
467 long expected_size = state_variable.size();
468 if (lambda.rows() != expected_size || lambda.cols() != expected_size) {
470 "Gain matrix is of incorrect size: expected " + std::to_string(expected_size) + "x"
471 + std::to_string(expected_size) + ", given " + std::to_string(lambda.rows()) + "x"
472 + std::to_string(lambda.cols()));
473 }
474 this->set_state_variable(lambda * this->get_state_variable(state_variable_type), state_variable_type);
475}
476
478 this->set_state_variable(lambda * this->get_state_variable(JointStateVariable::ALL), JointStateVariable::ALL);
479 return (*this);
480}
481
482JointState JointState::operator*(double lambda) const {
483 JointState result(*this);
484 result *= lambda;
485 return result;
486}
487
488JointState operator*(double lambda, const JointState& state) {
489 JointState result(state);
490 result *= lambda;
491 return result;
492}
493
494JointState operator*(const Eigen::MatrixXd& lambda, const JointState& state) {
495 JointState result(state);
496 result.multiply_state_variable(lambda, JointStateVariable::ALL);
497 return result;
498}
499
501 return JointState::operator*=(1 / lambda);
502}
503
504JointState JointState::operator/(double lambda) const {
505 JointState result(*this);
506 result /= lambda;
507 return result;
508}
509
511 if (this->is_incompatible(state)) {
513 "The two joint states are incompatible, check name, joint names and order or size"
514 );
515 }
516 this->set_state_variable(
517 this->get_state_variable(JointStateVariable::ALL) + state.get_state_variable(JointStateVariable::ALL),
518 JointStateVariable::ALL
519 );
520 return (*this);
521}
522
524 JointState result(*this);
525 result += state;
526 return result;
527}
528
530 // create a copy of the state
531 JointState result(*this);
532 result.set_state_variable(-result.get_state_variable(JointStateVariable::ALL), JointStateVariable::ALL);
533 return result;
534}
535
537 (*this) += -state;
538 return (*this);
539}
540
542 JointState result(*this);
543 result -= state;
544 return result;
545}
546
547std::string JointState::to_string() const {
548 std::stringstream s;
549 s << this->State::to_string();
550 s << std::endl << "joint names: [";
551 for (auto& n : this->get_names()) { s << n << ", "; }
552 s << "]";
553 if (this->is_empty()) {
554 return s.str();
555 }
556 if (this->get_type() == StateType::JOINT_POSITIONS || this->get_type() == StateType::JOINT_STATE) {
557 s << std::endl << "positions: [";
558 for (auto& p : this->get_positions()) { s << p << ", "; }
559 s << "]";
560 }
561 if (this->get_type() == StateType::JOINT_VELOCITIES || this->get_type() == StateType::JOINT_STATE) {
562 s << std::endl << "velocities: [";
563 for (auto& v : this->get_velocities()) { s << v << ", "; }
564 s << "]";
565 }
566 if (this->get_type() == StateType::JOINT_ACCELERATIONS || this->get_type() == StateType::JOINT_STATE) {
567 s << std::endl << "accelerations: [";
568 for (auto& a : this->get_accelerations()) { s << a << ", "; }
569 s << "]";
570 }
571 if (this->get_type() == StateType::JOINT_TORQUES || this->get_type() == StateType::JOINT_STATE) {
572 s << std::endl << "torques: [";
573 for (auto& t : this->get_torques()) { s << t << ", "; }
574 s << "]";
575 }
576 return s.str();
577}
578
579std::ostream& operator<<(std::ostream& os, const JointState& state) {
580 os << state.to_string();
581 return os;
582}
583}// namespace state_representation
Class to define a state in joint space.
const Eigen::VectorXd & get_torques() const
Getter of the torques attribute.
JointState operator+(const JointState &state) const
Add another joint sate.
double dist(const JointState &state, const JointStateVariable &state_variable_type=JointStateVariable::ALL) const
Compute the distance to another state as the sum of distances between each attribute.
void set_accelerations(const Eigen::VectorXd &accelerations)
Setter of the accelerations attribute.
void reset() override
Reset the object to a post-construction state.
void multiply_state_variable(const Eigen::MatrixXd &lambda, const JointStateVariable &state_variable_type)
Proxy function that scale the specified state variable by a matrix.
double get_torque(const std::string &joint_name) const
Get the torque of a joint by its name, if it exists.
void set_positions(const Eigen::VectorXd &positions)
Setter of the positions attribute.
static JointState Random(const std::string &robot_name, unsigned int nb_joints)
Constructor for a random joint state.
JointState()
Empty constructor for a joint state.
void set_names(unsigned int nb_joints)
Setter of the names attribute from the number of joints.
JointState & operator=(const JointState &state)
Copy assignment operator that has to be defined to the custom assignment operator.
JointState & operator*=(double lambda)
Scale inplace by a scalar.
void set_zero()
Set the joint state to a zero value.
const Eigen::VectorXd & get_velocities() const
Getter of the velocities attribute.
unsigned int get_size() const
Getter of the size from the attributes.
bool is_incompatible(const State &state) const override
Check if the joint state is incompatible for operations with the state given as argument.
Eigen::VectorXd get_state_variable(const JointStateVariable &state_variable_type) const
Getter of the variable value corresponding to the input.
void set_state_variable(const Eigen::VectorXd &new_value, const JointStateVariable &state_variable_type)
Setter of the variable value corresponding to the input.
void clamp_state_variable(double max_absolute_value, const JointStateVariable &state_variable_type, double noise_ratio=0)
Clamp inplace the magnitude of the a specific joint state variable.
void set_acceleration(double acceleration, const std::string &joint_name)
Set the acceleration of a joint by its name.
std::vector< double > to_std_vector() const
Return the joint state as a std vector.
static JointState Zero(const std::string &robot_name, unsigned int nb_joints)
Constructor for a zero joint state.
Eigen::ArrayXd array() const
Returns the data vector as an Eigen array.
JointState & operator+=(const JointState &state)
Add inplace another joint state.
unsigned int get_joint_index(const std::string &joint_name) const
Get joint index by the name of the joint, if it exists.
JointState copy() const
Return a copy of the joint state.
double get_acceleration(const std::string &joint_name) const
Get the acceleration of a joint by its name, if it exists.
void set_torques(const Eigen::VectorXd &torques)
Setter of the torques attribute.
std::string to_string() const override
Convert the state to its string representation.
void set_position(double position, const std::string &joint_name)
Set the position of a joint by its name.
double get_velocity(const std::string &joint_name) const
Get the velocity of a joint by its name, if it exists.
virtual void set_data(const Eigen::VectorXd &data) override
Set the data of the state from all the state variables in a single Eigen vector.
JointState & operator-=(const JointState &state)
Compute inplace the difference with another joint state.
void set_torque(double torque, const std::string &joint_name)
Set the torque of a joint by its name.
friend double dist(const JointState &s1, const JointState &s2, const JointStateVariable &state_variable_type)
Compute the distance between two joint states.
JointState & operator/=(double lambda)
Scale inplace by a scalar.
const Eigen::VectorXd & get_accelerations() const
Getter of the accelerations attribute.
JointState operator-() const
Negate a joint state.
friend JointState operator*(double lambda, const JointState &state)
Scale a joint state by a scalar.
const std::vector< std::string > & get_names() const
Getter of the names attribute.
double get_position(const std::string &joint_name) const
Get the position of a joint by its name, if it exists.
void set_velocity(double velocity, const std::string &joint_name)
Set the velocity of a joint by its name.
const Eigen::VectorXd & get_positions() const
Getter of the positions attribute.
void set_velocities(const Eigen::VectorXd &velocities)
Setter of the velocities attribute.
JointState operator/(double lambda) const
Scale a joint state by a scalar.
virtual Eigen::VectorXd data() const
Returns the data as the concatenation of all the state variables in a single vector.
friend void swap(JointState &state1, JointState &state2)
Swap the values of the two joint states.
Abstract class to represent a state.
Definition State.hpp:25
void reset_timestamp()
Reset the timestamp attribute to now.
Definition State.cpp:61
const StateType & get_type() const
Getter of the type attribute.
Definition State.cpp:25
void set_type(const StateType &type)
Setter of the state type attribute.
Definition State.cpp:41
virtual std::string to_string() const
Convert the state to its string representation.
Definition State.cpp:99
virtual void reset()
Reset the object to a post-construction state.
Definition State.cpp:77
void assert_not_empty() const
Throw an exception if the state is empty.
Definition State.cpp:55
bool is_empty() const
Getter of the empty attribute.
Definition State.cpp:33
void set_empty(bool empty=true)
Setter of the empty attribute.
Definition State.cpp:50
Exception that is thrown when a joint name or index is out of range.
Core state variables and objects.
double dist(const CartesianState &s1, const CartesianState &s2, const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL)
Compute the distance between two Cartesian states.
std::ostream & operator<<(std::ostream &os, const AnalogIOState &state)
JointStateVariable
Enum representing all the fields (positions, velocities, accelerations and torques) of the JointState...
CartesianAcceleration operator*(double lambda, const CartesianAcceleration &acceleration)