当前位置:网站首页>autoware中ndtmatching功能加载点云图坐标系修正的问题
autoware中ndtmatching功能加载点云图坐标系修正的问题
2022-07-29 01:25:00 【qq_278667286】
autoware中ndtmatching加载点云图坐标系修正的问题
autoware中点云和矢量(高精)地图都是map系
我们建图实践时创建点云图与场地不符
如果对位修正方法采用创建一个新的系如map3d来容纳点云
然后修改发布map3d到world的变换使 点云与场地对齐
坐标系如图:
如图,地面红框为场地边界,淡蓝色为墙面标记
加载点云的坐标系为map3d,经过调整map3d到world(map)系的变换,点云已与场地重合。
但此时运行ndt_matching,给初始位置后会定位失败。
为了解决这个问题,就需要更改一下ndtmatching加载点云时对点云的处理,即把map3d的点云转到map下。
主要代码:
if (input->header.frame_id == “map3d”)
{
tf::TransformListener local_transform_listener;
try
{
ros::Time now = ros::Time(0);
local_transform_listener.waitForTransform(“/map”, “/map3d”, now, ros::Duration(10.0));
local_transform_listener.lookupTransform(“/map”, “map3d”, now, local_transform_map_map3d);
}
catch (tf::TransformException& ex)
{
ROS_ERROR(“%s”, ex.what());
}
pcl_ros::transformPointCloud(map, map, local_transform_map_map3d);
}
添加转换后的定位效果
map_callback点云话题的回调函数
static void map_callback(const sensor_msgs::PointCloud2::ConstPtr& input)
{
// if (map_loaded == 0)
if (points_map_num != input->width)
{
std::cout << "Update points_map." << std::endl;
points_map_num = input->width;
// Convert the data type(from sensor_msgs to pcl).
pcl::fromROSMsg(*input, map);
//zzz20220722----------------------------begin
if (input->header.frame_id == "map3d")
{
tf::TransformListener local_transform_listener;
try
{
ros::Time now = ros::Time(0);
local_transform_listener.waitForTransform("/map", "/map3d", now, ros::Duration(10.0));
local_transform_listener.lookupTransform("/map", "map3d", now, local_transform_map_map3d);
}
catch (tf::TransformException& ex)
{
ROS_ERROR("%s", ex.what());
}
pcl_ros::transformPointCloud(map, map, local_transform_map_map3d);
}
//zzz20220722----------------------------end
if (_use_local_transform == true)
{
tf::TransformListener local_transform_listener;
try
{
ros::Time now = ros::Time(0);
local_transform_listener.waitForTransform("/map", "/world", now, ros::Duration(10.0));
local_transform_listener.lookupTransform("/map", "world", now, local_transform);
}
catch (tf::TransformException& ex)
{
ROS_ERROR("%s", ex.what());
}
pcl_ros::transformPointCloud(map, map, local_transform.inverse());
}
pcl::PointCloud<pcl::PointXYZ>::Ptr map_ptr(new pcl::PointCloud<pcl::PointXYZ>(map));
// Setting point cloud to be aligned to.
if (_method_type == MethodType::PCL_GENERIC)
{
pcl::NormalDistributionsTransform<pcl::PointXYZ, pcl::PointXYZ> new_ndt;
pcl::PointCloud<pcl::PointXYZ>::Ptr output_cloud(new pcl::PointCloud<pcl::PointXYZ>);
new_ndt.setResolution(ndt_res);
new_ndt.setInputTarget(map_ptr);
new_ndt.setMaximumIterations(max_iter);
new_ndt.setStepSize(step_size);
new_ndt.setTransformationEpsilon(trans_eps);
new_ndt.align(*output_cloud, Eigen::Matrix4f::Identity());
pthread_mutex_lock(&mutex);
ndt = new_ndt;
pthread_mutex_unlock(&mutex);
}
else if (_method_type == MethodType::PCL_ANH)
{
cpu::NormalDistributionsTransform<pcl::PointXYZ, pcl::PointXYZ> new_anh_ndt;
new_anh_ndt.setResolution(ndt_res);
new_anh_ndt.setInputTarget(map_ptr);
new_anh_ndt.setMaximumIterations(max_iter);
new_anh_ndt.setStepSize(step_size);
new_anh_ndt.setTransformationEpsilon(trans_eps);
pcl::PointCloud<pcl::PointXYZ>::Ptr dummy_scan_ptr(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointXYZ dummy_point;
dummy_scan_ptr->push_back(dummy_point);
new_anh_ndt.setInputSource(dummy_scan_ptr);
new_anh_ndt.align(Eigen::Matrix4f::Identity());
pthread_mutex_lock(&mutex);
anh_ndt = new_anh_ndt;
pthread_mutex_unlock(&mutex);
}
#ifdef CUDA_FOUND
else if (_method_type == MethodType::PCL_ANH_GPU)
{
std::shared_ptr<gpu::GNormalDistributionsTransform> new_anh_gpu_ndt_ptr =
std::make_shared<gpu::GNormalDistributionsTransform>();
new_anh_gpu_ndt_ptr->setResolution(ndt_res);
new_anh_gpu_ndt_ptr->setInputTarget(map_ptr);
new_anh_gpu_ndt_ptr->setMaximumIterations(max_iter);
new_anh_gpu_ndt_ptr->setStepSize(step_size);
new_anh_gpu_ndt_ptr->setTransformationEpsilon(trans_eps);
pcl::PointCloud<pcl::PointXYZ>::Ptr dummy_scan_ptr(new pcl::PointCloud<pcl::PointXYZ>());
pcl::PointXYZ dummy_point;
dummy_scan_ptr->push_back(dummy_point);
new_anh_gpu_ndt_ptr->setInputSource(dummy_scan_ptr);
new_anh_gpu_ndt_ptr->align(Eigen::Matrix4f::Identity());
pthread_mutex_lock(&mutex);
anh_gpu_ndt_ptr = new_anh_gpu_ndt_ptr;
pthread_mutex_unlock(&mutex);
}
#endif
#ifdef USE_PCL_OPENMP
else if (_method_type == MethodType::PCL_OPENMP)
{
pcl_omp::NormalDistributionsTransform<pcl::PointXYZ, pcl::PointXYZ> new_omp_ndt;
pcl::PointCloud<pcl::PointXYZ>::Ptr output_cloud(new pcl::PointCloud<pcl::PointXYZ>);
new_omp_ndt.setResolution(ndt_res);
new_omp_ndt.setInputTarget(map_ptr);
new_omp_ndt.setMaximumIterations(max_iter);
new_omp_ndt.setStepSize(step_size);
new_omp_ndt.setTransformationEpsilon(trans_eps);
new_omp_ndt.align(*output_cloud, Eigen::Matrix4f::Identity());
pthread_mutex_lock(&mutex);
omp_ndt = new_omp_ndt;
pthread_mutex_unlock(&mutex);
}
#endif
map_loaded = 1;
}
}
边栏推荐
- [the road of Exile - Chapter 6]
- DSP vibration seat
- Semiconductor chip industry chain
- QT source code analysis -- QObject (4)
- Have you ever encountered the situation that the IP is blocked when crawling web pages?
- Mathematical modeling -- Optimization of picking in warehouse
- Promise解决异步
- [10:00 public class]: application exploration of Kwai gpu/fpga/asic heterogeneous platform
- Golang run times undefined error [resolved]
- ASCII code table
猜你喜欢
![[circuit design] open collector OC output of triode](/img/48/5a111b81f0d99990fbcc5263313c07.jpg)
[circuit design] open collector OC output of triode

Type analysis of demultiplexer (demultiplexer)

Lua log implementation -- print table

Force deduction brush question (1): sum of two numbers

LM13丨形态量化-动量周期分析
![[golang] synchronization lock mutex](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[golang] synchronization lock mutex
[electronic components] zener diode
![[golang] network connection net.dial](/img/8d/7ef64cb63cbd230e5ac1655b86786f.png)
[golang] network connection net.dial

MySQL安装常见报错处理大全
![[10:00 public class]: application exploration of Kwai gpu/fpga/asic heterogeneous platform](/img/e7/1d06eba0e50eeb91d2d5da7524f4af.png)
[10:00 public class]: application exploration of Kwai gpu/fpga/asic heterogeneous platform
随机推荐
Implementation of 10m multifunctional signal generator with FPGA
表单校验 隐藏的输入框 显示才校验
Explanation of yocto project directory structure
Planning mathematics final simulation exam I
[public class preview]: application exploration of Kwai gpu/fpga/asic heterogeneous platform
LeetCode 练习——剑指 Offer 45. 把数组排成最小的数
What is the function of data parsing?
[MySQL] SQL aliases the table
MySQL安装常见报错处理大全
Related function records about string processing (long-term update)
E-commerce keyword research helps data collection
leetcode/0和1个数相同的连续子数组
How to find the right agent type? Multi angle analysis for you!
[the road of Exile - Chapter III]
JVM内存溢出在线分析Dump文件以及在线分析打开.hprof文件得出JVM运行报告jvisualvm怎么在线分析
[electronic components] zener diode
How to write, load and unload plug-ins in QT
Use POI to export excel file, image URL to export file, image and excel file to export compressed package
Use of packet capturing tool Charles
What is a proxy server? [2022 guide]