7 #ifndef DYNAMIC_GRAPH_EIGEN_IO_H 8 #define DYNAMIC_GRAPH_EIGEN_IO_H 10 #include <boost/format.hpp> 11 #include <boost/numeric/conversion/cast.hpp> 12 #pragma GCC diagnostic push 13 #pragma GCC system_header 14 #include <Eigen/Geometry> 15 #pragma GCC diagnostic pop 16 #include <dynamic-graph/exception-signal.h> 17 #include <dynamic-graph/linear-algebra.h> 30 typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE eigen_index;
32 inline std::istringstream &operator>>(std::istringstream &iss,
33 dynamicgraph::Vector &inst) {
37 boost::format fmt(
"Failed to enter %s as vector." 38 " Reenter as [N](val1,val2,val3,...,valN)");
40 if (iss >> _ch && _ch !=
'[') {
43 if (iss >> _size && !iss.fail()) {
47 if (iss >> _ch && _ch !=
']')
50 if (iss >> _ch && _ch !=
'(')
53 for (
unsigned int i = 0; i < _size; i++) {
55 if (iss.peek() ==
',' || iss.peek() ==
' ')
59 if (iss >> _ch && _ch !=
')')
74 template <
typename Derived>
75 inline std::istringstream &operator>>(std::istringstream &iss,
76 DenseBase<Derived> &inst) {
77 unsigned int _colsize;
78 unsigned int _rowsize;
81 boost::format fmt(
"Failed to enter %s as matrix. Reenter as " 82 "((val11,val12,val13,...,val1N)," 83 "...,(valM1,valM2,...,valMN))");
86 if (iss >> _ch && _ch !=
'[') {
90 if (iss.peek() ==
',' || iss.peek() ==
' ')
96 _tmp_matrix.resize(_rowsize, _colsize);
97 if (iss >> _ch && _ch !=
']')
100 if (iss >> _ch && _ch !=
'(')
103 for (
unsigned int j = 0; j < _rowsize; j++) {
104 if (iss >> _ch && _ch !=
'(')
106 for (
unsigned int i = 0; i < _colsize; i++) {
108 if (iss.peek() ==
',' || iss.peek() ==
' ')
110 _tmp_matrix(j, i) = _dbl_val;
112 if (iss >> _ch && _ch !=
')')
114 if (iss.peek() ==
',' || iss.peek() ==
' ')
117 if (iss >> _ch && _ch !=
')')
127 inline std::istringstream &operator>>(std::istringstream &iss,
128 Transform<double, 3, Affine> &inst) {
142 inline std::ostream &operator<<(std::ostream &os,
143 Transform<double, 3, Affine> MH) {
144 IOFormat boostFmt(StreamPrecision, DontAlignCols,
",",
",",
"(",
")",
"(",
147 os <<
"[4,4]" << MH.matrix().format(boostFmt);
151 inline std::ostream &operator<<(std::ostream &os, AngleAxisd quat) {
154 v.tail<3>() = quat.axis();
159 inline std::istringstream &operator>>(std::istringstream &iss,
164 inst.axis() = v.tail<3>();
170 #endif // DYNAMIC_GRAPH_EIGEN_IO_H
Exceptions raised when an error related to signals happen.