1、下载lidar_align源码

ethz-asl/lidar_align: A simple method for finding the extrinsic calibration between a 3D lidar and a 6-dof pose sensor (github.com)https://github.com/ethz-asl/lidar_align2、解压到ros工作空间目录下的src文件中

不知道如何创建ros工作空间的可以参考我另一篇博客:

ubuntu下如何创建ros工作空间、创建ros功能包、创建ros节点_╰︶ ̄ 莫等闲۩۩۩的博客-CSDN博客_ubuntu 创建工作空间https://blog.csdn.net/qq_49959714/article/details/127028396?spm=1001.2014.3001.5501

3、编译

sudo apt-get install libnlopt-devcd ~/catkin_wscatkin_make

此时编译可能会遇到一些问题,比如:

CNake Error at /usr /share/cnake-3.10/Nodules/FindPackageHandlestandardArgs.cmake:137 (nessage);could NOT find NLOPT (missing: NLOPT_INCLUDE_DIR NLOPT_LIBRARY)
Call stack (most recent call first):
/usr/share/cnake-3.10/NModules/FindPackageHandleStandardArgs.cnake:378(_FPHSA_FAILURENLOPTConfig.cmake:65 (find_package_handle_standard_args)
CMakeLists.txt: 18 (find_package)
— Configuring incomplete, errors occurred!
see also “/home/findlab/lidar_align-naster/build /CMakeFiles/CNakeoutput.log”.See also “/hone /findlab/lidar_align-naster/build/CMakeFiles/CNakeError.log”.

解决办法:

在lidar_align-master文件夹中的CMakeLists.txt添加以下代码:

list(APPEND CMAKE_FIND_ROOT_PATH ${PROJECT_SOURCE_DIR})set (CMAKE_PREFIX_PATH "/usr/local/lib/cmake/nlopt")

最后应该就编译成功了,如果还遇到编译问题,可以参考一下我另一篇博客,里面总结了几个可能遇到的问题解决办法:

(4条消息) ubuntu安装lidar_align时编译出错,激光雷达与IMU标定_╰︶ ̄ 莫等闲۩۩۩的博客-CSDN博客https://blog.csdn.net/qq_49959714/article/details/128086217?spm=1001.2014.3001.55014、启动

roscoresource devel/setup.bashroslaunch lidar_align lidar_align.launch

此时可能会遇到一些问题

问题1:

解决办法:

修改launch文件,改为自己的bag路径

问题2:

解决办法:

修改loader.cpp文件

将以下代码放到该文件的对应位置,并将odom的代码删除或注释掉

std::vector types;types.push_back(std::string("sensor_msgs/Imu"));rosbag::View view(bag, rosbag::TypeQuery(types));size_t imu_num = 0;double shiftX=0,shiftY=0,shiftZ=0,velX=0,velY=0,velZ=0;ros::Time time;double timeDiff,lastShiftX,lastShiftY,lastShiftZ;for (const rosbag::MessageInstance& m : view){std::cout <<"Loading imu: \e[1m"<< imu_num++<<"\e[0m from ros bag"<<'\r'<< std::flush;sensor_msgs::Imu imu=*(m.instantiate());Timestamp stamp = imu.header.stamp.sec * 1000000ll +imu.header.stamp.nsec / 1000ll;if(imu_num==1){time=imu.header.stamp;Transform T(Transform::Translation(0,0,0),Transform::Rotation(1,0,0,0));odom->addTransformData(stamp, T);}else{timeDiff=(imu.header.stamp-time).toSec();time=imu.header.stamp;velX=velX+imu.linear_acceleration.x*timeDiff;velY=velX+imu.linear_acceleration.y*timeDiff;velZ=velZ+(imu.linear_acceleration.z-9.801)*timeDiff;lastShiftX=shiftX;lastShiftY=shiftY;lastShiftZ=shiftZ;shiftX=lastShiftX+velX*timeDiff+imu.linear_acceleration.x*timeDiff*timeDiff/2;shiftY=lastShiftY+velY*timeDiff+imu.linear_acceleration.y*timeDiff*timeDiff/2;shiftZ=lastShiftZ+velZ*timeDiff+(imu.linear_acceleration.z-9.801)*timeDiff*timeDiff/2;Transform T(Transform::Translation(shiftX,shiftY,shiftZ), Transform::Rotation(imu.orientation.w,imu.orientation.x,imu.orientation.y,imu.orientation.z));odom->addTransformData(stamp, T);}}

问题3:

解决办法:

在loader.h头文件中定义Imu消息即可

#include 

然后再重新编译catkin_make

此时应该编译没问题了

再执行roslaunch lidar_align lidar_align.launch

可能还会再次遇到问题

原因是点云序列号超出范围

解决办法:在sensor.h头文件中将keep_points_ratio的默认值0.01改小,比如改成0.001.

最终成功标定了

最终的标定结果文件存放在lidar_align目录下的results文件夹中