g2o
Public Member Functions | Public Attributes | List of all members
g2o::Slam2DViewer Class Reference

#include <slam2d_viewer.h>

Inheritance diagram for g2o::Slam2DViewer:
Inheritance graph
[legend]
Collaboration diagram for g2o::Slam2DViewer:
Collaboration graph
[legend]

Public Member Functions

 Slam2DViewer (QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WFlags flags=0)
 
 ~Slam2DViewer ()
 
virtual void draw ()
 
void init ()
 

Public Attributes

SparseOptimizergraph
 
bool drawCovariance
 

Detailed Description

Definition at line 28 of file slam2d_viewer.h.

Constructor & Destructor Documentation

g2o::Slam2DViewer::Slam2DViewer ( QWidget *  parent = NULL,
const QGLWidget *  shareWidget = 0,
Qt::WFlags  flags = 0 
)

Definition at line 131 of file slam2d_viewer.cpp.

131  :
132  QGLViewer(parent, shareWidget, flags),
133  graph(0), drawCovariance(false)
134 {
135 }
SparseOptimizer * graph
Definition: slam2d_viewer.h:37
g2o::Slam2DViewer::~Slam2DViewer ( )

Definition at line 137 of file slam2d_viewer.cpp.

138 {
139 }

Member Function Documentation

void g2o::Slam2DViewer::draw ( )
virtual

Definition at line 141 of file slam2d_viewer.cpp.

References drawCovariance, g2o::BaseVertex< D, T >::estimate(), graph, and g2o::HyperGraph::vertices().

142 {
143  if (! graph)
144  return;
145 
146  // drawing the graph
147  glColor4f(0.00f, 0.67f, 1.00f, 1.f);
148  glBegin(GL_TRIANGLES);
149  for (SparseOptimizer::VertexIDMap::iterator it = graph->vertices().begin(); it != graph->vertices().end(); ++it) {
150  VertexSE2* v = dynamic_cast<VertexSE2*>(it->second);
151  if (v) {
152  drawSE2(v);
153  }
154  }
155  glEnd();
156 
157  glColor4f(1.00f, 0.67f, 0.00f, 1.f);
158  glPointSize(2.f);
159  glBegin(GL_POINTS);
160  for (SparseOptimizer::VertexIDMap::iterator it = graph->vertices().begin(); it != graph->vertices().end(); ++it) {
161  VertexPointXY* v = dynamic_cast<VertexPointXY*>(it->second);
162  if (v) {
163  glVertex3f(v->estimate()(0), v->estimate()(1), 0.f);
164  }
165  }
166  glEnd();
167  glPointSize(1.f);
168 
169  if (drawCovariance) {
170  for (SparseOptimizer::VertexIDMap::iterator it = graph->vertices().begin(); it != graph->vertices().end(); ++it) {
171  VertexSE2* v = dynamic_cast<VertexSE2*>(it->second);
172  if (v) {
173  // TODO
174  //drawCov(v->estimate().translation(), v->uncertainty());
175  }
176  }
177  }
178 }
SparseOptimizer * graph
Definition: slam2d_viewer.h:37
const VertexIDMap & vertices() const
Definition: hyper_graph.h:225
void g2o::Slam2DViewer::init ( )

Definition at line 180 of file slam2d_viewer.cpp.

References g2o::types_icp::init().

181 {
182  QGLViewer::init();
183 
184  // some default settings i like
185  glEnable(GL_LINE_SMOOTH);
186  glEnable(GL_BLEND);
187  glEnable(GL_DEPTH_TEST);
188  glShadeModel(GL_SMOOTH);
189  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
190 
191  setAxisIsDrawn();
192 
193  // don't save state
194  setStateFileName(QString::null);
195 
196  // mouse bindings
197 #ifdef QGLVIEWER_DEPRECATED_MOUSEBINDING
198  setMouseBinding(Qt::NoModifier, Qt::RightButton, CAMERA, ZOOM);
199  setMouseBinding(Qt::NoModifier, Qt::MidButton, CAMERA, TRANSLATE);
200 #else
201  setMouseBinding(Qt::RightButton, CAMERA, ZOOM);
202  setMouseBinding(Qt::MidButton, CAMERA, TRANSLATE);
203 #endif
204 
205  // keyboard shortcuts
206  setShortcut(CAMERA_MODE, 0);
207  setShortcut(EXIT_VIEWER, 0);
208  //setShortcut(SAVE_SCREENSHOT, 0);
209 
210  // replace camera
211  qglviewer::Camera* oldcam = camera();
212  qglviewer::Camera* cam = new StandardCamera();
213  setCamera(cam);
214  cam->setPosition(qglviewer::Vec(0., 0., 75.));
215  cam->setUpVector(qglviewer::Vec(0., 1., 0.));
216  cam->lookAt(qglviewer::Vec(0., 0., 0.));
217  delete oldcam;
218 }

Member Data Documentation

bool g2o::Slam2DViewer::drawCovariance

Definition at line 38 of file slam2d_viewer.h.

Referenced by draw().

SparseOptimizer* g2o::Slam2DViewer::graph

Definition at line 37 of file slam2d_viewer.h.

Referenced by draw().


The documentation for this class was generated from the following files: