MRPT  2.0.0
TMRSlamNodeAnnotations.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <cstdint>
13 #include <sstream>
14 #include <string>
15 
16 namespace mrpt::graphs::detail
17 {
18 /**\brief Struct to be used as the NODE_ANNOTATIONS template argument in
19  * CNetworkOfPoses class instances for use in multiple-robot SLAM applications
20  *
21  * \ingroup mrpt_graphs_grp
22  */
24 {
26 
29 
32  : parent_t(other)
33  {
34  this->setAnnots(other);
35  }
36 
38  {
39  auto* annots = new self_t(*this);
40  return annots;
41  }
42  bool setAnnots(const parent_t& other)
43  {
44  parent_t::setAnnots(other);
45 
46  bool res;
47  const auto* mr_slam_annots = dynamic_cast<const self_t*>(&other);
48  if (mr_slam_annots)
49  {
50  this->agent_ID_str = mr_slam_annots->agent_ID_str;
51  this->nodeID_loc = mr_slam_annots->nodeID_loc;
52  res = true;
53  }
54  else
55  {
56  res = false;
57  }
58 
59  return res;
60  }
61 
62  bool operator==(const TNodeAnnotations& other) const override
63  {
64  const auto* mr_slam_annots =
65  dynamic_cast<const TMRSlamNodeAnnotations*>(&other);
66 
67  bool res = false;
68  if (mr_slam_annots)
69  {
70  res =
71  (this->agent_ID_str == mr_slam_annots->agent_ID_str &&
72  this->nodeID_loc == mr_slam_annots->nodeID_loc);
73  }
74 
75  return res;
76  }
77 
78  void getAnnotsAsString(std::string* s) const override
79  {
81 
82  std::stringstream ss;
83  ss << "agent_ID_str: " << agent_ID_str << "| "
84  << "nodeID_loc: " << nodeID_loc;
85 
86  s->clear();
87  *s = ss.str();
88  }
89 
90  /**\brief string identifier of the SLAM Agent that initially registered this
91  * node. */
92  std::string agent_ID_str;
93  /**\brief ID of node in the graph of the SLAM Agent that initially
94  * registered
95  * this node.
96  *
97  * \note Field is handy especially in cases where one SLAM agent
98  * communicates
99  * its local graph to another agent and we still want to keep track of the
100  * node ID in the former's graph.
101  */
103 };
104 } // namespace mrpt::graphs::detail
void getAnnotsAsString(std::string *s) const override
Abstract class from which NodeAnnotations related classes can be implemented.
Internal functions for MRPT.
#define DECLARE_TTYPENAME_CLASSNAME(_CLASSNAME)
Like DECLARE_CUSTOM_TTYPENAME(), but for use within the class declaration body.
Definition: TTypeName.h:104
bool setAnnots(const self_t &other)
Set the properties of the current TNodeAnnotations object.
mrpt::graphs::TNodeID nodeID_loc
ID of node in the graph of the SLAM Agent that initially registered this node.
TMRSlamNodeAnnotations(const TMRSlamNodeAnnotations &other)
std::string agent_ID_str
string identifier of the SLAM Agent that initially registered this node.
bool operator==(const TNodeAnnotations &other) const override
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
Definition: TNodeID.h:16
#define INVALID_NODEID
Definition: TNodeID.h:19
virtual void getAnnotsAsString(std::string *s) const
Struct to be used as the NODE_ANNOTATIONS template argument in CNetworkOfPoses class instances for us...



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020