Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS-287: Ouster support for Apollo #290

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ New launch file parameter:
- `xyzir`: same as xyzi type but adds ring (channel) field.
this type is same as Velodyne point cloud type
this type is not compatible with the low data profile.
- `xyzit`: same as xyzi type but adds timestamp field.
this type is not compatible with the low data profile.

### Invoking Services
To execute any of the following service, first you need to open a new terminal
Expand Down
49 changes: 49 additions & 0 deletions include/ouster_ros/common_point_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,52 @@ struct PointXYZIR : public _PointXYZIR {
}
};

/*
* Same as Apollo point cloud type
* @remark XYZIT point type is not compatible with RNG15_RFL8_NIR8/LOW_DATA
* udp lidar profile.
*/
struct EIGEN_ALIGN16 _PointXYZIT {
PCL_ADD_POINT4D;
uint32_t intensity;
uint64_t timestamp;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

struct PointXYZIT : public _PointXYZIT {

inline PointXYZIT(const _PointXYZIT& pt)
{
x = pt.x; y = pt.y; z = pt.z; data[3] = 1.0f;
intensity = pt.intensity; timestamp = pt.timestamp;
}

inline PointXYZIT()
{
x = y = z = 0.0f; data[3] = 1.0f;
intensity = 0.0f; timestamp = 0;
}

inline const auto as_tuple() const {
return std::tie(x, y, z, intensity, timestamp);
}

inline auto as_tuple() {
return std::tie(x, y, z, intensity, timestamp);
}

template<size_t I>
inline auto& get() {
return std::get<I>(as_tuple());
}
};

} // namespace ouster_ros

// clang-format off

/* common point types */

POINT_CLOUD_REGISTER_POINT_STRUCT(ouster_ros::PointXYZIR,
(float, x, x)
(float, y, y)
Expand All @@ -69,4 +110,12 @@ POINT_CLOUD_REGISTER_POINT_STRUCT(ouster_ros::PointXYZIR,
(std::uint16_t, ring, ring)
)

POINT_CLOUD_REGISTER_POINT_STRUCT(ouster_ros::PointXYZIT,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(std::uint16_t, timestamp, timestamp)
)

// clang-format on
3 changes: 2 additions & 1 deletion launch/common.launch
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>


Expand Down
3 changes: 2 additions & 1 deletion launch/driver.launch
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>

<group ns="$(arg ouster_ns)">
Expand Down
3 changes: 2 additions & 1 deletion launch/record.launch
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>

<group ns="$(arg ouster_ns)">
Expand Down
3 changes: 2 additions & 1 deletion launch/replay.launch
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>

<group ns="$(arg ouster_ns)">
Expand Down
3 changes: 2 additions & 1 deletion launch/sensor.launch
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>

<group ns="$(arg ouster_ns)">
Expand Down
3 changes: 2 additions & 1 deletion launch/sensor_mtp.launch
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
native,
xyz,
xyzi,
xyzir
xyzir,
xyzit
}"/>

<group ns="$(arg ouster_ns)">
Expand Down
6 changes: 5 additions & 1 deletion src/point_cloud_processor_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class PointCloudProcessorFactory {
public:
static bool point_type_requires_intensity(const std::string& point_type) {
return point_type == "xyzi" || point_type == "xyzir" ||
point_type == "original";
point_type == "xyzit" || point_type == "original";
}

static LidarScanProcessor create_point_cloud_processor(
Expand Down Expand Up @@ -140,6 +140,10 @@ class PointCloudProcessorFactory {
return make_point_cloud_procssor<PointXYZIR>(
info, frame, apply_lidar_to_sensor_transform,
post_processing_fn);
} else if (point_type == "xyzit") {
return make_point_cloud_procssor<PointXYZIT>(
info, frame, apply_lidar_to_sensor_transform,
post_processing_fn);
} else if (point_type == "original") {
return make_point_cloud_procssor<ouster_ros::Point>(
info, frame, apply_lidar_to_sensor_transform,
Expand Down
10 changes: 10 additions & 0 deletions src/point_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ DEFINE_MEMBER_CHECKER(x);
DEFINE_MEMBER_CHECKER(y);
DEFINE_MEMBER_CHECKER(z);
DEFINE_MEMBER_CHECKER(t);
DEFINE_MEMBER_CHECKER(timestamp);
DEFINE_MEMBER_CHECKER(ring);
DEFINE_MEMBER_CHECKER(intensity);
DEFINE_MEMBER_CHECKER(ambient);
Expand All @@ -41,6 +42,15 @@ void transform(PointTGT& tgt_pt, const PointSRC& src_pt) {
tgt_pt, src_pt, [](auto& tgt_pt, const auto&) { tgt_pt.t = 0U; }
);

// t: timestamp
CondBinaryOp<has_timestamp_v<PointTGT> && has_t_v<PointSRC>>::run(
tgt_pt, src_pt, [](auto& tgt_pt, const auto& src_pt) { tgt_pt.timestamp = src_pt.t; }
);

CondBinaryOp<has_timestamp_v<PointTGT> && !has_t_v<PointSRC>>::run(
tgt_pt, src_pt, [](auto& tgt_pt, const auto&) { tgt_pt.timestamp = 0U; }
);

// ring
CondBinaryOp<has_ring_v<PointTGT> && has_ring_v<PointSRC>>::run(
tgt_pt, src_pt, [](auto& tgt_pt, const auto& src_pt) { tgt_pt.ring = src_pt.ring; }
Expand Down
Loading