Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00039 #include <warehouse_ros/transform_collection.h>
00040 #include <boost/foreach.hpp>
00041
00042 namespace warehouse_ros
00043 {
00044
00045 tf::StampedTransform TransformCollection::lookupTransform(const std::string& target, const std::string& src,
00046 const double t) const
00047 {
00048
00049 Query::Ptr q = coll_.createQuery();
00050 q->appendRangeInclusive("stamp", t - search_back_, t + search_forward_);
00051
00052
00053 tf::Transformer buffer(true, ros::Duration(search_back_ + search_forward_ * 1.1));
00054 typename QueryResults<tf::tfMessage>::range_t res = coll_.query(q);
00055 for (ResultIterator<tf::tfMessage> it = res.first; it != res.second; ++it)
00056 {
00057 BOOST_FOREACH (const geometry_msgs::TransformStamped& trans, (*it)->transforms)
00058 {
00059 const geometry_msgs::Vector3& v = trans.transform.translation;
00060 const geometry_msgs::Quaternion& q = trans.transform.rotation;
00061 const std_msgs::Header& h = trans.header;
00062 const tf::Transform tr(tf::Quaternion(q.x, q.y, q.z, q.w), tf::Vector3(v.x, v.y, v.z));
00063 const tf::StampedTransform t(tr, h.stamp, h.frame_id, trans.child_frame_id);
00064 const bool ok = buffer.setTransform(t);
00065 ROS_ASSERT_MSG(ok, "Tf setTransform returned false for transform from %s "
00066 "to %s at %.4f",
00067 trans.child_frame_id.c_str(), h.frame_id.c_str(), h.stamp.toSec());
00068 }
00069 }
00070 tf::StampedTransform result;
00071 buffer.lookupTransform(target, src, ros::Time(t), result);
00072 return result;
00073 }
00074
00075 void TransformCollection::putTransform(tf::StampedTransform)
00076 {
00077
00078 }
00079
00080 }