ImagePublisher#

Fully qualified name: isaacsim::ros2::nodes::ImagePublisher

class ImagePublisher : public isaacsim::ros2::nodes::PublisherBase#

Standalone ROS 2 image publisher that can be used from OmniGraph nodes or registered as a callback for SRTX frame delivery.

Lifecycle:

  1. Construct

  2. Call initialize() once

  3. Call publishFromHost() / publishFromDevice() per frame

  4. Call reset() or destroy

Public Functions

~ImagePublisher() override#
bool prepareFromHost(
const void *data,
size_t dataSize,
uint32_t width,
uint32_t height,
const std::string &encoding,
double timestamp,
)#

Fill the message from host (CPU) data without publishing.

bool publishFromHost(
const void *data,
size_t dataSize,
uint32_t width,
uint32_t height,
const std::string &encoding,
double timestamp,
)#

Convenience: prepareFromHost() + send().

bool prepareFromDevice(
const void *devicePtr,
size_t bufferSize,
uint32_t width,
uint32_t height,
const std::string &encoding,
double timestamp,
int cudaDeviceIndex,
carb::Format format = carb::Format::eUnknown,
)#

Fill the message from CUDA device memory without publishing.

bool publishFromDevice(
const void *devicePtr,
size_t bufferSize,
uint32_t width,
uint32_t height,
const std::string &encoding,
double timestamp,
int cudaDeviceIndex,
carb::Format format = carb::Format::eUnknown,
)#

Convenience: prepareFromDevice() + send().

virtual void reset() override#

Release ROS 2 resources and reset the publisher to an uninitialized state.

bool initialize(
const std::string &nodeName,
const std::string &namespaceName,
const std::string &topicName,
const std::string &frameId,
uint64_t queueSize,
const std::string &qosProfile,
uint64_t context = 0,
)#

One-time ROS 2 setup. Calls onCreateMessage() to create the message, then creates the publisher. Safe to call multiple times (no-op after first).

void send()#

Publish the message that was previously filled by a prepare() call. Thread-safe: can be called from a background task after prepare() completes.

inline bool isInitialized() const#

Return true if the publisher has been successfully initialized.

Protected Functions

virtual const void *onCreateMessage() override#

Override to create the ROS 2 message. Return the type-support handle pointer (from message->getTypeSupportHandle()). Store the typed message in a member of the derived class.

inline virtual isaacsim::ros2::core::Ros2Message *getMessagePtr(
) override#

Override to return the concrete message pointer for send().

bool shouldPublish() const#

Returns false when there are no subscribers and publish_without_verification is off.

Protected Attributes

isaacsim::ros2::core::Ros2Bridge *m_ros2Bridge = nullptr#

Cached bridge singleton.

isaacsim::ros2::core::Ros2Factory *m_factory = nullptr#

Cached factory from the bridge.

std::shared_ptr<isaacsim::ros2::core::Ros2ContextHandle> *m_contextHandle = nullptr#

ROS 2 context handle.

std::shared_ptr<isaacsim::ros2::core::Ros2NodeHandle> m_nodeHandle#

ROS 2 node handle.

std::shared_ptr<isaacsim::ros2::core::Ros2Publisher> m_publisher#

Underlying ROS 2 publisher.

std::string m_frameId#

TF frame ID stamped into published messages.

bool m_publishWithoutVerification = false#

When true, publish even with no subscribers.