Autoware.Auto
autoware::common::lidar_utils Namespace Reference

Classes

struct  _create_custom_pcl_datatype
 
struct  _create_custom_pcl_datatype< float32_t >
 
struct  _create_custom_pcl_datatype< float64_t >
 
struct  _create_custom_pcl_datatype< int16_t >
 
struct  _create_custom_pcl_datatype< int32_t >
 
struct  _create_custom_pcl_datatype< int8_t >
 
struct  _create_custom_pcl_datatype< uint16_t >
 
struct  _create_custom_pcl_datatype< uint32_t >
 
struct  _create_custom_pcl_datatype< uint8_t >
 
class  AngleFilter
 Filter class to check if a point's azimuth lies within a range defined by a start and end angles. The range is defined from start to the end angles in counter-clock-wise direction. More...
 
class  DistanceFilter
 Filter class to check if a point lies within a range defined by a min and max radius. More...
 
class  IntensityIteratorWrapper
 
class  PointCloudIts
 
struct  SafeCloudIndices
 
class  StaticTransformer
 Transform to apply a constant transform to given points. More...
 

Functions

float32_t fast_atan2 (float32_t y, float32_t x)
 
LIDAR_UTILS_PUBLIC std::size_t index_after_last_safe_byte_index (const sensor_msgs::msg::PointCloud2 &msg) noexcept
 Compute minimum safe length of point cloud access. More...
 
LIDAR_UTILS_PUBLIC SafeCloudIndices sanitize_point_cloud (const sensor_msgs::msg::PointCloud2 &msg)
 
LIDAR_UTILS_PUBLIC void init_pcl_msg (sensor_msgs::msg::PointCloud2 &msg, const std::string &frame_id, const std::size_t size=static_cast< std::size_t >(MAX_SCAN_POINTS))
 initializes header information for point cloud for x, y, z and intensity More...
 
template<typename ... Fields>
LIDAR_UTILS_PUBLIC void init_pcl_msg (sensor_msgs::msg::PointCloud2 &msg, const std::string &frame_id, const std::size_t size, const uint32_t num_fields, Fields const &... fields)
 
LIDAR_UTILS_PUBLIC bool8_t add_point_to_cloud_raw (sensor_msgs::msg::PointCloud2 &cloud, const autoware::common::types::PointXYZIF &pt, uint32_t point_cloud_idx)
 add a point in the cloud by memcpy instead of using iterators This version prioritize speed and ease of parallelisation it assumes : - PointXYZIF is a POD object equivalent to a point stored in the cloud, which means same fields and same endianness. More...
 
LIDAR_UTILS_PUBLIC bool8_t add_point_to_cloud (PointCloudIts &cloud_its, const autoware::common::types::PointXYZIF &pt, uint32_t &point_cloud_idx)
 
LIDAR_UTILS_PUBLIC bool8_t add_point_to_cloud (sensor_msgs::msg::PointCloud2 &cloud, const autoware::common::types::PointXYZIF &pt, uint32_t &point_cloud_idx)
 
LIDAR_UTILS_PUBLIC bool8_t add_point_to_cloud (sensor_msgs::msg::PointCloud2 &cloud, const autoware::common::types::PointXYZF &pt, uint32_t &point_cloud_idx)
 
LIDAR_UTILS_PUBLIC void reset_pcl_msg (sensor_msgs::msg::PointCloud2 &msg, const std::size_t size, uint32_t &point_cloud_idx)
 
LIDAR_UTILS_PUBLIC void resize_pcl_msg (sensor_msgs::msg::PointCloud2 &msg, const std::size_t new_size)
 
LIDAR_UTILS_PUBLIC bool8_t has_intensity_and_throw_if_no_xyz (const PointCloud2::SharedPtr &cloud)
 
LIDAR_UTILS_PUBLIC bool8_t has_intensity_and_throw_if_no_xyz (const PointCloud2 &cloud)
 
template<typename T >
LIDAR_UTILS_PUBLIC sensor_msgs::msg::PointCloud2::SharedPtr create_custom_pcl (const std::vector< std::string > &field_names, const uint32_t cloud_size)
 

Variables

static const uint32_t MAX_SCAN_POINTS = 57872U
 

Function Documentation

◆ add_point_to_cloud() [1/3]

bool8_t autoware::common::lidar_utils::add_point_to_cloud ( PointCloudIts cloud_its,
const autoware::common::types::PointXYZIF pt,
uint32_t &  point_cloud_idx 
)

◆ add_point_to_cloud() [2/3]

bool8_t autoware::common::lidar_utils::add_point_to_cloud ( sensor_msgs::msg::PointCloud2 &  cloud,
const autoware::common::types::PointXYZF pt,
uint32_t &  point_cloud_idx 
)

◆ add_point_to_cloud() [3/3]

bool8_t autoware::common::lidar_utils::add_point_to_cloud ( sensor_msgs::msg::PointCloud2 &  cloud,
const autoware::common::types::PointXYZIF pt,
uint32_t &  point_cloud_idx 
)

◆ add_point_to_cloud_raw()

bool8_t autoware::common::lidar_utils::add_point_to_cloud_raw ( sensor_msgs::msg::PointCloud2 &  cloud,
const autoware::common::types::PointXYZIF pt,
uint32_t  point_cloud_idx 
)

add a point in the cloud by memcpy instead of using iterators This version prioritize speed and ease of parallelisation it assumes : - PointXYZIF is a POD object equivalent to a point stored in the cloud, which means same fields and same endianness.

  • The caller is responsible for incrementing point_cloud_idx between two calls. This differs from add_point_to_cloud who increment point_cloud_idx by itself

◆ create_custom_pcl()

template<typename T >
LIDAR_UTILS_PUBLIC sensor_msgs::msg::PointCloud2::SharedPtr autoware::common::lidar_utils::create_custom_pcl ( const std::vector< std::string > &  field_names,
const uint32_t  cloud_size 
)

◆ fast_atan2()

float32_t autoware::common::lidar_utils::fast_atan2 ( float32_t  y,
float32_t  x 
)

Approximation was taken from: http://www-labs.iro.umontreal.ca/~mignotte/IFT2425/Documents/EfficientApproximationArctgFunction.pdf

|Error = fast_atan2(y, x) - atan2f(y, x)| < 0.00468 rad

Octants: pi/2 3 | 2 / | / 4 ` | / 1 pi --—+--— 0 5 / | 8 / | / 6 | 7 ` 3pi/2

◆ has_intensity_and_throw_if_no_xyz() [1/2]

bool8_t autoware::common::lidar_utils::has_intensity_and_throw_if_no_xyz ( const PointCloud2 &  cloud)

Check that the pointcloud msg has x, y, z of type float32_t as the first three fields, otherwise throw an exception; check that the pointcloud msg has intensity field as the fourth field, otherwise return false

◆ has_intensity_and_throw_if_no_xyz() [2/2]

bool8_t autoware::common::lidar_utils::has_intensity_and_throw_if_no_xyz ( const PointCloud2::SharedPtr &  cloud)

Check that the pointcloud msg has x, y, z of type float32_t as the first three fields, otherwise throw an exception; check that the pointcloud msg has intensity field as the fourth field, otherwise return false

◆ index_after_last_safe_byte_index()

std::size_t autoware::common::lidar_utils::index_after_last_safe_byte_index ( const sensor_msgs::msg::PointCloud2 &  msg)
noexcept

Compute minimum safe length of point cloud access.

Parameters
[in]msgThe point cloud message to validate
Returns
Byte index of one past the end of the last point ok to access

◆ init_pcl_msg() [1/2]

template<typename ... Fields>
LIDAR_UTILS_PUBLIC void autoware::common::lidar_utils::init_pcl_msg ( sensor_msgs::msg::PointCloud2 &  msg,
const std::string &  frame_id,
const std::size_t  size,
const uint32_t  num_fields,
Fields const &...  fields 
)

initializes header information for point cloud given frame id, size, number of frames and a parameter pack of fields.

Template Parameters
FieldsTemplate paramater pack containing field types.
Parameters
msgPoint cloud message.
frame_idFrame ID of the point cloud.
sizeSize of the initialized point cloud.
num_fieldsNumber of fields.
fieldsSet of parameters defining the fields. Each field must contain the following parameters in strict order: field_name, count, data_type. These parameters should be provided for each field

◆ init_pcl_msg() [2/2]

void autoware::common::lidar_utils::init_pcl_msg ( sensor_msgs::msg::PointCloud2 &  msg,
const std::string &  frame_id,
const std::size_t  size = static_cast<std::size_t>(MAX_SCAN_POINTS) 
)

initializes header information for point cloud for x, y, z and intensity

Parameters
[out]msga point cloud message to initialize
[in]frame_idthe name of the frame for the point cloud (assumed fixed)
[in]sizenumber of points to preallocate for underyling data array

◆ reset_pcl_msg()

void autoware::common::lidar_utils::reset_pcl_msg ( sensor_msgs::msg::PointCloud2 &  msg,
const std::size_t  size,
uint32_t &  point_cloud_idx 
)

◆ resize_pcl_msg()

void autoware::common::lidar_utils::resize_pcl_msg ( sensor_msgs::msg::PointCloud2 &  msg,
const std::size_t  new_size 
)

◆ sanitize_point_cloud()

SafeCloudIndices autoware::common::lidar_utils::sanitize_point_cloud ( const sensor_msgs::msg::PointCloud2 &  msg)

Compute the safe stride and max length for given point cloud

Returns
A pair size of data ok to read per point, and last index ok to read, for use with the form for (auto idx = 0U; idx < ret.data_length; idx += msg.point_step) {memcpy(&pt, msg.data[idx], ret.point_step);}

XYZI or XYZ, or throw

XYZI or XYZ, or throw

Variable Documentation

◆ MAX_SCAN_POINTS

const uint32_t autoware::common::lidar_utils::MAX_SCAN_POINTS = 57872U
static

max number of points in a scan for VLP16s, assuming 300 rpm = 5hz: 57870.3703 points per full rotation