00001 00011 #ifndef FURNITURE_TRACKER_H_ 00012 #define FURNITURE_TRACKER_H_ 00013 00014 #include <ros/ros.h> 00015 #include <ar_track_alvar_msgs/AlvarMarkers.h> 00016 #include <geometry_msgs/Polygon.h> 00017 #include <geometry_msgs/Pose2D.h> 00018 #include <rail_ceiling/GetAllObstacles.h> 00019 #include <rail_ceiling/Obstacles.h> 00020 #include <ros/package.h> 00021 #include <tf/transform_listener.h> 00022 #include <yaml-cpp/yaml.h> 00023 00024 #define POSITION_THRESHOLD .03 //threshold at which to republish changes in furniture position 00025 #define ANGULAR_THRESHOLD .087 //threshold at which to republish changes in furniture angle, ~5 degrees 00026 00027 typedef struct _Marker 00028 { 00029 unsigned int id; 00030 unsigned int fid; //associated furniture id 00031 geometry_msgs::Pose2D pose; 00032 } Marker; 00033 00034 typedef struct _Furniture 00035 { 00036 unsigned int id; 00037 std::string type; 00038 std::vector<Marker> markers; 00039 } Furniture; 00040 00041 typedef struct _FurnitureTransforms 00042 { 00043 std::string name; 00044 std::vector<geometry_msgs::Polygon> localizationFootprint; 00045 std::vector<geometry_msgs::Polygon> navigationFootprint; 00046 } FurnitureTransforms; 00047 00048 class FurnitureTracker 00049 { 00050 public: 00054 FurnitureTracker(); 00055 00062 void publishFurniturePoses(); 00063 00064 private: 00065 ros::NodeHandle n; 00066 00067 ros::Publisher furnitureLayerPub; 00068 ros::ServiceServer allPosesServer; 00069 std::vector<ros::Subscriber> markerSubscribers; 00070 00071 tf::TransformListener tfListener; 00072 00073 bool readInitialPoses; 00074 std::vector<Marker> markerList; 00075 std::vector<Furniture> furnitureList; 00076 std::vector<FurnitureTransforms> footprintTransforms; 00077 std::vector<geometry_msgs::Pose2D> furniturePoses; 00078 std::vector<geometry_msgs::Pose2D> lastPublishedPoses; 00079 00086 void readConfigFiles(std::string markerConfigFile, std::string furnitureConfigFile); 00087 00093 void markerCallback(const ar_track_alvar_msgs::AlvarMarkers::ConstPtr& msg); 00094 00104 bool getAllPoses(rail_ceiling::GetAllObstacles::Request &req, rail_ceiling::GetAllObstacles::Response &res); 00105 00113 void updateMessages(int index, std::string type, rail_ceiling::Obstacles *obstacles); 00114 00123 void fillFootprintInformation(int index, std::vector<geometry_msgs::Polygon> footprints, rail_ceiling::Obstacles *obstacles, bool isLocalization); 00124 00134 bool updated(geometry_msgs::Pose2D pose); 00135 }; 00136 00144 int main(int argc, char **argv); 00145 00146 #endif