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 #ifndef GRAPH_SLAM_LOCALIZATION_BUFFER_H
00040 #define GRAPH_SLAM_LOCALIZATION_BUFFER_H
00041
00042 #include <graph_mapping_msgs/LocalizationDistribution.h>
00043 #include <ros/ros.h>
00044 #include <tf/transform_listener.h>
00045 #include <boost/circular_buffer.hpp>
00046 #include <boost/thread.hpp>
00047 #include <boost/optional.hpp>
00048
00049 namespace graph_slam
00050 {
00051
00052 typedef boost::shared_ptr<tf::TransformListener> TfPtr;
00053
00058 class LocalizationBuffer
00059 {
00060 public:
00061 LocalizationBuffer (const unsigned buffer_size, const std::string& fixed_frame,
00062 const std::string& base_frame, TfPtr tf, const double max_extrapolation);
00063
00065 geometry_msgs::PoseStamped localizationAt (const ros::Time& t) const;
00066
00068 geometry_msgs::PoseStamped localizationAt (const ros::Time& t,
00069 const ros::Duration& d) const;
00070
00072 bool hasLocalization (const ros::Time& t) const;
00073
00075 boost::optional<geometry_msgs::PoseStamped> lastLocalization () const;
00076
00077 private:
00078
00079 void localizationCallback (graph_mapping_msgs::LocalizationDistribution::ConstPtr m);
00080
00081 const std::string fixed_frame_;
00082 const std::string base_frame_;
00083 const double max_extrapolation_;
00084
00085 mutable boost::mutex mutex_;
00086 TfPtr tf_;
00087 boost::circular_buffer<graph_mapping_msgs::LocalizationDistribution::ConstPtr> buffer_;
00088 ros::NodeHandle nh_;
00089 ros::Subscriber loc_sub_;
00090
00091 };
00092
00093 }
00094
00095 #endif // include guard