car_pos.num = ( (int)( car_pos_y / map_.info.resolution) * map_.info.width + car_pos_x / map_.info.resolution);
int的类型转换很重要,否则乘以了地图宽度后,index会移位,到后面读到的data[index]数据不准确,捣鼓了一天。(facepalm)
map_.info.width是一行总的格子数量。
细节问题
car_pos.num = ( (int)( car_pos_y / map_.info.resolution) * map_.info.width + car_pos_x / map_.info.resolution);
int的类型转换很重要,否则乘以了地图宽度后,index会移位,到后面读到的data[index]数据不准确,捣鼓了一天。(facepalm)
map_.info.width是一行总的格子数量。
细节问题