33 #if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && ((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 6) 34 #define qglv_real qreal 36 #define qglv_real float 41 #if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && ((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 5) 42 #define QGLVIEWER_DEPRECATED_MOUSEBINDING 52 class StandardCamera :
public qglviewer::Camera
61 return Camera::zNear();
69 return Camera::zFar();
72 const bool& standard()
const {
return _standard;}
79 void drawSE2(
const VertexSE2* v)
81 static const double len = 0.2;
82 static Eigen::Vector2d p1( 0.75 * len, 0.);
83 static Eigen::Vector2d p2(-0.25 * len, 0.5 * len);
84 static Eigen::Vector2d p3(-0.25 * len, -0.5 * len);
86 const SE2& pose = v->estimate();
88 Eigen::Vector2d aux = pose * p1;
89 glVertex3f(aux[0], aux[1], 0.f);
91 glVertex3f(aux[0], aux[1], 0.f);
93 glVertex3f(aux[0], aux[1], 0.f);
96 template <
typename Derived>
97 void drawCov(
const Eigen::Vector2d& p,
const Eigen::MatrixBase<Derived>& cov)
99 const double scalingFactor = 1.;
102 glTranslatef(p.x(), p.y(), 0.f);
104 const typename Derived::Scalar& a = cov(0, 0);
105 const typename Derived::Scalar& b = cov(0, 1);
106 const typename Derived::Scalar& d = cov(1, 1);
109 double D = a*d - b*b;
111 double h = sqrt(0.25*(T*T) - D);
112 double lambda1 = 0.5*T + h;
113 double lambda2 = 0.5*T - h;
115 double theta = 0.5 * atan2(2.0 * b, a - d);
116 double majorAxis = 3.0 * sqrt(lambda1);
117 double minorAxis = 3.0 * sqrt(lambda2);
120 glRotatef(
RAD2DEG(theta), 0.f, 0.f, 1.f);
121 glScalef(majorAxis * scalingFactor, minorAxis * scalingFactor, 1.f);
122 glColor4f(1.0f, 1.f, 0.f, 0.4f);
124 glColor4f(0.f, 0.f, 0.f, 1.0f);
131 Slam2DViewer::Slam2DViewer(QWidget* parent,
const QGLWidget* shareWidget, Qt::WFlags flags) :
132 QGLViewer(parent, shareWidget, flags),
133 graph(0), drawCovariance(false)
147 glColor4f(0.00f, 0.67f, 1.00f, 1.f);
148 glBegin(GL_TRIANGLES);
157 glColor4f(1.00f, 0.67f, 0.00f, 1.f);
185 glEnable(GL_LINE_SMOOTH);
187 glEnable(GL_DEPTH_TEST);
188 glShadeModel(GL_SMOOTH);
189 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
194 setStateFileName(QString::null);
197 #ifdef QGLVIEWER_DEPRECATED_MOUSEBINDING 198 setMouseBinding(Qt::NoModifier, Qt::RightButton, CAMERA, ZOOM);
199 setMouseBinding(Qt::NoModifier, Qt::MidButton, CAMERA, TRANSLATE);
201 setMouseBinding(Qt::RightButton, CAMERA, ZOOM);
202 setMouseBinding(Qt::MidButton, CAMERA, TRANSLATE);
206 setShortcut(CAMERA_MODE, 0);
207 setShortcut(EXIT_VIEWER, 0);
211 qglviewer::Camera* oldcam = camera();
212 qglviewer::Camera* cam =
new StandardCamera();
214 cam->setPosition(qglviewer::Vec(0., 0., 75.));
215 cam->setUpVector(qglviewer::Vec(0., 1., 0.));
216 cam->lookAt(qglviewer::Vec(0., 0., 0.));
void drawDisk(GLfloat radius)
2D pose Vertex, (x,y,theta)
void drawCircle(GLfloat radius, int segments)
const VertexIDMap & vertices() const
const EstimateType & estimate() const
return the current estimate of the vertex
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the graph