Go to the documentation of this file.00001 #ifndef OBJECT_MSGS_TOOLS_OBJECTTFBROADCASTER_H
00002 #define OBJECT_MSGS_TOOLS_OBJECTTFBROADCASTER_H
00003
00004 #include <ros/ros.h>
00005 #include <object_msgs/Object.h>
00006 #include <object_msgs/RegisterObject.h>
00007 #include <tf/transform_broadcaster.h>
00008 #include <boost/thread.hpp>
00009
00010 namespace object_msgs_tools {
00011
00024 class ObjectTFBroadcaster
00025 {
00026 public:
00027
00048 ObjectTFBroadcaster(
00049 ros::NodeHandle& n,
00050 const std::string& register_object_service,
00051 unsigned int publish_tf_rate,
00052 unsigned int query_object_info_rate,
00053 const std::string& object_topic,
00054 const std::string& object_service);
00055
00056 bool isRegistered(const std::string& name) const;
00057
00061 int registerObject(const std::string& name, bool printMsgs = true);
00062
00063 private:
00064
00068 bool registerObjectService(object_msgs::RegisterObject::Request &req,
00069 object_msgs::RegisterObject::Response &res);
00070
00074 bool queryObjectPose(const std::string& name, object_msgs::Object& obj, bool printErrors = true);
00075
00079 void sendTF(const geometry_msgs::PoseStamped& pose, const std::string& frame_name);
00080
00084 bool updateObject(const object_msgs::Object& obj);
00085
00089 void objectCallback(const object_msgs::Object& obj);
00090
00094 void publishTFEvent(const ros::TimerEvent& e);
00095
00099 void queryObjectPoseEvent(const ros::TimerEvent& e);
00100
00101
00102
00103 std::map<std::string, geometry_msgs::PoseStamped> obj_poses;
00104 mutable boost::recursive_mutex obj_poses_mutex;
00105
00106 ros::ServiceServer register_object_srv;
00107 ros::ServiceClient object_info_srv;
00108 ros::Subscriber object_info_sub;
00109
00110 ros::NodeHandle node;
00111
00112 tf::TransformBroadcaster tf_broadcaster;
00113 ros::Timer publish_tf_timer;
00114 ros::Timer query_object_info_timer;
00115 };
00116
00117 }
00118
00119 #endif // OBJECT_MSGS_TOOLS_OBJECTTFBROADCASTER_H