Statistics.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
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 met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING 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 
29 #include <rtabmap/utilite/UStl.h>
31 
32 namespace rtabmap {
33 std::map<std::string, float> Statistics::_defaultData;
35 
36 const std::map<std::string, float> & Statistics::defaultData()
37 {
38  Statistics stat;
39  return _defaultData;
40 }
41 
42 std::string Statistics::serializeData(const std::map<std::string, float> & data)
43 {
44  std::stringstream output;
45  for(std::map<std::string, float>::const_iterator iter=data.begin(); iter!=data.end(); ++iter)
46  {
47  if(iter != data.begin())
48  {
49  output << ";";
50  }
51  // make sure there are no commas instead of dots
52  output << iter->first << ":" << uReplaceChar(uNumber2Str(iter->second), ',', '.');
53  }
54  return output.str();
55 }
56 
57 std::map<std::string, float> Statistics::deserializeData(const std::string & data)
58 {
59  std::map<std::string, float> output;
60  std::list<std::string> tuplets = uSplit(data, ';');
61  for(std::list<std::string>::iterator iter=tuplets.begin(); iter!=tuplets.end(); ++iter)
62  {
63  std::list<std::string> p = uSplit(*iter, ':');
64  if(p.size() == 2)
65  {
66  std::string key = p.front();
67  std::string value = p.back();
68  uInsert(output, std::make_pair(key, uStr2Float(value)));
69  }
70  }
71  return output;
72 }
73 
75  _extended(0),
76  _refImageId(0),
77  _refImageMapId(-1),
78  _loopClosureId(0),
79  _loopClosureMapId(-1),
80  _proximiyDetectionId(0),
81  _proximiyDetectionMapId(-1),
82  _stamp(0.0f),
83  _currentGoalId(0)
84 {
86 }
87 
89 {
90 }
91 
92 // name format = "Grp/Name/unit"
93 void Statistics::addStatistic(const std::string & name, float value)
94 {
95  uInsert(_data, std::pair<std::string, float>(name, value));
96 }
97 
98 //deprecated
100 {
101  _signaturesData.insert(std::make_pair(data.id(), data));
102 }
103 
104 }
name
rtabmap::Statistics
Definition: Statistics.h:53
rtabmap::Statistics::Statistics
Statistics()
Definition: Statistics.cpp:74
rtabmap::Statistics::_data
std::map< std::string, float > _data
Definition: Statistics.h:333
uInsert
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)
Definition: UStl.h:441
rtabmap::Statistics::data
const std::map< std::string, float > & data() const
Definition: Statistics.h:292
uNumber2Str
std::string UTILITE_EXPORT uNumber2Str(unsigned int number)
Definition: UConversion.cpp:91
UConversion.h
Some conversion functions.
rtabmap::Statistics::serializeData
static std::string serializeData(const std::map< std::string, float > &data)
Definition: Statistics.cpp:42
rtabmap::Statistics::defaultData
static const std::map< std::string, float > & defaultData()
Definition: Statistics.cpp:36
p
Point3_ p(2)
rtabmap::Statistics::deserializeData
static std::map< std::string, float > deserializeData(const std::string &data)
Definition: Statistics.cpp:57
key
const gtsam::Symbol key( 'X', 0)
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
uReplaceChar
std::string UTILITE_EXPORT uReplaceChar(const std::string &str, char before, char after)
Definition: UConversion.cpp:33
rtabmap::Statistics::setLastSignatureData
RTABMAP_DEPRECATED void setLastSignatureData(const Signature &data)
Definition: Statistics.cpp:99
uSplit
std::list< std::string > uSplit(const std::string &str, char separator=' ')
Definition: UStl.h:564
iter
iterator iter(handle obj)
UStl.h
Wrappers of STL for convenient functions.
rtabmap::Statistics::~Statistics
virtual ~Statistics()
Definition: Statistics.cpp:88
Statistics.h
rtabmap::Statistics::addStatistic
void addStatistic(const std::string &name, float value)
Definition: Statistics.cpp:93
rtabmap::Statistics::_defaultDataInitialized
static bool _defaultDataInitialized
Definition: Statistics.h:335
rtabmap::Statistics::_defaultData
static std::map< std::string, float > _defaultData
Definition: Statistics.h:334
uStr2Float
float UTILITE_EXPORT uStr2Float(const std::string &str)
Definition: UConversion.cpp:138
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::Statistics::_signaturesData
std::map< int, Signature > _signaturesData
Definition: Statistics.h:305
value
value
rtabmap::Signature
Definition: Signature.h:48


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jul 1 2024 02:42:39