Skip to content

Commit 90ed051

Browse files
committed
fix: Delete relocalization, fix deque error
1 parent 93e695b commit 90ed051

File tree

3 files changed

+15
-94
lines changed

3 files changed

+15
-94
lines changed

src/faster-lio/config/mid360.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,9 @@ irobot:
4444
# 0, 0, -1]
4545

4646
icp:
47-
use_icp: false
4847
save_result: false
4948
pub_result: false
5049

51-
# ICP定位参数
52-
SCORE_THRESHOLD_MAX: 0.03 # 达到最大迭代次数后,代价仍高于此值,认为无法收敛
53-
ANGLE_UPPER_THRESHOLD_: 15 # 最大角度变换
54-
Point_Quantity_THRESHOLD: 500 # 点云数阈值
55-
Maximum_Iterations: 300 # 最大迭代次数
56-
VoxelGridRemoval_LeafSize: 0.1 # 体素滤波的边长
57-
ObstacleRemoval_Distance_Max: 100 # 如果雷达点云中点在地图点云最近点大于此值,就认为该点为障碍点
58-
5950
publish:
6051
path_en: false
6152
scan_publish_en: true # false: close all the point cloud output

src/faster-lio/include/laser_mapping.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "ivox3d/ivox3d.h"
1616
#include "options.h"
1717
#include "pointcloud_preprocess.h"
18-
#include "relocalization.hpp"
1918

2019
namespace faster_lio {
2120

@@ -200,12 +199,6 @@ class LaserMapping {
200199
common::M3D BOT_R_wrt_IMU_;
201200
tf::Vector3 tf_T_;
202201

203-
// relocalization
204-
std::thread relocalization_thread_;
205-
Relocalization relocalization_;
206-
bool use_icp_ = false;
207-
bool init_localization_ = false;
208-
209202
// icp RT
210203
common::V3D icp_T_wrt_;
211204
common::M3D icp_R_wrt_;

src/faster-lio/src/laser_mapping.cc

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ bool LaserMapping::LoadParams(ros::NodeHandle &nh) {
6363
std::vector<double> extrinT_IMU_BOT{3, 0.0}; // lidar-imu translation
6464
std::vector<double> extrinR_IMU_BOT{9, 0.0}; // lidar-imu rotation
6565

66-
nh.param<bool>("icp/use_icp", use_icp_, false);
6766
nh.param<bool>("path_save_en", path_save_en_, true);
6867
nh.param<bool>("publish/path_publish_en", path_pub_en_, true);
6968
nh.param<bool>("publish/scan_publish_en", scan_pub_en_, true);
@@ -129,11 +128,6 @@ bool LaserMapping::LoadParams(ros::NodeHandle &nh) {
129128
ivox_options_.nearby_type_ = IVoxType::NearbyType::NEARBY18;
130129
}
131130

132-
if (use_icp_)
133-
{
134-
init_localization_ = true;
135-
}
136-
137131
path_.header.stamp = ros::Time::now();
138132
path_.header.frame_id = "odom";
139133

@@ -402,71 +396,6 @@ void LaserMapping::Run() {
402396
return;
403397
}
404398

405-
if (use_icp_ && init_localization_)
406-
{
407-
if (!relocalization_.IsInit())
408-
relocalization_.InitParams(nh_, color_info_);
409-
410-
if (lidar_buffer_.size() < 10)
411-
// if (lidar_buffer_.empty())
412-
return;
413-
414-
LOG(INFO) << "Localization Initing!";
415-
PointCloudType::Ptr cloud_xyzi(new PointCloudType());
416-
417-
mtx_buffer_.lock();
418-
for (int i = 0; i < 10; i++)
419-
{
420-
*cloud_xyzi += *(lidar_buffer_.back());
421-
lidar_buffer_.pop_back();
422-
}
423-
// cloud_xyzi = lidar_buffer_.back();
424-
lidar_buffer_.clear();
425-
time_buffer_.clear();
426-
imu_buffer_.clear();
427-
imu_buf_.clear();
428-
mtx_buffer_.unlock();
429-
430-
int size = cloud_xyzi->size();
431-
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz(new pcl::PointCloud<pcl::PointXYZ>(size, 1));
432-
int i = 0;
433-
for (const PointType& point_xyzi : *cloud_xyzi)
434-
{
435-
common::V3D p_lidar(point_xyzi.x, point_xyzi.y, point_xyzi.z);
436-
common::V3D p_BOT(R_wrt_ * p_lidar + T_wrt_);
437-
438-
pcl::PointXYZ point_xyz;
439-
point_xyz.x = p_BOT(0);
440-
point_xyz.y = p_BOT(1);
441-
point_xyz.z = p_BOT(2);
442-
cloud_xyz->points[i] = point_xyz;
443-
i++;
444-
}
445-
446-
Eigen::Isometry3d result = Eigen::Isometry3d::Identity();
447-
if (relocalization_.InitExtrinsic(result, cloud_xyz))
448-
{
449-
icp_R_wrt_ = result.rotation();
450-
icp_T_wrt_ = result.translation();
451-
R_wrt_ = result.rotation() * R_wrt_;
452-
T_wrt_ = result.rotation() * T_wrt_ + result.translation();
453-
R_wrt_inv_ = R_wrt_.inverse();
454-
init_localization_ = false;
455-
// relocalization_.clear();
456-
LOG(INFO) << "\033[1;32m----> Init Localization Finished.\033[0m";
457-
lidar_buffer_.clear();
458-
time_buffer_.clear();
459-
imu_buffer_.clear();
460-
imu_buf_.clear();
461-
}
462-
else
463-
{
464-
LOG(WARNING) << "----> Init Localization Failed!";
465-
}
466-
467-
return;
468-
}
469-
470399
if (!SyncPackages()) {
471400
if (flg_first_odom_ && IMUUpdate())
472401
{
@@ -533,8 +462,20 @@ void LaserMapping::Run() {
533462

534463
state_imu_ = state_point_;
535464
imu_buf_ = imu_buffer_;
536-
sensor_msgs::Imu::Ptr msg(new sensor_msgs::Imu(*(measures_.imu_.back())));
537-
msg->header.stamp = ros::Time().fromSec(measures_.lidar_end_time_);
465+
sensor_msgs::Imu::Ptr msg;
466+
if (!measures_.imu_.empty()) {
467+
msg = sensor_msgs::Imu::Ptr(new sensor_msgs::Imu(*(measures_.imu_.back())));
468+
msg->header.stamp = ros::Time().fromSec(measures_.lidar_end_time_);
469+
} else {
470+
msg = sensor_msgs::Imu::Ptr(new sensor_msgs::Imu());
471+
msg->header.stamp = ros::Time().fromSec(measures_.lidar_end_time_);
472+
msg->angular_velocity.x = 0;
473+
msg->angular_velocity.y = 0;
474+
msg->angular_velocity.z = 0;
475+
msg->linear_acceleration.x = 0;
476+
msg->linear_acceleration.y = 0;
477+
msg->linear_acceleration.z = 0;
478+
}
538479
last_imu_ = msg;
539480
flg_first_odom_ = true;
540481

@@ -550,7 +491,7 @@ void LaserMapping::Run() {
550491
if (scan_pub_en_ || pcd_save_en_) {
551492
PublishFrameWorld();
552493
}
553-
if (use_icp_ || (scan_pub_en_ && scan_body_pub_en_)) {
494+
if (scan_pub_en_ && scan_body_pub_en_) {
554495
PublishFrameBody(pub_laser_cloud_body_);
555496
}
556497
if (scan_pub_en_ && scan_effect_pub_en_) {
@@ -881,8 +822,6 @@ void LaserMapping::PublishOdometry(const ros::Publisher &pub_odom_aft_mapped, na
881822
odom_lidar.pose.pose.orientation.z);
882823
common::M3D init_R_lidar = eigen_quat.toRotationMatrix();
883824
common::M3D MAP_R_BOT = BOT_R_wrt_IMU_ * init_R_lidar * IMU_R_wrt_BOT_;
884-
if (use_icp_)
885-
MAP_R_BOT = icp_R_wrt_ * MAP_R_BOT;
886825

887826
// 转换为tf与odom
888827
Eigen::Quaterniond q(MAP_R_BOT);
@@ -895,8 +834,6 @@ void LaserMapping::PublishOdometry(const ros::Publisher &pub_odom_aft_mapped, na
895834
odom_lidar.pose.pose.position.z);
896835
common::V3D MAP_T_lidar(BOT_R_wrt_IMU_ * init_T_lidar + BOT_T_wrt_IMU_);
897836
common::V3D MAP_T_BOT(MAP_T_lidar - MAP_R_BOT * BOT_T_wrt_IMU_);
898-
if (use_icp_)
899-
MAP_T_BOT = icp_R_wrt_ * MAP_T_BOT + icp_T_wrt_;
900837

901838
odom_base.pose.pose.position.x = MAP_T_BOT(0);
902839
odom_base.pose.pose.position.y = MAP_T_BOT(1);

0 commit comments

Comments
 (0)