g2o
Loading...
Searching...
No Matches
g2o
examples
interactive_slam
slam_parser
interface
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
27
#include "
slam_context_interface.h
"
28
29
#include <iostream>
30
31
#include "
abstract_slam_interface.h
"
32
#include "
slam_parser/parser/commands.h
"
33
using namespace
std
;
34
35
namespace
SlamParser
{
36
37
SlamContextInterface::SlamContextInterface
(
AbstractSlamInterface
* slam)
38
:
SlamContext
(),
_slam
(slam) {}
39
40
SlamContextInterface::~SlamContextInterface
() {}
41
42
bool
SlamContextInterface::process
(
CommandNode
* commandNode) {
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
abstract_slam_interface.h
SlamParser::AbstractSlamInterface
interface for communicating with the SLAM algorithm
Definition
abstract_slam_interface.h:40
SlamParser::AddEdge
Definition
commands.h:75
SlamParser::AddEdge::id
int id() const
Definition
commands.h:88
SlamParser::AddEdge::id2
int id2() const
Definition
commands.h:91
SlamParser::AddEdge::dimension
int dimension() const
Definition
commands.h:89
SlamParser::AddEdge::id1
int id1() const
Definition
commands.h:90
SlamParser::AddEdge::values
const std::vector< double > & values()
Definition
commands.h:92
SlamParser::AddEdge::information
const std::vector< double > & information()
Definition
commands.h:93
SlamParser::AddNode
Definition
commands.h:56
SlamParser::AddNode::values
const std::vector< double > & values()
Definition
commands.h:67
SlamParser::AddNode::dimension
int dimension() const
Definition
commands.h:66
SlamParser::AddNode::id
int id() const
Definition
commands.h:65
SlamParser::CommandNode
Definition
commands.h:43
SlamParser::CommandNode::tag
const std::string & tag() const
Definition
commands.h:49
SlamParser::CommandNode::commandType
CommandType commandType() const
Definition
commands.h:48
SlamParser::FixNode
Definition
commands.h:120
SlamParser::FixNode::ids
const std::vector< int > & ids()
Definition
commands.h:124
SlamParser::QueryState
Definition
commands.h:109
SlamParser::QueryState::ids
const std::vector< int > & ids()
Definition
commands.h:114
SlamParser::SlamContextInterface::process
bool process(CommandNode *commandNode)
Definition
slam_context_interface.cpp:42
SlamParser::SlamContextInterface::~SlamContextInterface
~SlamContextInterface()
Definition
slam_context_interface.cpp:40
SlamParser::SlamContextInterface::SlamContextInterface
SlamContextInterface(AbstractSlamInterface *slam)
Definition
slam_context_interface.cpp:37
SlamParser::SlamContextInterface::_slam
AbstractSlamInterface * _slam
Definition
slam_context_interface.h:46
SlamParser::SlamContext::SlamContext
SlamContext()
Definition
slam_context.cpp:36
commands.h
SlamParser
Definition
abstract_slam_interface.h:33
SlamParser::CT_ADD_EDGE
@ CT_ADD_EDGE
Definition
commands.h:37
SlamParser::CT_ADD_NODE
@ CT_ADD_NODE
Definition
commands.h:36
SlamParser::CT_QUERY_STATE
@ CT_QUERY_STATE
Definition
commands.h:39
SlamParser::CT_SOLVE_STATE
@ CT_SOLVE_STATE
Definition
commands.h:38
SlamParser::CT_FIX
@ CT_FIX
Definition
commands.h:40
std
Definition
jet.h:876
slam_context_interface.h
Generated on
for g2o by
1.15.0