transform_collection.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  */
30 
39 #ifndef WAREHOUSE_ROS_TF_COLLECTION_H
40 #define WAREHOUSE_ROS_TF_COLLECTION_H
41 
43 #include <tf/transform_listener.h>
44 #include <tf/tfMessage.h>
45 
46 namespace warehouse_ros
47 {
51 {
52 public:
55  virtual tf::StampedTransform lookupTransform(const std::string& target_frame, const std::string& source_frame,
56  double t) const = 0;
57 };
58 
67 {
68 public:
69  TransformCollection(MessageCollection<tf::tfMessage>& coll, const double search_back = 10.0,
70  const double search_forward = 1.0)
71  : TransformSource(), coll_(coll), search_back_(search_back), search_forward_(search_forward)
72  {
73  }
74 
77  tf::StampedTransform lookupTransform(const std::string& target_frame, const std::string& source_frame,
78  double t) const override;
79 
81  void putTransform(tf::StampedTransform);
82 
83 private:
85  double search_back_;
87 };
88 
92 {
93 public:
97  LiveTransformSource(double timeout = 0) : TransformSource(), tf_(new tf::TransformListener()), timeout_(timeout)
98  {
99  }
100 
103  tf::StampedTransform lookupTransform(const std::string& target, const std::string& source, double t) const override
104  {
105  ros::Time tm(t);
106  tf_->waitForTransform(target, source, tm, ros::Duration(timeout_));
107  tf::StampedTransform trans;
108  tf_->lookupTransform(target, source, tm, trans); // Can throw
109  return trans;
110  }
111 
112 private:
116 };
117 
118 } // namespace warehouse_ros
119 
120 #endif // include guard
virtual tf::StampedTransform lookupTransform(const std::string &target_frame, const std::string &source_frame, double t) const =0
boost::shared_ptr< tf::TransformListener > tf_
tf::StampedTransform lookupTransform(const std::string &target, const std::string &source, double t) const override
MessageCollection< tf::tfMessage > coll_
TransformCollection(MessageCollection< tf::tfMessage > &coll, const double search_back=10.0, const double search_forward=1.0)


warehouse_ros
Author(s): Bhaskara Marthi , Connor Brew
autogenerated on Mon Apr 26 2021 02:23:26