transform_provider.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Suat Gedikli */
36 
37 #pragma once
38 
39 #include <string>
43 #include <map>
44 
45 namespace tf2_ros
46 {
47 class TransformListener;
48 class Buffer;
49 } // namespace tf2_ros
50 
56 {
57 public:
63  TransformProvider(double update_rate = 30.);
64 
67 
75  bool getTransform(mesh_filter::MeshHandle handle, Eigen::Isometry3d& transform) const;
76 
83  void addHandle(mesh_filter::MeshHandle handle, const std::string& name);
84 
90  void setFrame(const std::string& frame);
91 
96  void start();
97 
102  void stop();
103 
110  void setUpdateRate(double update_rate);
111 
112 private:
118  void updateTransforms();
119 
120  MOVEIT_CLASS_FORWARD(TransformContext); // Defines TransformContextPtr, ConstPtr, WeakPtr... etc
121 
127  {
128  public:
129  TransformContext(const std::string& name) : frame_id_(name)
130  {
131  transformation_.matrix().setZero();
132  }
133  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
134  std::string frame_id_;
135  Eigen::Isometry3d transformation_;
136  std::mutex mutex_;
137  };
138 
143  void run();
144 
146  std::map<mesh_filter::MeshHandle, TransformContextPtr> handle2context_;
147 
149  std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
150  std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
151 
153  planning_scene_monitor::PlanningSceneMonitorPtr psm_;
154 
156  std::string frame_id_;
157 
159  std::thread thread_;
160 
162  bool stop_;
163 
166 };
TransformProvider::TransformProvider
TransformProvider(double update_rate=30.)
Constructor.
Definition: transform_provider.cpp:42
TransformProvider::updateTransforms
void updateTransforms()
this method is called periodically by the dedicated thread and updates all the transformations of the...
Definition: transform_provider.cpp:122
TransformProvider::setFrame
void setFrame(const std::string &frame)
sets the camera frame id. The returned transformations are in respect to this coordinate frame
Definition: transform_provider.cpp:75
TransformProvider::~TransformProvider
~TransformProvider()
Destructor.
Definition: transform_provider.cpp:50
TransformProvider::MOVEIT_CLASS_FORWARD
MOVEIT_CLASS_FORWARD(TransformContext)
TransformProvider::setUpdateRate
void setUpdateRate(double update_rate)
sets the update rate in Hz. This should be slow enough to reduce the system load but fast enough to g...
Definition: transform_provider.cpp:117
transform
template Halfspace< double > transform(const Halfspace< double > &a, const Transform3< double > &tf)
TransformProvider::update_rate_
ros::Rate update_rate_
update rate in Hz
Definition: transform_provider.h:165
TransformProvider::addHandle
void addHandle(mesh_filter::MeshHandle handle, const std::string &name)
registers a mesh with its handle
Definition: transform_provider.cpp:67
TransformProvider::TransformContext::frame_id_
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::string frame_id_
Definition: transform_provider.h:134
TransformProvider::tf_buffer_
std::shared_ptr< tf2_ros::Buffer > tf_buffer_
Definition: transform_provider.h:150
TransformProvider::psm_
planning_scene_monitor::PlanningSceneMonitorPtr psm_
SceneMonitor used to get current states.
Definition: transform_provider.h:153
TransformProvider::frame_id_
std::string frame_id_
the camera frame id
Definition: transform_provider.h:156
name
std::string name
tf2_ros
planning_scene_monitor.h
TransformProvider::TransformContext::transformation_
Eigen::Isometry3d transformation_
Definition: transform_provider.h:135
TransformProvider::stop_
bool stop_
Definition: transform_provider.h:162
TransformProvider::TransformContext::mutex_
std::mutex mutex_
Definition: transform_provider.h:136
TransformProvider::TransformContext
Context Object for registered frames.
Definition: transform_provider.h:126
TransformProvider::tf_listener_
std::shared_ptr< tf2_ros::TransformListener > tf_listener_
TransformListener used to listen and update transformations.
Definition: transform_provider.h:149
mesh_filter::MeshHandle
unsigned int MeshHandle
Definition: mesh_filter_base.h:60
class_forward.h
TransformProvider
Class that caches and updates transformations for given frames.
Definition: transform_provider.h:55
TransformProvider::getTransform
bool getTransform(mesh_filter::MeshHandle handle, Eigen::Isometry3d &transform) const
returns the current transformation of a mesh given by its handle
Definition: transform_provider.cpp:90
TransformProvider::TransformContext::TransformContext
TransformContext(const std::string &name)
Definition: transform_provider.h:129
ros::Rate
TransformProvider::run
void run()
The entry point of the dedicated thread that updates the transformations periodically.
Definition: transform_provider.cpp:105
TransformProvider::stop
void stop()
stops the update process/thread.
Definition: transform_provider.cpp:61
mesh_filter_base.h
TransformProvider::start
void start()
starts the updating process. Done in a seperate thread
Definition: transform_provider.cpp:55
TransformProvider::thread_
std::thread thread_
thread object
Definition: transform_provider.h:159
TransformProvider::handle2context_
std::map< mesh_filter::MeshHandle, TransformContextPtr > handle2context_
mapping between the mesh handle and its context
Definition: transform_provider.h:146


perception
Author(s): Ioan Sucan , Jon Binney , Suat Gedikli
autogenerated on Thu Jun 27 2024 02:27:09