time_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
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  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
32 #ifndef TF2_TIME_CACHE_H
33 #define TF2_TIME_CACHE_H
34 
35 #include "transform_storage.h"
36 
37 #include <deque>
38 
39 #include <sstream>
40 
41 #include <ros/message_forward.h>
42 #include <ros/time.h>
43 
44 #include <boost/shared_ptr.hpp>
45 
46 namespace geometry_msgs
47 {
48 ROS_DECLARE_MESSAGE(TransformStamped);
49 }
50 
51 namespace tf2
52 {
53 
54 typedef std::pair<ros::Time, CompactFrameID> P_TimeAndFrameID;
55 
57 {
58 public:
60  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
61 
63  virtual bool insertData(const TransformStorage& new_data)=0;
64 
66  virtual void clearList()=0;
67 
69  virtual CompactFrameID getParent(ros::Time time, std::string* error_str) = 0;
70 
74  virtual P_TimeAndFrameID getLatestTimeAndParent() = 0;
75 
76 
78 
79  virtual unsigned int getListLength()=0;
80 
82  virtual ros::Time getLatestTimestamp()=0;
83 
85  virtual ros::Time getOldestTimestamp()=0;
86 };
87 
89 
95 {
96  public:
97  static const int MIN_INTERPOLATION_DISTANCE = 5;
98  static const unsigned int MAX_LENGTH_LINKED_LIST = 1000000;
99  static const int64_t DEFAULT_MAX_STORAGE_TIME = 10ULL * 1000000000LL;
100 
101  TimeCache(ros::Duration max_storage_time = ros::Duration().fromNSec(DEFAULT_MAX_STORAGE_TIME));
102 
103 
105 
106  virtual bool getData(ros::Time time, TransformStorage & data_out, std::string* error_str = 0);
107  virtual bool insertData(const TransformStorage& new_data);
108  virtual void clearList();
109  virtual CompactFrameID getParent(ros::Time time, std::string* error_str);
110  virtual P_TimeAndFrameID getLatestTimeAndParent();
111 
113  virtual unsigned int getListLength();
114  virtual ros::Time getLatestTimestamp();
115  virtual ros::Time getOldestTimestamp();
116 
117 
118 private:
119  typedef std::deque<TransformStorage> L_TransformStorage;
120  L_TransformStorage storage_;
121 
123 
124 
126  //Assumes storage is already locked for it
127  inline uint8_t findClosest(TransformStorage*& one, TransformStorage*& two, ros::Time target_time, std::string* error_str);
128 
129  inline void interpolate(const TransformStorage& one, const TransformStorage& two, ros::Time time, TransformStorage& output);
130 
131 
132  void pruneList();
133 
134 
135 
136 };
137 
139 {
140  public:
142 
143  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
144  virtual bool insertData(const TransformStorage& new_data);
145  virtual void clearList();
146  virtual CompactFrameID getParent(ros::Time time, std::string* error_str);
147  virtual P_TimeAndFrameID getLatestTimeAndParent();
148 
149 
151  virtual unsigned int getListLength();
152  virtual ros::Time getLatestTimestamp();
153  virtual ros::Time getOldestTimestamp();
154 
155 
156 private:
158 };
159 
160 }
161 
162 #endif // TF2_TIME_CACHE_H
uint32_t CompactFrameID
ROS_DECLARE_MESSAGE(TransformStamped)
std::deque< TransformStorage > L_TransformStorage
Definition: time_cache.h:119
ros::Duration max_storage_time_
Definition: time_cache.h:122
L_TransformStorage storage_
Definition: time_cache.h:120
std::pair< ros::Time, CompactFrameID > P_TimeAndFrameID
Definition: buffer_core.h:57
Storage for transforms and their parent.
boost::shared_ptr< TimeCacheInterface > TimeCacheInterfacePtr
Definition: buffer_core.h:61
A class to keep a sorted linked list in time This builds and maintains a list of timestamped data...
Definition: time_cache.h:94
TransformStorage storage_
Definition: time_cache.h:157


tf2
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Fri Oct 16 2020 19:08:50