Control Libraries 7.4.0
Loading...
Searching...
No Matches
IOState.cpp
1#include "state_representation/IOState.hpp"
2
3namespace state_representation {
4
5template<>
6void IOState<double>::set_data(const std::vector<double>& data) {
7 this->set_data(Eigen::VectorXd::Map(data.data(), data.size()));
8}
9
10template<>
11void IOState<bool>::set_data(const std::vector<bool>& data) {
12 Eigen::Vector<bool, Eigen::Dynamic> vec;
13 vec.resize(data.size());
14 for (unsigned int i = 0; i < data.size(); ++i) {
15 vec(i) = data.at(i);
16 }
17 this->set_data(vec);
18}
19
20template<>
21std::vector<double> IOState<double>::to_std_vector() const {
22 return {this->data_.data(), this->data_.data() + this->data_.size()};
23}
24
25template<>
26std::vector<bool> IOState<bool>::to_std_vector() const {
27 std::vector<bool> vec;
28 vec.resize(this->get_size());
29 for (unsigned int i = 0; i < this->get_size(); ++i) {
30 vec.at(i) = this->data_(i);
31 }
32 return vec;
33}
34
35}// namespace state_representation
void set_data(const Eigen::Vector< T, Eigen::Dynamic > &data)
Set the values of the IO state from a single Eigen vector.
Definition IOState.hpp:240
std::vector< T > to_std_vector() const
Return the IO values as a std vector.
Core state variables and objects.