33 #include <Eigen/StdVector> 44 int main (
int argc,
char** argv)
50 std::vector<double> noiseTranslation;
51 std::vector<double> noiseRotation;
54 arg.
param(
"o", outFilename,
"-",
"output filename");
55 arg.
param(
"nodesPerLevel", nodesPerLevel, 50,
"how many nodes per lap on the sphere");
56 arg.
param(
"laps", numLaps, 50,
"how many times the robot travels around the sphere");
57 arg.
param(
"radius", radius, 100.,
"radius of the sphere");
58 arg.
param(
"noiseTranslation", noiseTranslation, std::vector<double>(),
"set the noise level for the translation, separated by semicolons without spaces e.g: \"0.1;0.1;0.1\"");
59 arg.
param(
"noiseRotation", noiseRotation, std::vector<double>(),
"set the noise level for the rotation, separated by semicolons without spaces e.g: \"0.001;0.001;0.001\"");
62 if (noiseTranslation.size() == 0) {
63 cerr <<
"using default noise for the translation" << endl;
64 noiseTranslation.push_back(0.01);
65 noiseTranslation.push_back(0.01);
66 noiseTranslation.push_back(0.01);
68 cerr <<
"Noise for the translation:";
69 for (
size_t i = 0; i < noiseTranslation.size(); ++i)
70 cerr <<
" " << noiseTranslation[i];
72 if (noiseRotation.size() == 0) {
73 cerr <<
"using default noise for the rotation" << endl;
74 noiseRotation.push_back(0.005);
75 noiseRotation.push_back(0.005);
76 noiseRotation.push_back(0.005);
78 cerr <<
"Noise for the rotation:";
79 for (
size_t i = 0; i < noiseRotation.size(); ++i)
80 cerr <<
" " << noiseRotation[i];
83 Eigen::Matrix3d transNoise = Eigen::Matrix3d::Zero();
84 for (
int i = 0; i < 3; ++i)
85 transNoise(i, i) = std::pow(noiseTranslation[i], 2);
87 Eigen::Matrix3d rotNoise = Eigen::Matrix3d::Zero();
88 for (
int i = 0; i < 3; ++i)
89 rotNoise(i, i) = std::pow(noiseRotation[i], 2);
91 Eigen::Matrix<double, 6, 6> information = Eigen::Matrix<double, 6, 6>::Zero();
92 information.block<3,3>(0,0) = transNoise.inverse();
93 information.block<3,3>(3,3) = rotNoise.inverse();
96 vector<EdgeSE3*> odometryEdges;
97 vector<EdgeSE3*> edges;
99 for (
int f = 0; f < numLaps; ++f){
100 for (
int n = 0; n < nodesPerLevel; ++n) {
104 Eigen::AngleAxisd rotz(-
M_PI + 2*n*
M_PI / nodesPerLevel, Eigen::Vector3d::UnitZ());
105 Eigen::AngleAxisd roty(-0.5*
M_PI +
id*
M_PI / (numLaps * nodesPerLevel), Eigen::Vector3d::UnitY());
106 Eigen::Matrix3d rot = (rotz * roty).toRotationMatrix();
110 t.translation() = t.linear() * Eigen::Vector3d(radius, 0, 0);
112 vertices.push_back(v);
117 for (
size_t i = 1; i < vertices.size(); ++i) {
126 odometryEdges.push_back(e);
131 for (
int f = 1; f < numLaps; ++f) {
132 for (
int nn = 0; nn < nodesPerLevel; ++nn) {
133 VertexSE3* from = vertices[(f-1)*nodesPerLevel + nn];
134 for (
int n = -1; n <= 1; ++n) {
135 if (f == numLaps-1 && n == 1)
137 VertexSE3* to = vertices[f*nodesPerLevel + nn + n];
155 for (
size_t i = 0; i < edges.size(); ++i) {
157 Eigen::Quaterniond gtQuat = (Eigen::Quaterniond)e->
measurement().linear();
158 Eigen::Vector3d gtTrans = e->
measurement().translation();
161 double qw = 1.0 - quatXYZ.norm();
166 Eigen::Quaterniond rot(qw, quatXYZ.x(), quatXYZ.y(), quatXYZ.z());
170 trans = gtTrans + trans;
172 Eigen::Isometry3d noisyMeasurement = (Eigen::Isometry3d) rot;
173 noisyMeasurement.translation() = trans;
178 for (
size_t i =0; i < odometryEdges.size(); ++i) {
187 ofstream fileOutputStream;
188 if (outFilename !=
"-") {
189 cerr <<
"Writing into " << outFilename << endl;
190 fileOutputStream.open(outFilename.c_str());
192 cerr <<
"writing to stdout" << endl;
195 string vertexTag = Factory::instance()->tag(vertices[0]);
196 string edgeTag = Factory::instance()->tag(edges[0]);
198 ostream& fout = outFilename !=
"-" ? fileOutputStream : cout;
199 for (
size_t i = 0; i < vertices.size(); ++i) {
201 fout << vertexTag <<
" " << v->
id() <<
" ";
206 for (
size_t i = 0; i < edges.size(); ++i) {
210 fout << edgeTag <<
" " << from->
id() <<
" " << to->
id() <<
" ";
int id() const
returns the id
const Vertex * vertex(size_t i) const
Command line parsing of argc and argv.
std::set< Vertex * > VertexSet
SampleType generateSample()
virtual bool write(std::ostream &os) const
write the vertex to a stream
void setVertex(size_t i, Vertex *v)
virtual void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
Edge between two 3D pose vertices.
virtual bool write(std::ostream &os) const
write the vertex to a stream
virtual void setId(int id)
sets the id of the node in the graph be sure that the graph keeps consistent after changing the id ...
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the explicitly state the reprensentation poses are represented by poses by VERTEX_XYZRPY In the Quaternions and other representations could be but note that it is up to the SLAM algorithm to choose the internal representation of the angles The keyword is followed by a unique vertex ID and an optional initialization of the or edges in the explicitly state the type of the constraint pose constraints are given by pose constraints by EDGE_XYZRPY The keyword is followed by a unique edge the IDs of the referenced vertices
bool parseArgs(int argc, char **argv, bool exitOnError=true)
virtual void setMeasurement(const Isometry3D &m)
EIGEN_STRONG_INLINE void setInformation(const InformationType &information)
int main(int argc, char **argv)
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
const EstimateType & estimate() const
return the current estimate of the vertex
3D pose Vertex, represented as an Isometry3D
void setDistribution(const CovarianceType &cov)
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge