loam中各种旋转各种坐标变换

欧拉角

  1. 从旋转所相对的坐标系来看,分成两种:
    extrinsic:每一次旋转,都相对于固定的基坐标系进行
    intrinsic:每一次旋转,都相对于旋转后的新坐标系进行
  2. 从旋转轴类型上,分成两类:
    Proper Euler angles:有重复旋转的轴
    Tait–Bryan angles: 没有重复旋转的轴
    总结成下表:
    在这里插入图片描述
    从loam的程序来看,可能选择的是上表中 Y 1 X 2 Z 3 Y_1X_2Z_3 Y1X2Z3这种类型

AccumulateRotation函数

假设基坐标系——也就是第一帧的系为0系,上一帧得到的车辆坐标系为1系,本帧车辆坐标系为2系,本次laserOdometry求解后得到1系和2系的相对旋转关系 2 1 R ^1_2R 21R。则,本函数,计算的是:
2 0 R = 1 0 R ⋅ 2 1 R ^0_2R= ^0_1R \cdot ^1_2R 20R=10R21R

通过下面的matlab符号计算可以进行公式验证

syms cx cy cz lx ly lz ox oy oz R1 R2 R3;
R1 = [cos(cy),0,sin(cy);0,1,0;-sin(cy),0,cos(cy)] * ...
    [1,0,0;0,cos(cx),-sin(cx);0,sin(cx),cos(cx)] * ...
    [cos(cz),-sin(cz),0;sin(cz),cos(cz),0;0,0,1]

R2 = [cos(ly),0,sin(ly);0,1,0;-sin(ly),0,cos(ly)] * ...
    [1,0,0;0,cos(lx),-sin(lx);0,sin(lx),cos(lx)] * ...
    [cos(lz),-sin(lz),0;sin(lz),cos(lz),0;0,0,1]

R3 = R1 * R2

TransformToStartIMU函数

该函数在去畸变函数中,作用是将一个特定时刻的激光点的坐标变换到,当前帧第一个点对应的车辆坐标系下。假设,imu给出的rollpitchyaw角度相对于一个固定的设计坐标系0系。当前激光点对应的车辆坐标系为2系,当前帧第一个激光点对应的车辆坐标系为1系
以下代码实现 0 p = 2 0 R ⋅ 2 p ^0 p = ^0_2R \cdot ^2p 0p=20R2p

/********************************************************************************
    Ry*Rx*Rz*Pl, transform point to the global frame
  *********************************************************************************/
  //绕z轴旋转(imuRollCur)
  float x1 = cos(imuRollCur) * p->x - sin(imuRollCur) * p->y;
  float y1 = sin(imuRollCur) * p->x + cos(imuRollCur) * p->y;
  float z1 = p->z;

  //绕x轴旋转(imuPitchCur)
  float x2 = x1;
  float y2 = cos(imuPitchCur) * y1 - sin(imuPitchCur) * z1;
  float z2 = sin(imuPitchCur) * y1 + cos(imuPitchCur) * z1;

  //绕y轴旋转(imuYawCur)
  float x3 = cos(imuYawCur) * x2 + sin(imuYawCur) * z2;
  float y3 = y2;
  float z3 = -sin(imuYawCur) * x2 + cos(imuYawCur) * z2;

以下代码实现 1 p = 0 1 R ⋅ 2 0 R ⋅ 2 p ^1p= ^1_0R \cdot ^0_2R \cdot ^2p 1p=01R20R2p

//绕y轴旋转(-imuYawStart)
  float x4 = cos(imuYawStart) * x3 - sin(imuYawStart) * z3;
  float y4 = y3;
  float z4 = sin(imuYawStart) * x3 + cos(imuYawStart) * z3;

  //绕x轴旋转(-imuPitchStart)
  float x5 = x4;
  float y5 = cos(imuPitchStart) * y4 + sin(imuPitchStart) * z4;
  float z5 = -sin(imuPitchStart) * y4 + cos(imuPitchStart) * z4;

  //绕z轴旋转(-imuRollStart),然后叠加平移量
  p->x = cos(imuRollStart) * x5 + sin(imuRollStart) * y5 + imuShiftFromStartXCur;
  p->y = -sin(imuRollStart) * x5 + cos(imuRollStart) * y5 + imuShiftFromStartYCur;
  p->z = z5 + imuShiftFromStartZCur;
LeGO-LOAM的地图配准主要是通过ICP算法实现的。下面是配准的代码: ```c++ void mapOptimization::scan2MapOptimization(){ ... // Step 1: Transform current scan to global map PointCloudT::Ptr transformed_scan_ptr (new PointCloudT()); pcl::transformPointCloud(*laserCloudCornerLast, *transformed_scan_ptr, laserOdometry); // Step 2: Add current scan to global map *laserCloudCornerFromMap += *transformed_scan_ptr; laserCloudCornerFromMapDS->clear(); downSizeFilterCorner.setInputCloud(laserCloudCornerFromMap); downSizeFilterCorner.filter(*laserCloudCornerFromMapDS); // Step 3: Apply ICP algorithm to align current scan with global map pcl::IterativeClosestPoint<PointT, PointT> icp; icp.setInputSource(transformed_scan_ptr); icp.setInputTarget(laserCloudCornerFromMapDS); icp.setMaxCorrespondenceDistance(0.5); icp.setMaximumIterations(50); icp.setTransformationEpsilon(1e-8); icp.align(*transformed_scan_ptr); // Step 4: Transform current scan back to its local frame if (icp.hasConverged()) { laserOdometry = icp.getFinalTransformation().inverse() * laserOdometry; pcl::transformPointCloud(*transformed_scan_ptr, *laserCloudCornerLast, laserOdometry); } ... } ``` 在这个函数,我们首先将当前的点云数据通过位姿转换,转换到全局地图的坐标系下。然后将当前点云添加到全局地图。接着,我们使用ICP算法,将当前点云与全局地图进行匹配,得到它们之间的变换关系。最后,我们将当前点云通过变换关系转换回到它的本地坐标系下。 需要注意的是,在LeGO-LOAM,我们是将当前点云的角点部分与全局地图的角点部分进行匹配,因为角点更具有特征性。另外,我们使用了一个体素滤波器对全局地图进行了下采样,这样可以加快匹配速度,同时也可以去除一些不必要的噪声点。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值