00001 #include "laser_people_detection_alg.h" 00002 00003 LaserPeopleDetectionAlgorithm::LaserPeopleDetectionAlgorithm(void) 00004 { 00005 myLaserPeopleDetection = new CLaserPeopleDetection(); 00006 } 00007 00008 LaserPeopleDetectionAlgorithm::~LaserPeopleDetectionAlgorithm(void) 00009 { 00010 delete myLaserPeopleDetection; 00011 } 00012 00013 void LaserPeopleDetectionAlgorithm::config_update(Config& new_cfg, uint32_t level) 00014 { 00015 this->lock(); 00016 00017 // save the current configuration 00018 this->setRangeThreshold(float(new_cfg.rangeThreshold)); 00019 this->setDetectionThreshold(float(new_cfg.detectionThreshold)); 00020 myLaserPeopleDetection->setPersonRadius(new_cfg.personRadius); 00021 std::string newPath(new_cfg.boostFilePath); 00022 std::string newPath2(new_cfg.boostFilePath2); 00023 this->setBoostFilePaths(newPath, newPath2); 00024 this->config_=new_cfg; 00025 00026 this->unlock(); 00027 } 00028 00029 // LaserPeopleDetectionAlgorithm Public API 00030 00031 void LaserPeopleDetectionAlgorithm::iteration(const sensor_msgs::LaserScan scan, iri_perception_msgs::detectionArray & people) 00032 { 00033 // Using scan ranges and params, performs a detection iteration, storing people results in peopleList[] 00034 vector<vector<float> > peopleList; 00035 myLaserPeopleDetection->detectionIteration(scan.ranges, scan.angle_min, scan.angle_max, scan.angle_increment, &peopleList); 00036 00037 // Fills people message with header and people data 00038 people.header.frame_id = scan.header.frame_id; 00039 people.header.stamp = scan.header.stamp; 00040 people.type = 0; //laser detector type 00041 00042 people.detection.resize(peopleList.size()); 00043 for(unsigned int i=0; i<peopleList.size(); i++) 00044 { 00045 people.detection[i].position.x = peopleList[i][0]; // x coordinate of person [i] 00046 people.detection[i].position.y = peopleList[i][1]; // y coordinate of person [i] 00047 people.detection[i].position.z = 0; 00048 people.detection[i].probability = peopleList[i][2]; // p quality value of person [i] 00049 people.detection[i].covariances[0] = peopleList[i][3]; // covariance xx 00050 people.detection[i].covariances[7] = peopleList[i][3]; // covariance yy 00051 people.detection[i].id = 0; 00052 } 00053 00054 } 00055 00056 void LaserPeopleDetectionAlgorithm::setRangeThreshold(const float rangeThreshold) 00057 { 00058 myLaserPeopleDetection->setRangeThreshold(rangeThreshold); 00059 } 00060 00061 void LaserPeopleDetectionAlgorithm::setDetectionThreshold(const float detectionThreshold) 00062 { 00063 myLaserPeopleDetection->setDetectionThreshold(detectionThreshold); 00064 } 00065 00066 void LaserPeopleDetectionAlgorithm::setBoostFilePaths(const std::string newPath, const std::string newPath2) 00067 { 00068 myLaserPeopleDetection->setBoostFilePaths(newPath, newPath2); 00069 }