g2o
commands.h
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 #ifndef COMMANDS_H
28 #define COMMANDS_H
29 
30 #include <vector>
31 #include <string>
32 
33 namespace SlamParser {
34 
36  {
42  };
43 
45  {
46  public:
47  CommandNode(CommandType commandType, const std::string& tag) : _commandType(commandType), _tag(tag) {}
48  virtual ~CommandNode() {}
50  const std::string& tag() const { return _tag;}
51  protected:
53  std::string _tag;
54  };
55 
56  class AddNode : public CommandNode
57  {
58  public:
59  AddNode(const std::string& tag, int id, int dimension, const std::vector<double>& values = std::vector<double>()) :
61  _id(id), _dimension(dimension), _values(values)
62  {
63  }
64 
65  int id() const {return _id;}
66  int dimension() const {return _dimension;}
67  const std::vector<double>& values() { return _values;}
68 
69  protected:
70  int _id;
72  std::vector<double> _values;
73  };
74 
75  class AddEdge : public CommandNode
76  {
77  public:
78  AddEdge(const std::string& tag, int id, int dimension, int id1, int id2, const std::vector<double>& values, const std::vector<double> information) :
80  _id(id), _dimension(dimension), _id1(id1), _id2(id2), _values(values), _information(information)
81  {
82  }
83 
84  int id() const {return _id;}
85  int dimension() const {return _dimension;}
86  int id1() const {return _id1;}
87  int id2() const {return _id2;}
88  const std::vector<double>& values() { return _values;}
89  const std::vector<double>& information() { return _information;}
90 
91  protected:
92  int _id;
94  int _id1;
95  int _id2;
96  std::vector<double> _values;
97  std::vector<double> _information;
98  };
99 
100  class SolveSate : public CommandNode
101  {
102  public:
103  SolveSate(const std::string& tag) :
105  {
106  }
107  };
108 
109  class QueryState : public CommandNode
110  {
111  public:
112  explicit QueryState(const std::string& tag, const std::vector<int>& ids = std::vector<int>()) :
113  CommandNode(CT_QUERY_STATE, tag), _ids(ids)
114  {
115  }
116  const std::vector<int>& ids() { return _ids;}
117  protected:
118  std::vector<int> _ids;
119  };
120 
121  class FixNode : public CommandNode
122  {
123  public:
124  explicit FixNode(const std::string& tag, const std::vector<int>& ids) :
125  CommandNode(CT_FIX, tag), _ids(ids)
126  {
127  }
128  const std::vector<int>& ids() { return _ids;}
129  protected:
130  std::vector<int> _ids;
131  };
132 
133 } // end namespace
134 
135 #endif
int id1() const
Definition: commands.h:86
int id() const
Definition: commands.h:84
const std::vector< double > & values()
Definition: commands.h:88
CommandType commandType() const
Definition: commands.h:49
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the explicitly state the reprensentation poses are represented by poses by VERTEX_XYZRPY In the Quaternions and other representations could be but note that it is up to the SLAM algorithm to choose the internal representation of the angles The keyword is followed by a unique vertex ID and an optional initialization of the values
Definition: protocol.txt:7
std::vector< double > _information
Definition: commands.h:97
int id() const
Definition: commands.h:65
AddEdge(const std::string &tag, int id, int dimension, int id1, int id2, const std::vector< double > &values, const std::vector< double > information)
Definition: commands.h:78
CommandNode(CommandType commandType, const std::string &tag)
Definition: commands.h:47
const std::vector< double > & values()
Definition: commands.h:67
std::vector< double > _values
Definition: commands.h:72
QueryState(const std::string &tag, const std::vector< int > &ids=std::vector< int >())
Definition: commands.h:112
SolveSate(const std::string &tag)
Definition: commands.h:103
std::vector< int > _ids
Definition: commands.h:130
const std::vector< int > & ids()
Definition: commands.h:116
FixNode(const std::string &tag, const std::vector< int > &ids)
Definition: commands.h:124
const std::string & tag() const
Definition: commands.h:50
const std::vector< int > & ids()
Definition: commands.h:128
AddNode(const std::string &tag, int id, int dimension, const std::vector< double > &values=std::vector< double >())
Definition: commands.h:59
std::vector< double > _values
Definition: commands.h:96
const std::vector< double > & information()
Definition: commands.h:89
virtual ~CommandNode()
Definition: commands.h:48
std::vector< int > _ids
Definition: commands.h:118
std::string _tag
Definition: commands.h:53
int dimension() const
Definition: commands.h:66
int dimension() const
Definition: commands.h:85
int id2() const
Definition: commands.h:87
CommandType _commandType
Definition: commands.h:52