g2o
Loading...
Searching...
No Matches
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)
 
 ~Slam2DViewer ()
 
virtual void draw ()
 
void init ()
 

Public Attributes

SparseOptimizergraph
 
bool drawCovariance
 
g2o::SparseBlockMatrix< g2o::MatrixXcovariances
 

Detailed Description

Definition at line 29 of file slam2d_viewer.h.

Constructor & Destructor Documentation

◆ Slam2DViewer()

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

Definition at line 129 of file slam2d_viewer.cpp.

130 : QGLViewer(parent, shareWidget), graph(0), drawCovariance(false) {}
SparseOptimizer * graph

◆ ~Slam2DViewer()

g2o::Slam2DViewer::~Slam2DViewer ( )

Definition at line 132 of file slam2d_viewer.cpp.

132{}

Member Function Documentation

◆ draw()

void g2o::Slam2DViewer::draw ( )
virtual

Definition at line 134 of file slam2d_viewer.cpp.

134 {
135 if (!graph) return;
136
137 // drawing the graph
138 glColor4f(0.00f, 0.67f, 1.00f, 1.f);
139 glBegin(GL_TRIANGLES);
140 for (SparseOptimizer::VertexIDMap::iterator it = graph->vertices().begin();
141 it != graph->vertices().end(); ++it) {
142 VertexSE2* v = dynamic_cast<VertexSE2*>(it->second);
143 if (v) {
144 drawSE2(v);
145 }
146 }
147 glEnd();
148
149 glColor4f(1.00f, 0.67f, 0.00f, 1.f);
150 glPointSize(2.f);
151 glBegin(GL_POINTS);
152 for (SparseOptimizer::VertexIDMap::iterator it = graph->vertices().begin();
153 it != graph->vertices().end(); ++it) {
154 VertexPointXY* v = dynamic_cast<VertexPointXY*>(it->second);
155 if (v) {
156 glVertex3f(v->estimate()(0), v->estimate()(1), 0.f);
157 }
158 }
159 glEnd();
160 glPointSize(1.f);
161
162 if (drawCovariance) {
163 for (const auto& vertex_index : graph->vertices()) {
164 VertexSE2* v = dynamic_cast<VertexSE2*>(vertex_index.second);
165 if (!v || v->fixed()) continue;
166 const g2o::MatrixX* covariance =
167 covariances.block(v->hessianIndex(), v->hessianIndex());
168 if (!covariance) continue;
169 drawCov(v->estimate().translation(), *covariance);
170 }
171 }
172}
const VertexIDMap & vertices() const
g2o::SparseBlockMatrix< g2o::MatrixX > covariances
SparseMatrixBlock * block(int r, int c, bool alloc=false)
MatrixN< Eigen::Dynamic > MatrixX
Definition eigen_types.h:74

References g2o::SparseBlockMatrix< MatrixType >::block(), covariances, drawCovariance, g2o::BaseVertex< D, T >::estimate(), g2o::OptimizableGraph::Vertex::fixed(), graph, g2o::OptimizableGraph::Vertex::hessianIndex(), g2o::SE2::translation(), and g2o::HyperGraph::vertices().

◆ init()

void g2o::Slam2DViewer::init ( )

Definition at line 174 of file slam2d_viewer.cpp.

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

Member Data Documentation

◆ covariances

g2o::SparseBlockMatrix<g2o::MatrixX> g2o::Slam2DViewer::covariances

Definition at line 39 of file slam2d_viewer.h.

Referenced by draw().

◆ drawCovariance

bool g2o::Slam2DViewer::drawCovariance

Definition at line 38 of file slam2d_viewer.h.

Referenced by draw().

◆ graph

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: