23 std::cout <<
"q \t | \t qd" << std::endl;
24 for(
auto i=0; i<state.
q.size(); ++i)
26 out << state.
q(i) <<
"\t | \t" << state.
qd(i) << std::endl;
29 out <<
"x" <<
" " <<
"y" <<
" " <<
"z" <<
" " <<
"qx" <<
" " <<
"qy" <<
" " <<
"qz" <<
" " <<
"qw" << std::endl;
30 out << state.
H_root.x() <<
" ";
31 out << state.
H_root.y() <<
" ";
32 out << state.
H_root.z() <<
" ";
33 out << state.
H_root.qx() <<
" ";
34 out << state.
H_root.qy() <<
" ";
35 out << state.
H_root.qz() <<
" ";
36 out << state.
H_root.qw() << std::endl;
38 out <<
"rx" <<
" " <<
"ry" <<
" " <<
"rz" <<
" " <<
"rx" <<
" " <<
"ry" <<
" " <<
"rz" << std::endl;
45 out << state.
T_root << std::endl;
53 connection.appendInt(BOTTLE_TAG_LIST);
54 connection.appendInt(2);
56 connection.appendInt(BOTTLE_TAG_INT);
57 connection.appendInt(
q.size());
59 connection.appendInt(BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE);
60 connection.appendInt(
q.size() +
qd.size() + 13);
61 for(
auto i=0; i<
q.size(); ++i)
63 connection.appendDouble(
q(i));
64 connection.appendDouble(
qd(i));
66 connection.appendDouble(
H_root.x());
67 connection.appendDouble(
H_root.y());
68 connection.appendDouble(
H_root.z());
69 connection.appendDouble(
H_root.qx());
70 connection.appendDouble(
H_root.qy());
71 connection.appendDouble(
H_root.qz());
72 connection.appendDouble(
H_root.qw());
74 connection.appendDouble(
T_root.rx());
75 connection.appendDouble(
T_root.ry());
76 connection.appendDouble(
T_root.rz());
77 connection.appendDouble(
T_root.vx());
78 connection.appendDouble(
T_root.vy());
79 connection.appendDouble(
T_root.vz());
82 connection.convertTextMode();
84 return !connection.isError();
90 connection.convertTextMode();
92 if ( connection.expectInt() != BOTTLE_TAG_LIST || connection.expectInt() != 2) {
93 OCRA_ERROR(
"Received malformed data. Expected two lists with the following structure: (DOF)(ROBOT STATE)");
98 if ( connection.expectInt() != BOTTLE_TAG_INT ) {
99 OCRA_ERROR(
"Received malformed data. Expected one integer for DOF)");
102 this->nDoF = connection.expectInt();
103 this->
q.resize(nDoF);
104 this->
qd.resize(nDoF);
106 if ( connection.expectInt() != BOTTLE_TAG_LIST + BOTTLE_TAG_DOUBLE || connection.expectInt()!=
q.size() +
qd.size() + 13 ) {
107 OCRA_ERROR(
"Received a list with less data than expected");
111 for(
auto i=0; i<this->nDoF; ++i)
113 this->
q(i) = connection.expectDouble();
114 this->
qd(i) = connection.expectDouble();
116 this->
H_root.x() = connection.expectDouble();
117 this->
H_root.y() = connection.expectDouble();
118 this->
H_root.z() = connection.expectDouble();
119 this->
H_root.qx() = connection.expectDouble();
120 this->
H_root.qy() = connection.expectDouble();
121 this->
H_root.qz() = connection.expectDouble();
122 this->
H_root.qw() = connection.expectDouble();
124 this->
T_root.rx() = connection.expectDouble();
125 this->
T_root.ry() = connection.expectDouble();
126 this->
T_root.rz() = connection.expectDouble();
127 this->
T_root.vx() = connection.expectDouble();
128 this->
T_root.vy() = connection.expectDouble();
129 this->
T_root.vz() = connection.expectDouble();
131 return !connection.isError();
157 if (!state.
read(connection)){
158 OCRA_ERROR(
"Couldn't read state: " << state << std::endl);
Eigen::Displacementd H_root
bool read(yarp::os::ConnectionReader &connection)
std::ostream & operator<<(std::ostream &out, const RobotState &state)
virtual bool write(yarp::os::ConnectionWriter &connection)
A portable class for sending robot state information over yarp.
virtual bool read(yarp::os::ConnectionReader &connection)