33#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
34 ((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 6)
35#define qglv_real qreal
37#define qglv_real float
42#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
43 ((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 5)
44#define QGLVIEWER_DEPRECATED_MOUSEBINDING
54class StandardCamera :
public qglviewer::Camera {
62 return Camera::zNear();
69 return Camera::zFar();
72 const bool& standard()
const {
return _standard; }
79void drawSE2(
const VertexSE2* v) {
80 static const double len = 0.2;
81 static Eigen::Vector2d p1(0.75 * len, 0.);
82 static Eigen::Vector2d p2(-0.25 * len, 0.5 * len);
83 static Eigen::Vector2d p3(-0.25 * len, -0.5 * len);
85 const SE2& pose = v->estimate();
87 Eigen::Vector2d aux = pose * p1;
88 glVertex3f(aux[0], aux[1], 0.f);
90 glVertex3f(aux[0], aux[1], 0.f);
92 glVertex3f(aux[0], aux[1], 0.f);
95template <
typename Derived>
96void drawCov(
const Eigen::Vector2d& p,
const Eigen::MatrixBase<Derived>& cov) {
97 const double scalingFactor = 1.;
100 glTranslatef(p.x(), p.y(), 0.f);
102 const typename Derived::Scalar& a = cov(0, 0);
103 const typename Derived::Scalar& b = cov(0, 1);
104 const typename Derived::Scalar& d = cov(1, 1);
107 double D = a * d - b * b;
109 double h = sqrt(0.25 * (T * T) - D);
112 double lambda2 = 0.5 * T - h;
114 double theta = 0.5 * atan2(2.0 * b, a - d);
115 double majorAxis = 3.0 * sqrt(lambda1);
116 double minorAxis = 3.0 * sqrt(lambda2);
118 glRotatef(
RAD2DEG(theta), 0.f, 0.f, 1.f);
119 glScalef(majorAxis * scalingFactor, minorAxis * scalingFactor, 1.f);
120 glColor4f(1.0f, 1.f, 0.f, 0.4f);
122 glColor4f(0.f, 0.f, 0.f, 1.0f);
130 : QGLViewer(parent, shareWidget), graph(0), drawCovariance(false) {}
138 glColor4f(0.00f, 0.67f, 1.00f, 1.f);
139 glBegin(GL_TRIANGLES);
140 for (SparseOptimizer::VertexIDMap::iterator it =
graph->
vertices().begin();
149 glColor4f(1.00f, 0.67f, 0.00f, 1.f);
152 for (SparseOptimizer::VertexIDMap::iterator it =
graph->
vertices().begin();
165 if (!v || v->
fixed())
continue;
168 if (!covariance)
continue;
178 glEnable(GL_LINE_SMOOTH);
180 glEnable(GL_DEPTH_TEST);
181 glShadeModel(GL_SMOOTH);
182 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
187 setStateFileName(QString());
190#ifdef QGLVIEWER_DEPRECATED_MOUSEBINDING
191 setMouseBinding(Qt::NoModifier, Qt::RightButton, CAMERA, ZOOM);
192 setMouseBinding(Qt::NoModifier, Qt::MiddleButton, CAMERA, TRANSLATE);
194 setMouseBinding(Qt::RightButton, CAMERA, ZOOM);
195 setMouseBinding(Qt::MidButton, CAMERA, TRANSLATE);
199 setShortcut(CAMERA_MODE, 0);
200 setShortcut(EXIT_VIEWER, 0);
204 qglviewer::Camera* oldcam = camera();
205 qglviewer::Camera* cam =
new StandardCamera();
207 cam->setPosition(qglviewer::Vec(0., 0., 75.));
208 cam->setUpVector(qglviewer::Vec(0., 1., 0.));
209 cam->lookAt(qglviewer::Vec(0., 0., 0.));
const EstimateType & estimate() const
return the current estimate of the vertex
const VertexIDMap & vertices() const
bool fixed() const
true => this node is fixed during the optimization
const Vector2 & translation() const
translational component
Slam2DViewer(QWidget *parent=NULL, const QGLWidget *shareWidget=0)
g2o::SparseBlockMatrix< g2o::MatrixX > covariances
SparseMatrixBlock * block(int r, int c, bool alloc=false)
2D pose Vertex, (x,y,theta)
void drawDisk(GLfloat radius)
void drawCircle(GLfloat radius, int segments)
MatrixN< Eigen::Dynamic > MatrixX