g2o
Loading...
Searching...
No Matches
slam_context_interface.cpp
Go to the documentation of this file.
1// g2o - General Graph Optimization
2// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
28
29#include <iostream>
30
33using namespace std;
34
35namespace SlamParser {
36
39
41
43 if (!_slam) {
44 return true;
45 }
46 switch (commandNode->commandType()) {
47 case CT_ADD_NODE: {
48 AddNode* c = static_cast<AddNode*>(commandNode);
49 return _slam->addNode(c->tag(), c->id(), c->dimension(), c->values());
50 }
51 case CT_ADD_EDGE: {
52 AddEdge* c = static_cast<AddEdge*>(commandNode);
53 return _slam->addEdge(c->tag(), c->id(), c->dimension(), c->id1(),
54 c->id2(), c->values(), c->information());
55 }
56 case CT_SOLVE_STATE: {
57 // SolveState* c = static_cast<SolveState*>(commandNode);
58 return _slam->solveState();
59 }
60 case CT_QUERY_STATE: {
61 QueryState* c = static_cast<QueryState*>(commandNode);
62 return _slam->queryState(c->ids());
63 }
64 case CT_FIX: {
65 FixNode* c = static_cast<FixNode*>(commandNode);
66 return _slam->fixNode(c->ids());
67 }
68 }
69 cerr << "SlamContextInterface::process: Unknown command type" << endl;
70 return false;
71}
72
73} // namespace SlamParser
interface for communicating with the SLAM algorithm
virtual bool fixNode(const std::vector< int > &nodes)=0
virtual bool addEdge(const std::string &tag, int id, int dimension, int v1, int v2, const std::vector< double > &measurement, const std::vector< double > &information)=0
virtual bool queryState(const std::vector< int > &nodes)=0
virtual bool addNode(const std::string &tag, int id, int dimension, const std::vector< double > &values)=0
int id() const
Definition commands.h:88
int id2() const
Definition commands.h:91
int dimension() const
Definition commands.h:89
int id1() const
Definition commands.h:90
const std::vector< double > & values()
Definition commands.h:92
const std::vector< double > & information()
Definition commands.h:93
const std::vector< double > & values()
Definition commands.h:67
int dimension() const
Definition commands.h:66
int id() const
Definition commands.h:65
const std::string & tag() const
Definition commands.h:49
CommandType commandType() const
Definition commands.h:48
const std::vector< int > & ids()
Definition commands.h:124
const std::vector< int > & ids()
Definition commands.h:114
bool process(CommandNode *commandNode)
SlamContextInterface(AbstractSlamInterface *slam)
@ CT_ADD_EDGE
Definition commands.h:37
@ CT_ADD_NODE
Definition commands.h:36
@ CT_QUERY_STATE
Definition commands.h:39
@ CT_SOLVE_STATE
Definition commands.h:38
Definition jet.h:876