Use lidar_align to perform external parameter calibration of lidar and IMU (super detailed tutorial)

1. Download lidar_align source code

ethz-asl/lidar_align: A simple method for finding the extrinsic calibration between a 3D lidar and a 6-dof pose sensor (github.com) icon-default.png?t=M85Bhttps://github.com/ethz-asl/lidar_align 2. Unzip to ros workspace In the src file under the directory

If you don’t know how to create a ros workspace, you can refer to my other blog:

How to create a ros workspace, create a ros function package, and create a ros node under ubuntu_╰︶ ̄ Mo Dongxian۩۩۩’s blog-CSDN blog_ubuntu Create a workspace icon-default.png?t=M85Bhttps://blog.csdn.net/qq_49959714/article/details /127028396?spm=1001.2014.3001.5501

 3. Compile

sudo apt-get install libnlopt-dev
cd ~/catkin_ws
catkin_make

At this time, compilation may encounter some problems, such as:

 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".

Solution:

 Add the following code to CMakeLists.txt in the lidar_align-master folder:

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

 In the end, the compilation should be successful. If you still encounter compilation problems, you can refer to my other blog, which summarizes several solutions to possible problems:

(4 messages) Compilation error when installing lidar_align on ubuntu, lidar and IMU calibration_╰︶ ̄ Mo Dianxian۩۩۩’s blog-CSDN blog icon-default.png?t=M85Bhttps://blog.csdn.net/qq_49959714/article/details/128086217?spm =1001.2014.3001.5501 4. Start

roscore
source devel/setup.bash
roslaunch lidar_align lidar_align.launch

 You may encounter some problems at this time

Question 1:

Solution:

Modify the launch file and change it to your own bag path

 Question 2:

 Solution:

Modify loader.cpp file

Place the following code into the corresponding location of the file, and delete or comment out the odom code

std::vector<std::string> 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<sensor_msgs::Imu>());

    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);
    }
  }

 

 Question 3:

 Solution:

Just define the Imu message in the loader.h header file

#include <sensor_msgs/Imu.h>

 Then recompile catkin_make

There should be no problem compiling at this point.

Then execute roslaunch lidar_align lidar_align.launch

You may encounter problems again

 The reason is that the point cloud serial number is out of range

Solution: Change the default value of keep_points_ratio from 0.01 in the sensor.h header file to a smaller value, for example, to 0.001.

 Finally successfully calibrated

 The final calibration result file is stored in the results folder under the lidar_align directory.

 

 

Guess you like

Origin blog.csdn.net/qq_49959714/article/details/128119029
Recommended