Closed GoogleCodeExporter closed 8 years ago
Thanks for messing around with this!
In your compiler output, it says:
before ‘>’ token
What is that symbol supposed to be?
Also, what's the definition of _Scalar, and what is your conversion code to
yaml-cpp?
Original comment by jbe...@gmail.com
on 13 Nov 2011 at 11:39
Here is the whole definition:
{{{
template < typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
int _MaxCols>
struct convert< Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows,
_MaxCols> > {
static Node encode(const Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& matrix) {
Node node;
return node;
}
static bool decode(const Node& node, Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& matrix) {
int nSize = node.size(); // Sequence check is implicit
if (nSize != matrix.rows() * matrix.cols()) {
ROS_ERROR_STREAM("Unable to create Eigen::Matrix. Input is of wrong size! Matrix("<<
matrix.rows() <<"x"<< matrix.cols() <<") != Tokens("<< nSize <<")");
return false;
} else {
// fill
for (int i = 0; i < matrix.rows(); i++) {
for (int j = 0; j < matrix.cols(); j++) {
//ROS_INFO_STREAM("Node pos: " << i*matrix.rows() + j << "Matrix: " << i << "," << j);
//node[i + j*matrix.cols()] >> matrix(i, j);
YAML::Node field = node[i + j*matrix.cols()];
matrix(i,j) = field.as<_Scalar>();
//matrix(i,j) = node[i + j*matrix.cols()].as<_Scalar>(); <- not working.
}
}
}
return true;
}
};
}}}
The symbol is '>' and the stuff before an encoding error for quotes or
something... (Eclipse on a Mac :) )
Original comment by m...@riedel-privat.de
on 13 Nov 2011 at 11:44
And _Scalar is int, double, float... But I think the issue lies somewhere else,
because one version of the code is working. I could probably also provide a
less complex example for the error.
Original comment by m...@riedel-privat.de
on 13 Nov 2011 at 11:46
I found the Problem.
This works:
matrix(i,j) = node[(int)(i + j*matrix.cols())].as<_Scalar>();
I have to cast the inner expression to int. I'm currently checking what it is
before.
Martin
Original comment by m...@riedel-privat.de
on 13 Nov 2011 at 11:58
Hm ok, I thought matrix.cols evaluates as some integer. But apparently there is
something going on behind the scenes that I do not completely understand.
cols() returns
typedef typename internal::traits<Derived>::Index Index;
Original comment by m...@riedel-privat.de
on 14 Nov 2011 at 12:08
OK, interesting.
I'm surprised, then, that
{{{
YAML::Node testNode = node[i + j*matrix.cols()];
}}}
did not give you a compiler error as well.
Original comment by jbe...@gmail.com
on 14 Nov 2011 at 1:49
Original issue reported on code.google.com by
m...@riedel-privat.de
on 13 Nov 2011 at 11:30