intpf_resample_limit(pf_t *pf, int k) { double a, b, c, x; int n; if (k <= 1) return pf->max_samples; a = 1; b = 2 / (9 * ((double) k - 1)); // pop_z 为3 c = sqrt(2 / (9 * ((double) k - 1))) * pf->pop_z; x = a - b + c; // pop_err 为0.01 n = (int) ceil( (k - 1) / (2 * pf->pop_err) * x * x * x );
if (n < pf->min_samples) return pf->min_samples; if (n > pf->max_samples) return pf->max_samples; return n; }
boost::recursive_mutex::scoped_lock cfl(configuration_mutex_); // 地图的宽高,分辨率 ROS_INFO("Received a %d X %d map @ %.3f m/pix\n", msg.info.width, msg.info.height, msg.info.resolution); // 如果目前的全局坐标系不是map if(msg.header.frame_id != global_frame_id_) ROS_WARN("Frame_id of map received:'%s' doesn't match global_frame_id:'%s'. This could cause issues with reading published topics", msg.header.frame_id.c_str(), global_frame_id_.c_str() );
//free相应的指针 freeMapDependentMemory(); // Clear queued laser objects because they hold pointers to the existing map lasers_.clear(); lasers_update_.clear(); frame_to_laser_.clear();
处理获得的地图
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// AMCL所用的地图类型 typedefstruct { // Map origin; the map is a viewport onto a conceptual larger map. double origin_x, origin_y; double scale; // Map scale (m/cell)
// Map dimensions (number of cells) int size_x, size_y; // The map data, stored as a grid map_cell_t *cells;
// Max distance at which we care about obstacles, for constructing // likelihood field double max_occ_dist; } map_t;
// In case the initial pose message arrived before the first map, // try to apply the initial pose now that the map has arrived. 可能初始位姿的信息比第一个map先到达,map到达后apply初始位姿