• 镭神激光雷达对于Autoware的适配


    1. 前言

    我们的自动驾驶采用镭神激光雷达,在使用Autoware的时候,需要对镭神激光雷达的底层驱动,进行一些改变以适配Autoware。

    2. 修改

    (1)首先修改lslidar_c32.launch文件:

     1 <launch>
     2 
     3   <node pkg="lslidar_c32_driver" type="lslidar_c32_driver_node" name="leishen_lslidar_c32_driver" output="screen" >
     4     <param name="frame_id" value="laser_link"/>
     5     <param name="device_ip" value="192.168.1.200"/>
     6     <param name="device_port" value="2368"/>
     7   </node>
     8 
     9   <node pkg="lslidar_c32_decoder" type="lslidar_c32_decoder_node" name="leishen_lslidar_c32_decoder" output="screen">
    10     <!-- <param name="child_frame_id" value="world"/> -->
    11     <param name="child_frame_id" value="velodyne"/>
    12     <param name="point_num" value="2000"/>
    13     <param name="channel_num" value="0"/>
    14     <param name="angle_disable_min" value="0"/>
    15     <param name="angle_disable_max" value="0"/>
    16     <param name="min_range" value="0.15"/>
    17     <param name="max_range" value="500.0"/>
    18     <param name="frequency" value="10.0"/>
    19     <param name="publish_point_cloud" value="true"/>
    20     <param name="publish_channels" value="false"/>
    21     <remap from="lslidar_point_cloud" to="/points_raw" />
    22   </node>
    23   
    24   <!--node name="rviz" pkg="rviz" type="rviz" args="-d $(find lslidar_c32_decoder)/launch/lslidar_c32.rviz" output="screen"/-->
    25 
    26 </launch>

    这里贴出了修改后的launch文件,第10行修改为11行,21行去掉s。我们修改了frame_id,将之前的“world”改为“velodyne”。还有就是Autoware需要的点云topic为points_raw,而镭神的点云topic为point_raw,我们讲point_raw改为points_raw。

    (2)修改时间戳

    根据镭神的手册:“如果镭神接入GPS,那么会采用GPS时间,如果不接入GPS,雷达会采用内部时间,从0开始以微秒为单位计数,计数值赋值到主数据流时间戳的字节,计数到1小时在从0开始”。这样会导致在使用TF变换的时候时间戳出错,所以,需要修改时间戳,找到如下代码

     1 void LslidarC32Decoder::publishPointCloud() {
     2 //    pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud(
     3 //                new pcl::PointCloud<pcl::PointXYZI>());
     4     VPointCloud::Ptr point_cloud(new VPointCloud());
     5 
     6     //point_cloud->header.stamp =
     7             //pcl_conversions::toPCL(sweep_data->header).stamp;
     8     point_cloud->header.frame_id = child_frame_id;
     9     point_cloud->height = 1;
    10 
    11     for (size_t i = 0; i < 32; ++i) {
    12         const lslidar_c32_msgs::LslidarC32Scan& scan = sweep_data->scans[i];
    13         // The first and last point in each scan is ignored, which
    14         // seems to be corrupted based on the received data.
    15         // TODO: The two end points should be removed directly
    16         //    in the scans.
    17         // point_time unit is sec
    18         double timestamp = point_time;
    19         //point_cloud->header.stamp = static_cast<uint64_t>(timestamp * 1e6);
    20         point_cloud->header.stamp = ros::Time::now().toSec() * 1e6; 
    21         if (scan.points.size() == 0) continue;
    22         size_t j;
    23         VPoint point;
    24         for (j = 1; j < scan.points.size()-1; ++j) {
    25             point.timestamp = timestamp - (scan.points.size()-1 - j)*0.00005;  // time interval for each point is 50us
    26             point.x = scan.points[j].x;
    27             point.y = scan.points[j].y;
    28             point.z = scan.points[j].z;
    29             point.intensity = scan.points[j].intensity;
    30             point.range = scan.points[j].distance;
    31             point.h_angle = scan.points[j].azimuth;
    32             point.v_angle = layer_altitude[i];
    33             point.laserid = layer_id[i];
    34 
    35             point_cloud->points.push_back(point);
    36             ++point_cloud->width;
    37         }
    38 
    39     }
    40 
    41     //      if(point_cloud->width > 2000)
    42     {
    43         point_cloud_pub.publish(point_cloud);
    44     }
    45 
    46 
    47     return;
    48 }

    同样是贴上修改后的代码,将19行变为20行。

  • 相关阅读:
    专用学习笔记
    百度地图API试用--(初次尝试)
    学习进度条
    AAAA
    HBase集成(准备篇)
    软件工程学期总结
    【操作系统】实验四 主存空间的分配和回收
    《构建之法》8、9、10章
    金融计算器app的下载情况
    操作系统 实验三 进程调度模拟程序
  • 原文地址:https://www.cnblogs.com/hgl0417/p/11165275.html
Copyright © 2020-2023  润新知