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 
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
warehouse_ros::LiveTransformSource::nh_
ros::NodeHandle nh_
Definition: transform_collection.h:113
warehouse_ros::TransformCollection::search_back_
double search_back_
Definition: transform_collection.h:85
warehouse_ros::TransformCollection::lookupTransform
tf::StampedTransform lookupTransform(const std::string &target_frame, const std::string &source_frame, double t) const override
Definition: transform_collection.cpp:44
boost::shared_ptr< tf::TransformListener >
warehouse_ros::LiveTransformSource::tf_
boost::shared_ptr< tf::TransformListener > tf_
Definition: transform_collection.h:114
warehouse_ros::LiveTransformSource::timeout_
ros::Duration timeout_
Definition: transform_collection.h:115
warehouse_ros::MessageCollection< tf::tfMessage >
tf::StampedTransform
warehouse_ros::TransformCollection::search_forward_
double search_forward_
Definition: transform_collection.h:86
warehouse_ros::TransformSource::lookupTransform
virtual tf::StampedTransform lookupTransform(const std::string &target_frame, const std::string &source_frame, double t) const =0
warehouse_ros::TransformCollection::putTransform
void putTransform(tf::StampedTransform)
Put the transform into the collection.
Definition: transform_collection.cpp:74
warehouse_ros::LiveTransformSource::LiveTransformSource
LiveTransformSource(double timeout=0)
Definition: transform_collection.h:97
warehouse_ros::TransformCollection::coll_
MessageCollection< tf::tfMessage > coll_
Definition: transform_collection.h:84
warehouse_ros::LiveTransformSource
Definition: transform_collection.h:91
transform_listener.h
ros::Time
message_collection.h
warehouse_ros::LiveTransformSource::lookupTransform
tf::StampedTransform lookupTransform(const std::string &target, const std::string &source, double t) const override
Definition: transform_collection.h:103
tf
warehouse_ros::TransformSource
Definition: transform_collection.h:50
warehouse_ros
Definition: database_connection.h:44
warehouse_ros::TransformCollection
Definition: transform_collection.h:66
ros::Duration
ros::NodeHandle
warehouse_ros::TransformCollection::TransformCollection
TransformCollection(MessageCollection< tf::tfMessage > &coll, const double search_back=10.0, const double search_forward=1.0)
Definition: transform_collection.h:69


warehouse_ros
Author(s): Bhaskara Marthi , Connor Brew
autogenerated on Wed Oct 16 2024 02:42:07