YDLIDAR / ydlidar_ros_driver

ydlidar driver package under ros
Other
64 stars 54 forks source link

what's the different between ydlidar_ros_driver::LaserFan and sensor_msgs::LaserScan of ROS #2

Closed DYFeng closed 3 years ago

DYFeng commented 3 years ago

What's the point of creating a new message type LaserFan?

yangfuyuan commented 3 years ago

LaserScan is a standard ROS message type. The angle precision of LaserFan message type will not be lost, and LaserScan will lose the angle precision:

   for(size_t i=0; i < scan.points.size(); i++) {
       // Convert angle to index will cause angle precision loss 
        int index = std::ceil((scan.points[i].angle - scan.config.min_angle)/scan.config.angle_increment);
        if(index >=0 && index < size) {
          if(scan.points[i].range >= scan.config.min_range) {
            scan_msg.ranges[index] = scan.points[i].range;
            scan_msg.intensities[index] = scan.points[i].intensity;
          }
        }
        // Keep the original angle 
        fan.angles.push_back(scan.points[i].angle);
        fan.ranges.push_back(scan.points[i].range);
        fan.intensities.push_back(scan.points[i].intensity);
      }