Class PointCloudCodec

Class Documentation

class PointCloudCodec

Class to expose all the functionality of pointcloud transport (encode/decode msgs) without needing to spin a node.

Public Functions

POINT_CLOUD_TRANSPORT_PUBLIC PointCloudCodec()

Constructor.

virtual POINT_CLOUD_TRANSPORT_PUBLIC ~PointCloudCodec()

Destructor.

POINT_CLOUD_TRANSPORT_PUBLIC std::shared_ptr< point_cloud_transport::PublisherPlugin > getEncoderByName (const std::string &name)

Get a shared pointer to an instance of a publisher plugin given its transport name (publishers encode messages). e.g. if you want the raw encoder, call getEncoderByName(“raw”).

Parameters:

name – The name of the transport to load.

Returns:

A shared pointer to the publisher plugin.

POINT_CLOUD_TRANSPORT_PUBLIC std::shared_ptr< point_cloud_transport::SubscriberPlugin > getDecoderByName (const std::string &name)

Get a shared pointer to an instance of a publisher plugin given its transport name (subscribers decode messages). e.g. if you want the raw decoder, call getDecoderByName(“raw”).

Parameters:

name – The name of the transport to load.

Returns:

A shared pointer to the subscriber plugin.

POINT_CLOUD_TRANSPORT_PUBLIC void getLoadableTransports (std::vector< std::string > &transports, std::vector< std::string > &names)

Get a list of all the transports that can be loaded.

Parameters:
  • transports[out] Vector of the loadable transport plugins.

  • names[out] Vector of string identifieries for the transport provided by each plugin

POINT_CLOUD_TRANSPORT_PUBLIC void getTopicsToPublish (const std::string &baseTopic, std::vector< std::string > &transports, std::vector< std::string > &topics, std::vector< std::string > &names, std::vector< std::string > &dataTypes)

Get a list of all the transport plugins, topics, transport names, and their data types that can be loaded.

Parameters:
  • baseTopic[in] The base topic to use for the transport.

  • transports[out] Vector of the loadable transport plugins.

  • topics[out] Vector of the topics that can be published.

  • names[out] Vector of string identifieries for the transport provided by each plugin

  • dataTypes[out] Vector of the data types the transports encode a PointCloud2 into

POINT_CLOUD_TRANSPORT_PUBLIC void getTopicToSubscribe (const std::string &baseTopic, const std::string &transport, std::string &topic, std::string &name, std::string &dataType)

Get the topic, transport name, and data type that a given topic is published on for a particular transport plugin.

Parameters:
  • baseTopic[in] The base topic to use for the transport.

  • transport[in] The transport plugin to load.

  • topic[out] The topic that should be subscribed to.

  • name[out] String identifier for the transport provided by the plugin

  • dataType[out] The data type the transport encodes a PointCloud2 into

POINT_CLOUD_TRANSPORT_PUBLIC bool encode (const std::string &transport_name, const sensor_msgs::msg::PointCloud2 &msg, rclcpp::SerializedMessage &serialized_msg)

Encode a PointCloud2 message into a serialized message using the specified transport plugin. The underlying type of the serialized message is determined by the transport plugin, but doesnt need to be known by this function.

Parameters:
  • transport_name[in] The name of the transport plugin to use.

  • msg[in] The message to encode.

  • serialized_msg[out] The serialized message to store the encoded message in.

Returns:

True if the message was successfully encoded, false otherwise.

template<class M> POINT_CLOUD_TRANSPORT_PUBLIC bool encodeTyped (const std::string &transport_name, const sensor_msgs::msg::PointCloud2 &msg, M &compressed_msg)

Encode a PointCloud2 message into some compressed message type using the specified transport plugin. The compressed message type is determined by the transport plugin.

Parameters:
  • transport_name[in] The name of the transport plugin to use.

  • msg[in] The message to encode.

  • compressed_msg[out] The compressed message to store the encoded message in.

Returns:

True if the message was successfully encoded, false otherwise.

POINT_CLOUD_TRANSPORT_PUBLIC bool decode (const std::string &transport_name, const rclcpp::SerializedMessage &serialized_msg, sensor_msgs::msg::PointCloud2 &msg)

Decode a serialized message into a PointCloud2 using the specified transport plugin. The underlying type of the serialized message is determined by the transport plugin, but doesnt need to be known by this function.

Parameters:
  • transport_name[in] The name of the transport plugin to use.

  • serialized_msg[in] The serialized message to decode.

  • msg[out] The message to store the decoded output in.

Returns:

True if the message was successfully decoded, false otherwise.

template<class M> POINT_CLOUD_TRANSPORT_PUBLIC bool decodeTyped (const std::string &transport_name, const M &compressed_msg, sensor_msgs::msg::PointCloud2 &msg)

Decode some compressed message type into a PointCloud2 based on the specified transport plugin. The compressed message type is determined by the transport plugin.

Parameters:
  • transport_name[in] The name of the transport plugin to use.

  • compressed_msg[in] The compressed message to decode.

  • msg[out] The message to store the decoded output in.

Returns:

True if the message was successfully decoded, false otherwise.