Ros2ImageMessage#

Fully qualified name: isaacsim::ros2::core::Ros2ImageMessage

class Ros2ImageMessage : public isaacsim::ros2::core::Ros2Message#

Class implementing a sensor_msgs/msg/Image message.

Provides functionality to write ROS 2 Image messages that contain image data with specified encoding and dimensions.

Subclassed by isaacsim::ros2::core::Ros2ImageMessageImpl

Public Functions

virtual void writeHeader(
const double timeStamp,
const std::string &frameId,
) = 0#

Write the message header.

Sets the header fields in a ROS 2 Image message.

Parameters:
  • timeStamp – [in] Time (seconds).

  • frameId – [in] Transform frame with which this data is associated.

virtual void generateBuffer(
const uint32_t height,
const uint32_t width,
const std::string &encoding,
bool usePinnedMemory = false,
) = 0#

Generate the buffer with optional CUDA pinned memory allocation.

Allocates memory for the data field, and computes and fills in the values of the other message fields. When usePinnedMemory is true, allocates CUDA (page-locked) memory for faster GPU transfers.

Parameters:
  • height – [in] Image height.

  • width – [in] Image width.

  • encoding – [in] Encoding of pixels.

  • usePinnedMemory – [in] If true, allocate CUDA pinned memory instead of regular host memory.

inline void *getBufferPtr()#

Get the pointer to the buffer (matrix data).

Provides direct access to the underlying buffer containing the image data. Returns pinned memory pointer if allocated, otherwise returns vector buffer pointer.

Returns:

Pointer to the buffer.

inline size_t getTotalBytes()#

Get the total size (step * height) of the buffer, in bytes.

Returns the total size of the image buffer in bytes.

Returns:

Buffer size.

inline void *getPtr()#

Retrieves the message pointer.

Returns the pointer to the underlying ROS 2 message if it has been properly created and initialized.

Note

This method does not perform type checking - the caller is responsible for proper casting to the appropriate message type.

Returns:

Pointer to the message or nullptr if not initialized.

virtual const void *getTypeSupportHandle() = 0#

Gets the type support handle for the message.

Returns a pointer to the ROS IDL message type support data structure. The actual type depends on the message category:

  • Topic: rosidl_message_type_support_t

  • Service: rosidl_service_type_support_t

  • Action: rosidl_action_type_support_t

Returns:

Pointer to the type support structure or nullptr.

Protected Attributes

std::vector<uint8_t> m_buffer#

Buffer (matrix data).

void *m_pinnedBuffer = nullptr#

Pinned memory buffer pointer.

size_t m_totalBytes = 0#

Buffer size.

bool m_isPinnedMemory = false#

Flag indicating if buffer is using CUDA pinned memory.

void *m_msg = nullptr#

Message pointer.