00001 #include <gmapping/sensor/sensor_range/rangesensor.h> 00002 00003 namespace GMapping{ 00004 00005 RangeSensor::RangeSensor(std::string name): Sensor(name){} 00006 00007 RangeSensor::RangeSensor(std::string name, unsigned int beams_num, double res, const OrientedPoint& position, double span, double maxrange):Sensor(name), 00008 m_pose(position), m_beams(beams_num){ 00009 double angle=-.5*res*beams_num; 00010 for (unsigned int i=0; i<beams_num; i++, angle+=res){ 00011 RangeSensor::Beam& beam(m_beams[i]); 00012 beam.span=span; 00013 beam.pose.x=0; 00014 beam.pose.y=0; 00015 beam.pose.theta=angle; 00016 beam.maxRange=maxrange; 00017 } 00018 newFormat=0; 00019 updateBeamsLookup(); 00020 } 00021 00022 void RangeSensor::updateBeamsLookup(){ 00023 for (unsigned int i=0; i<m_beams.size(); i++){ 00024 RangeSensor::Beam& beam(m_beams[i]); 00025 beam.s=sin(m_beams[i].pose.theta); 00026 beam.c=cos(m_beams[i].pose.theta); 00027 } 00028 } 00029 00030 };