time_cache.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 /*
3  * Copyright (c) 2008, Willow Garage, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, 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  * * Neither the name of the Willow Garage, Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
33 #ifndef TF2_TIME_CACHE_H
34 #define TF2_TIME_CACHE_H
35 
36 #include "transform_storage.h"
37 
38 #include <deque>
39 
40 #include <sstream>
41 
42 #include <ros/message_forward.h>
43 #include <ros/time.h>
44 
45 #include <memory>
46 
47 namespace geometry_msgs
48 {
50 }
51 
52 namespace tf2
53 {
54 
55 typedef std::pair<ros::Time, CompactFrameID> P_TimeAndFrameID;
56 
57 class TimeCacheInterface
58 {
59 public:
61  virtual bool getData(ros::Time time, TransformStorage & data_out, std::string* error_str = 0)=0; //returns false if data unavailable (should be thrown as lookup exception
62 
64  virtual bool insertData(const TransformStorage& new_data)=0;
65 
67  virtual void clearList()=0;
68 
70  virtual CompactFrameID getParent(ros::Time time, std::string* error_str) = 0;
71 
76 
77 
79 
80  virtual unsigned int getListLength()=0;
81 
83  virtual ros::Time getLatestTimestamp()=0;
84 
86  virtual ros::Time getOldestTimestamp()=0;
87 };
88 
89 typedef std::shared_ptr<TimeCacheInterface> TimeCacheInterfacePtr;
90 
95 class TimeCache : public TimeCacheInterface
96 {
97  public:
98  static const int MIN_INTERPOLATION_DISTANCE = 5;
99  static const unsigned int MAX_LENGTH_LINKED_LIST = 1000000;
100  static const int64_t DEFAULT_MAX_STORAGE_TIME = 10ULL * 1000000000LL;
101 
102  TimeCache(ros::Duration max_storage_time = ros::Duration().fromNSec(DEFAULT_MAX_STORAGE_TIME));
103 
104 
106 
107  virtual bool getData(ros::Time time, TransformStorage & data_out, std::string* error_str = 0);
108  virtual bool insertData(const TransformStorage& new_data);
109  virtual void clearList();
110  virtual CompactFrameID getParent(ros::Time time, std::string* error_str);
112 
114  virtual unsigned int getListLength();
115  virtual ros::Time getLatestTimestamp();
116  virtual ros::Time getOldestTimestamp();
117 
118 
119 private:
120  typedef std::deque<TransformStorage> L_TransformStorage;
122 
124 
125 
127  //Assumes storage is already locked for it
128  inline uint8_t findClosest(TransformStorage*& one, TransformStorage*& two, ros::Time target_time, std::string* error_str);
129 
130  inline void interpolate(const TransformStorage& one, const TransformStorage& two, ros::Time time, TransformStorage& output);
131 
132 
133  void pruneList();
134 
135 
136 
137 };
138 
139 class StaticCache : public TimeCacheInterface
140 {
141  public:
143 
144  virtual bool getData(ros::Time time, TransformStorage & data_out, std::string* error_str = 0); //returns false if data unavailable (should be thrown as lookup exception
145  virtual bool insertData(const TransformStorage& new_data);
146  virtual void clearList();
147  virtual CompactFrameID getParent(ros::Time time, std::string* error_str);
149 
150 
152  virtual unsigned int getListLength();
153  virtual ros::Time getLatestTimestamp();
154  virtual ros::Time getOldestTimestamp();
155 
156 
157 private:
158  TransformStorage storage_;
159 };
160 
161 }
162 
163 #endif // TF2_TIME_CACHE_H
P_TimeAndFrameID
std::pair< ros::Time, CompactFrameID > P_TimeAndFrameID
tf2::TimeCache::max_storage_time_
ros::Duration max_storage_time_
Definition: time_cache.h:123
tf2::TimeCache::MIN_INTERPOLATION_DISTANCE
static const int MIN_INTERPOLATION_DISTANCE
Number of nano-seconds to not interpolate below.
Definition: time_cache.h:98
tf2::TimeCache::getOldestTimestamp
virtual ros::Time getOldestTimestamp()
tf2::StaticCache::storage_
TransformStorage storage_
Definition: time_cache.h:158
tf2::StaticCache::insertData
virtual bool insertData(const TransformStorage &new_data, std::string *error_str=0)
tf2::TimeCacheInterface::getListLength
virtual unsigned int getListLength()=0
tf2::StaticCache::getListLength
virtual unsigned int getListLength()
tf2::TimeCacheInterfacePtr
boost::shared_ptr< TimeCacheInterface > TimeCacheInterfacePtr
Definition: time_cache.h:89
geometry_msgs
geometry_msgs::TransformStamped
::geometry_msgs::TransformStamped_< std::allocator< void > > TransformStamped
Definition: TransformStamped.h:60
tf2::TimeCache::L_TransformStorage
std::deque< TransformStorage > L_TransformStorage
tf2::TimeCache::insertData
virtual bool insertData(const TransformStorage &new_data, std::string *error_str=0)
tf2::TimeCacheInterface::getParent
virtual CompactFrameID getParent(ros::Time time, std::string *error_str)=0
tf2::TimeCache::clearList
virtual void clearList()
tf2::StaticCache::getData
virtual bool getData(ros::Time time, TransformStorage &data_out, std::string *error_str=0)
tf2::TimeCache::pruneList
void pruneList()
tf2::TimeCache::getParent
virtual CompactFrameID getParent(ros::Time time, std::string *error_str)
tf2::TimeCache::MAX_LENGTH_LINKED_LIST
static const unsigned int MAX_LENGTH_LINKED_LIST
Maximum length of linked list, to make sure not to be able to use unlimited memory.
Definition: time_cache.h:99
tf2::StaticCache::getLatestTimestamp
virtual ros::Time getLatestTimestamp()
tf2::TimeCache::interpolate
void interpolate(const TransformStorage &one, const TransformStorage &two, ros::Time time, TransformStorage &output)
tf2::TimeCache::DEFAULT_MAX_STORAGE_TIME
static const int64_t DEFAULT_MAX_STORAGE_TIME
default value of 10 seconds storage
Definition: time_cache.h:100
tf2::TimeCacheInterface::insertData
virtual bool insertData(const TransformStorage &new_data, std::string *error_str=0)=0
tf2::TimeCacheInterface::getOldestTimestamp
virtual ros::Time getOldestTimestamp()=0
CompactFrameID
uint32_t CompactFrameID
tf2::TimeCache::getListLength
virtual unsigned int getListLength()
tf2::StaticCache::getLatestTimeAndParent
virtual P_TimeAndFrameID getLatestTimeAndParent()
tf2::TimeCache::findClosest
uint8_t findClosest(TransformStorage *&one, TransformStorage *&two, ros::Time target_time, std::string *error_str)
tf2::TimeCache::storage_
L_TransformStorage storage_
Definition: time_cache.h:121
tf2::TimeCacheInterface::clearList
virtual void clearList()=0
transform_storage.h
geometry_msgs::ROS_DECLARE_MESSAGE
ROS_DECLARE_MESSAGE(TransformStamped)
tf2::TimeCacheInterface::getLatestTimestamp
virtual ros::Time getLatestTimestamp()=0
tf2::TimeCache::getData
virtual bool getData(ros::Time time, TransformStorage &data_out, std::string *error_str=0)
tf2::StaticCache::getParent
virtual CompactFrameID getParent(ros::Time time, std::string *error_str)
tf2::P_TimeAndFrameID
std::pair< ros::Time, CompactFrameID > P_TimeAndFrameID
Definition: time_cache.h:55
tf2::TimeCache::getLatestTimestamp
virtual ros::Time getLatestTimestamp()
ros::Time
tf2::TimeCacheInterface::getData
virtual bool getData(ros::Time time, TransformStorage &data_out, std::string *error_str=0)=0
tf2
tf2::TimeCache::TimeCache
TimeCache(ros::Duration max_storage_time=ros::Duration().fromNSec(DEFAULT_MAX_STORAGE_TIME))
sick_scan_base.h
tf2::TimeCacheInterface::getLatestTimeAndParent
virtual P_TimeAndFrameID getLatestTimeAndParent()=0
tf2::StaticCache::clearList
virtual void clearList()
tf2::StaticCache::getOldestTimestamp
virtual ros::Time getOldestTimestamp()
tf2::TimeCache::getLatestTimeAndParent
virtual P_TimeAndFrameID getLatestTimeAndParent()
ros::Duration


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12