Skip to content
Snippets Groups Projects
Commit 0e7700cf authored by Tixiao Shan's avatar Tixiao Shan
Browse files

add livox support (need customized driver from my repo)

parent 3cc124e5
No related branches found
No related tags found
No related merge requests found
...@@ -23,9 +23,9 @@ lio_sam: ...@@ -23,9 +23,9 @@ lio_sam:
savePCDDirectory: "/Downloads/LOAM/" # in your home folder, starts and ends with "/". Warning: the code deletes "LOAM" folder then recreates it. See "mapOptimization" for implementation savePCDDirectory: "/Downloads/LOAM/" # in your home folder, starts and ends with "/". Warning: the code deletes "LOAM" folder then recreates it. See "mapOptimization" for implementation
# Sensor Settings # Sensor Settings
sensor: velodyne # lidar sensor type, either 'velodyne' or 'ouster' sensor: velodyne # lidar sensor type, 'velodyne' or 'ouster' or 'livox'
N_SCAN: 16 # number of lidar channel (i.e., 16, 32, 64, 128) N_SCAN: 16 # number of lidar channel (i.e., Velodyne/Ouster: 16, 32, 64, 128, Livox Horizon: 6)
Horizon_SCAN: 1800 # lidar horizontal resolution (Velodyne:1800, Ouster:512,1024,2048) Horizon_SCAN: 1800 # lidar horizontal resolution (Velodyne:1800, Ouster:512,1024,2048, Livox Horizon: 4000)
downsampleRate: 1 # default: 1. Downsample your data if too many points. i.e., 16 = 64 / 4, 16 = 16 / 1 downsampleRate: 1 # default: 1. Downsample your data if too many points. i.e., 16 = 64 / 4, 16 = 16 / 1
lidarMinRange: 1.0 # default: 1.0, minimum lidar range to be used lidarMinRange: 1.0 # default: 1.0, minimum lidar range to be used
lidarMaxRange: 1000.0 # default: 1000.0, maximum lidar range to be used lidarMaxRange: 1000.0 # default: 1000.0, maximum lidar range to be used
......
...@@ -58,7 +58,7 @@ using namespace std; ...@@ -58,7 +58,7 @@ using namespace std;
typedef pcl::PointXYZI PointType; typedef pcl::PointXYZI PointType;
enum class SensorType { VELODYNE, OUSTER }; enum class SensorType { VELODYNE, OUSTER, LIVOX };
class ParamServer class ParamServer
{ {
...@@ -183,10 +183,14 @@ public: ...@@ -183,10 +183,14 @@ public:
{ {
sensor = SensorType::OUSTER; sensor = SensorType::OUSTER;
} }
else if (sensorStr == "livox")
{
sensor = SensorType::LIVOX;
}
else else
{ {
ROS_ERROR_STREAM( ROS_ERROR_STREAM(
"Invalid sensor type (must be either 'velodyne' or 'ouster'): " << sensorStr); "Invalid sensor type (must be either 'velodyne' or 'ouster' or 'livox'): " << sensorStr);
ros::shutdown(); ros::shutdown();
} }
......
...@@ -84,6 +84,8 @@ private: ...@@ -84,6 +84,8 @@ private:
double timeScanEnd; double timeScanEnd;
std_msgs::Header cloudHeader; std_msgs::Header cloudHeader;
vector<int> columnIdnCountLivox;
public: public:
ImageProjection(): ImageProjection():
...@@ -138,6 +140,8 @@ public: ...@@ -138,6 +140,8 @@ public:
imuRotY[i] = 0; imuRotY[i] = 0;
imuRotZ[i] = 0; imuRotZ[i] = 0;
} }
columnIdnCountLivox.assign(N_SCAN, 0);
} }
~ImageProjection(){} ~ImageProjection(){}
...@@ -200,7 +204,7 @@ public: ...@@ -200,7 +204,7 @@ public:
// convert cloud // convert cloud
currentCloudMsg = std::move(cloudQueue.front()); currentCloudMsg = std::move(cloudQueue.front());
cloudQueue.pop_front(); cloudQueue.pop_front();
if (sensor == SensorType::VELODYNE) if (sensor == SensorType::VELODYNE || sensor == SensorType::LIVOX)
{ {
pcl::moveFromROSMsg(currentCloudMsg, *laserCloudIn); pcl::moveFromROSMsg(currentCloudMsg, *laserCloudIn);
} }
...@@ -537,13 +541,21 @@ public: ...@@ -537,13 +541,21 @@ public:
if (rowIdn % downsampleRate != 0) if (rowIdn % downsampleRate != 0)
continue; continue;
float horizonAngle = atan2(thisPoint.x, thisPoint.y) * 180 / M_PI; int columnIdn = -1;
if (sensor == SensorType::VELODYNE || sensor == SensorType::OUSTER)
static float ang_res_x = 360.0/float(Horizon_SCAN); {
int columnIdn = -round((horizonAngle-90.0)/ang_res_x) + Horizon_SCAN/2; float horizonAngle = atan2(thisPoint.x, thisPoint.y) * 180 / M_PI;
if (columnIdn >= Horizon_SCAN) static float ang_res_x = 360.0/float(Horizon_SCAN);
columnIdn -= Horizon_SCAN; columnIdn = -round((horizonAngle-90.0)/ang_res_x) + Horizon_SCAN/2;
if (columnIdn >= Horizon_SCAN)
columnIdn -= Horizon_SCAN;
}
else if (sensor == SensorType::LIVOX)
{
columnIdn = columnIdnCountLivox[rowIdn];
columnIdnCountLivox[rowIdn] += 1;
}
if (columnIdn < 0 || columnIdn >= Horizon_SCAN) if (columnIdn < 0 || columnIdn >= Horizon_SCAN)
continue; continue;
......
...@@ -1356,6 +1356,12 @@ public: ...@@ -1356,6 +1356,12 @@ public:
if (cloudKeyPoses3D->points.empty()) if (cloudKeyPoses3D->points.empty())
return true; return true;
if (sensor == SensorType::LIVOX)
{
if (timeLaserInfoCur - cloudKeyPoses6D->back().time > 1.0)
return true;
}
Eigen::Affine3f transStart = pclPointToAffine3f(cloudKeyPoses6D->back()); Eigen::Affine3f transStart = pclPointToAffine3f(cloudKeyPoses6D->back());
Eigen::Affine3f transFinal = pcl::getTransformation(transformTobeMapped[3], transformTobeMapped[4], transformTobeMapped[5], Eigen::Affine3f transFinal = pcl::getTransformation(transformTobeMapped[3], transformTobeMapped[4], transformTobeMapped[5],
transformTobeMapped[0], transformTobeMapped[1], transformTobeMapped[2]); transformTobeMapped[0], transformTobeMapped[1], transformTobeMapped[2]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment