当前位置:网站首页>R2live code learning record (3): radar feature extraction
R2live code learning record (3): radar feature extraction
2022-07-27 07:03:00 【How much is the code? Oneortwo】
main Read configuration parameter declaration subscription 、 Post topics
int main(int argc, char **argv)
{
ros::init(argc, argv, "feature_ext");
ros::NodeHandle n;
// from launch Read configuration parameters
n.param<double>("feature_extraction/blind", blind, 0.01); // Minimum distance , Used to eliminate duplicate points , When the square of the distance between the current point and the next point is less than the threshold , Then remove
n.param<double>("feature_extraction/inf_bound", inf_bound, 10); // Infinite threshold , Beyond this threshold, it is considered infinite
n.param<int>("feature_extraction/N_SCANS", N_SCANS, 1); // Number of scan lines
n.param<int>("feature_extraction/group_size", group_size, 8); // Laser point cloud feature extraction , Used to confirm whether to group , If the number of points is greater than the threshold, the Group
n.param<double>("feature_extraction/disA", disA, 0.01); // Plane point judgment algorithm , It is used to increase the search scope in the process of point calculation , The coefficient of multiplication
n.param<double>("feature_extraction/disB", disB, 0.1); // Plane point judgment algorithm , It is used to increase the search scope in the process of point calculation , Additive sparseness
n.param<double>("feature_extraction/p2l_ratio", p2l_ratio, 400); // Threshold used to judge whether it is a plane point , If less than this threshold , Then this point is the point to be judged
n.param<double>("feature_extraction/limit_maxmid", limit_maxmid, 9); // Detect the threshold in the plane point
n.param<double>("feature_extraction/limit_midmin", limit_midmin, 16); // Detect the threshold in the plane point
n.param<double>("feature_extraction/limit_maxmin", limit_maxmin, 3.24); // Detect the threshold in the plane point
n.param<double>("feature_extraction/jump_up_limit", jump_up_limit, 175.0); // Upper angle limit
n.param<double>("feature_extraction/jump_down_limit", jump_down_limit, 5.0); // Lower limit of angle
n.param<double>("feature_extraction/cos160", cos160, 160.0);
n.param<double>("feature_extraction/edgea", edgea, 3); // In the edge judgment algorithm with crossing , Distance threshold , The coefficient of multiplication
n.param<double>("feature_extraction/edgeb", edgeb, 0.05); // In the edge judgment algorithm with crossing , Distance threshold , Additive sparseness
n.param<double>("feature_extraction/smallp_intersect", smallp_intersect, 170.0);
n.param<double>("feature_extraction/smallp_ratio", smallp_ratio, 1.2);
n.param<int>("feature_extraction/point_filter_num", point_filter_num, 4);
n.param<int>("feature_extraction/point_step", g_point_step, 3);
n.param<int>("feature_extraction/using_raw_point", g_if_using_raw_point, 1);
jump_up_limit = cos(jump_up_limit / 180 * M_PI);
jump_down_limit = cos(jump_down_limit / 180 * M_PI);
cos160 = cos(cos160 / 180 * M_PI);
smallp_intersect = cos(smallp_intersect / 180 * M_PI);
ros::Subscriber sub_points = n.subscribe("/velodyne_points", 1000, velo16_handler, ros::TransportHints().tcpNoDelay());
pub_full = n.advertise<sensor_msgs::PointCloud2>("/laser_cloud", 100); // All laser point clouds
pub_surf = n.advertise<sensor_msgs::PointCloud2>("/laser_cloud_flat", 100); // Flat plane point
pub_corn = n.advertise<sensor_msgs::PointCloud2>("/laser_cloud_sharp", 100); // Sharp edge points
ros::spin();
return 0;
}
Callback function :
int orders[16] = {
0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15};
void velo16_handler(const sensor_msgs::PointCloud2::ConstPtr &msg)
{
pcl::PointCloud<PointType> pl_orig;
pcl::fromROSMsg(*msg, pl_orig);
uint plsize = pl_orig.size();
vector<pcl::PointCloud<PointType>> pl_buff(N_SCANS);
vector<vector<orgtype>> typess(N_SCANS);
pcl::PointCloud<PointType> pl_corn, pl_surf, pl_full;
int scanID;
int last_stat = -1;
int idx = 0;
for (int i = 0; i < N_SCANS; i++)
{
pl_buff[i].resize(plsize);
typess[i].resize(plsize);
}
for (uint i = 0; i < plsize; i++)
{
PointType &ap = pl_orig[i];
double leng = sqrt(ap.x * ap.x + ap.y * ap.y);
if (leng < blind)
{
continue;
}
double ang = atan(ap.z / leng) * rad2deg;
scanID = int((ang + 15) / 2 + 0.5);
if (scanID >= N_SCANS || scanID < 0)
{
continue;
}
if (orders[scanID] <= last_stat)
{
idx++;
}
pl_buff[scanID][idx].x = ap.x;
pl_buff[scanID][idx].y = ap.y;
pl_buff[scanID][idx].z = ap.z;
pl_buff[scanID][idx].intensity = ap.intensity;
typess[scanID][idx].range = leng;
last_stat = orders[scanID];
}
idx++;
for (int j = 0; j < N_SCANS; j++)
{
pcl::PointCloud<PointType> &pl = pl_buff[j];
vector<orgtype> &types = typess[j];
pl.erase(pl.begin() + idx, pl.end());
types.erase(types.begin() + idx, types.end());
plsize = idx - 1;
for (uint i = 0; i < plsize; i++)
{
vx = pl[i].x - pl[i + 1].x;
vy = pl[i].y - pl[i + 1].y;
vz = pl[i].z - pl[i + 1].z;
types[i].dista = vx * vx + vy * vy + vz * vz;
}
types[plsize].range = sqrt(pl[plsize].x * pl[plsize].x + pl[plsize].y * pl[plsize].y);
give_feature(pl, types, pl_corn, pl_surf);
}
pub_func(pl_orig, pub_full, msg->header.stamp);
pub_func(pl_surf, pub_surf, msg->header.stamp);
pub_func(pl_corn, pub_corn, msg->header.stamp);
}
边栏推荐
- 如何删除或替换EasyPlayer流媒体播放器的loading样式?
- MangoDB
- Redis operation of Linux Installation
- DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)
- Do it yourself container
- C#时间相关操作
- deepsort源码解读(一)
- 程序、进程、线程、协程以及单线程、多线程基本概念
- Px4 source code compilation to establish its own program module
- PNA peptide nucleic acid modified peptide suc Tyr Leu Val PNA | suc ala Pro Phe PNA 11
猜你喜欢
![[unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature](/img/be/812ccb05d7763effcece51945f0460.png)
[unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature

MangoDB

ZnS DNA QDs near infrared zinc sulfide ZnS quantum dots modified deoxyribonucleic acid dna|dna modified ZnS quantum dots

Redis operation of Linux Installation

Disk management and file system

基于SSM音乐网站管理系统

How to avoid loopholes? Sunflower remote explains the safe use methods in different scenarios

脱氧核糖核酸DNA改性近红外二区砷化镓GaAs量子点|GaAs-DNA QDs|DNA修饰GaAs量子点

regular expression

关于ES6的新特性
随机推荐
基于SSM图书借阅管理系统
【12】 Understand the circuit: from telegraph to gate circuit, how can we "send messages from thousands of miles"?
C#时间相关操作
EasyRecovery14数据恢复软件官方功能简介
Bert and RESNET can also be trained on mobile phones?!
vscode运行命令报错:标记“&&”不是此版本中的有效语句分隔符。
Sok: the faults in our asrs: an overview of attacks against automatic speech recognition
DNA coupled PbSe quantum dots | near infrared lead selenide PbSe quantum dots modified DNA | PbSe DNA QDs
Shell编程的规范和变量
C语言怎么学?这篇文章给你完整答案
基于SSM学生成绩管理系统
Sunflower: don't worry when you encounter computer vulnerabilities, understand clearly and then judge sunflower: don't worry when you encounter computer vulnerabilities, understand clearly and then ju
deepsort源码解读(六)
Some problems about too fast s verification code
Unittest suite and runner
DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)
DNA科研实验应用|环糊精修饰核酸CD-RNA/DNA|环糊精核酸探针/量子点核酸探针
运行代码报错: libboost_filesystem.so.1.58.0: cannot open shared object file: No such file or directory
PNA modified polypeptide arms PNA PNA DNA suc aapf PNA suc - (ALA) 3 PNA
deepsort源码解读(二)