00001 /* 00002 * Localizing Jockey based on LaserScan. 00003 * 00004 * The role of this jockey is to get the dissimilarity of the LaserScan 00005 * descriptors of all vertices with the current LaserScan. 00006 * The action is done when the dissimilarities are computed. 00007 * Implemented actions: 00008 * - GET_VERTEX_DESCRIPTOR: return the ids of the LaserScan descriptor and the 00009 * computed Crossing descriptor 00010 * - GET_SIMILARITY: return the dissimilarity based on LaserScan 00011 * 00012 * Interaction with the map (created by this jockey): 00013 * - [Getter][/][Setter], message type, interface default name 00014 * - Getter/Setter: VectorLaserScan, jockey_name + "_laser" 00015 * - Setter: Crossing, jockey_name + "_crossing" 00016 * 00017 * Interaction with the map (created by other jockeys): 00018 * - [Getter][/][Setter], message type, interface default name 00019 * 00020 * Subscribers (other than map-related): 00021 * - message type, topic default name, description 00022 * - sensor_msgs::LaserScan, "~/base_scan", 360-deg laser-scan. 00023 * 00024 * Publishers (other than map-related): 00025 * - message type, topic default name, description 00026 * 00027 * Services used (other than map-related): 00028 * - service type, server default name, description 00029 * - place_matcher_msgs::PolygonDissimilarity, "~/compute_dissimilarity", used to 00030 * compare all known places with the current place 00031 * 00032 * Parameters: 00033 * - name, type, default name, description 00034 * - laser_interface_name, String, jockey_name + "_laser", name of the map interface for 360-degree laser-scan. 00035 * - crossing_interface_name, String, jockey_name + "_crossing", name of the map interface for crossing. 00036 * - dissimilarity_server_name, String, "compute_dissimilarity", name of the dissimilarity server. 00037 */ 00038 00039 #pragma once 00040 #ifndef LJ_LASER_JOCKEY_H 00041 #define LJ_LASER_JOCKEY_H 00042 00043 #include <cmath> 00044 00045 #include <ros/ros.h> 00046 #include <sensor_msgs/LaserScan.h> 00047 00048 #include <lama_common/polygon_utils.h> // for scanToPolygon 00049 #include <lama_interfaces/ActOnMap.h> 00050 #include <lama_interfaces/AddInterface.h> 00051 #include <lama_interfaces/GetVectorLaserScan.h> 00052 #include <lama_interfaces/SetVectorLaserScan.h> 00053 #include <lama_msgs/DescriptorLink.h> 00054 #include <lama_msgs/SetCrossing.h> 00055 #include <lama_jockeys/localizing_jockey.h> 00056 #include <place_matcher_msgs/PolygonDissimilarity.h> 00057 00058 #include <crossing_detector/laser_crossing_detector.h> 00059 00060 namespace lj_laser 00061 { 00062 00063 class Jockey : public lama_jockeys::LocalizingJockey 00064 { 00065 public: 00066 00067 Jockey(std::string name, const double frontier_width, const double max_frontier_angle=0.785); 00068 00069 virtual void onGetVertexDescriptor(); 00070 virtual void onGetEdgesDescriptors(); 00071 virtual void onLocalizeInVertex(); 00072 virtual void onLocalizeEdge(); 00073 virtual void onGetDissimilarity(); 00074 // virtual void onInterrupt(); 00075 // virtual void onContinue(); 00076 00077 void setDissimilarityServerName(std::string name) {dissimilarity_server_name_ = name;} 00078 00079 protected: 00080 00081 bool data_received_; 00082 00083 // Reception and storage of LaserScan. 00084 ros::Subscriber laserHandler_; 00085 ros::Time scan_reception_time_; 00086 sensor_msgs::LaserScan scan_; 00087 00088 // ROS parameters. 00089 std::string laser_interface_name_; 00090 std::string crossing_interface_name_; 00091 std::string dissimilarity_server_name_; 00092 00093 // Reception and Sending of LaserScan and Crossing descriptors. 00094 ros::ServiceClient laser_descriptor_getter_; 00095 ros::ServiceClient laser_descriptor_setter_; 00096 ros::ServiceClient crossing_descriptor_setter_; 00097 00098 // Dissimilarity server. 00099 ros::ServiceClient dissimilarity_server_; 00100 00101 crossing_detector::LaserCrossingDetector crossing_detector_; 00102 00103 private: 00104 00105 bool initMapLaserInterface(); 00106 bool initMapCrossingInterface(); 00107 void getData(); 00108 void handleLaser(const sensor_msgs::LaserScanConstPtr& msg); 00109 00110 lama_msgs::DescriptorLink laserDescriptorLink(const int32_t id); 00111 lama_msgs::DescriptorLink crossingDescriptorLink(const int32_t id); 00112 }; 00113 00114 00115 } // namespace lj_laser 00116 00117 #endif // LJ_LASER_JOCKEY_H