Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ using namespace std;

typedef pcl::PointXYZI PointType;

enum class SensorType { VELODYNE, OUSTER, LIVOX };
enum class SensorType { VELODYNE, OUSTER, LIVOX, VELODYNE_M1600 };

class ParamServer
{
Expand Down Expand Up @@ -186,11 +186,14 @@ class ParamServer
else if (sensorStr == "livox")
{
sensor = SensorType::LIVOX;
}
else if (sensorStr == "velodyne_m1600") {
sensor = SensorType::VELODYNE_M1600;
}
else
{
ROS_ERROR_STREAM(
"Invalid sensor type (must be either 'velodyne' or 'ouster' or 'livox'): " << sensorStr);
"Invalid sensor type (must be either 'velodyne' or 'ouster' or 'livox' or 'velodyne_m1600'): " << sensorStr);
ros::shutdown();
}

Expand Down
52 changes: 50 additions & 2 deletions src/imageProjection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "utility.h"
#include "lio_sam/cloud_info.h"
#include "pcl/filters/impl/filter.hpp"

struct VelodynePointXYZIRT
{
Expand All @@ -13,6 +14,19 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (VelodynePointXYZIRT,
(float, x, x) (float, y, y) (float, z, z) (float, intensity, intensity)
(uint16_t, ring, ring) (float, time, time)
)
struct Velodyne_M1600PointXYZIRT {
PCL_ADD_POINT4D;
uint8_t intensity;
uint8_t ring;
uint32_t timestampSec;
uint32_t timestampNsec;

EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;
POINT_CLOUD_REGISTER_POINT_STRUCT(
Velodyne_M1600PointXYZIRT,
(float, x, x)(float, y, y)(float, z, z)(uint8_t, intensity, intensity)(
uint8_t, ring, ring)(uint32_t, timestampSec, timestampSec)(uint32_t, timestampNsec, timestampNsec))

struct OusterPointXYZIRT {
PCL_ADD_POINT4D;
Expand Down Expand Up @@ -68,6 +82,7 @@ class ImageProjection : public ParamServer

pcl::PointCloud<PointXYZIRT>::Ptr laserCloudIn;
pcl::PointCloud<OusterPointXYZIRT>::Ptr tmpOusterCloudIn;
pcl::PointCloud<Velodyne_M1600PointXYZIRT>::Ptr tmpM1600CloudIn;
pcl::PointCloud<PointType>::Ptr fullCloud;
pcl::PointCloud<PointType>::Ptr extractedCloud;

Expand Down Expand Up @@ -108,6 +123,7 @@ class ImageProjection : public ParamServer
{
laserCloudIn.reset(new pcl::PointCloud<PointXYZIRT>());
tmpOusterCloudIn.reset(new pcl::PointCloud<OusterPointXYZIRT>());
tmpM1600CloudIn.reset(new pcl::PointCloud<Velodyne_M1600PointXYZIRT>());
fullCloud.reset(new pcl::PointCloud<PointType>());
extractedCloud.reset(new pcl::PointCloud<PointType>());

Expand Down Expand Up @@ -207,7 +223,27 @@ class ImageProjection : public ParamServer
if (sensor == SensorType::VELODYNE || sensor == SensorType::LIVOX)
{
pcl::moveFromROSMsg(currentCloudMsg, *laserCloudIn);
}
}
else if (sensor == SensorType::VELODYNE_M1600) {

pcl::moveFromROSMsg(currentCloudMsg, *tmpM1600CloudIn);
laserCloudIn->points.resize(tmpM1600CloudIn->size());
laserCloudIn->is_dense = tmpM1600CloudIn->is_dense;
double time_begins = tmpM1600CloudIn->points[0].timestampSec;
double time_beginns = tmpM1600CloudIn->points[0].timestampNsec;
double time_begin = time_begins + (time_beginns * 1e-9);
for (size_t i = 0; i < tmpM1600CloudIn->size(); i++) {
auto &src = tmpM1600CloudIn->points[i];
auto &dst = laserCloudIn->points[i];
dst.x = src.x;
dst.y = src.y*-1;
dst.z = src.z*-1;
dst.intensity = static_cast<float>(src.intensity);
dst.ring = src.ring;
double point_time = src.timestampSec + (src.timestampNsec * 1e-9);
dst.time = point_time-time_begin;
}
}
else if (sensor == SensorType::OUSTER)
{
// Convert to Velodyne format
Expand Down Expand Up @@ -236,6 +272,8 @@ class ImageProjection : public ParamServer
cloudHeader = currentCloudMsg.header;
timeScanCur = cloudHeader.stamp.toSec();
timeScanEnd = timeScanCur + laserCloudIn->points.back().time;
vector<int> indices;
pcl::removeNaNFromPointCloud(*laserCloudIn, *laserCloudIn, indices);

// check dense flag
if (laserCloudIn->is_dense == false)
Expand Down Expand Up @@ -270,7 +308,7 @@ class ImageProjection : public ParamServer
deskewFlag = -1;
for (auto &field : currentCloudMsg.fields)
{
if (field.name == "time" || field.name == "t")
if (field.name == "time" || field.name == "t" || field.name == "timestamp" || field.name == "timestampSec")
{
deskewFlag = 1;
break;
Expand Down Expand Up @@ -554,8 +592,18 @@ class ImageProjection : public ParamServer
{
columnIdn = columnIdnCountVec[rowIdn];
columnIdnCountVec[rowIdn] += 1;
} else if (sensor == SensorType::VELODYNE_M1600) {

float horizonAngle = atan2(thisPoint.x, thisPoint.y) * 180 / M_PI;

float ang_res_x = 0.29; // or 0.33 for the extended model, as per the specifications

columnIdn = round((horizonAngle / ang_res_x) + (Horizon_SCAN / 2));
if (columnIdn >= Horizon_SCAN)
columnIdn -= Horizon_SCAN;
}


if (columnIdn < 0 || columnIdn >= Horizon_SCAN)
continue;

Expand Down