PublisherBase#
Fully qualified name: isaacsim::ros2::nodes::PublisherBase
-
class PublisherBase#
Common base for all standalone ROS 2 publishers in the library.
Handles ROS 2 node handle creation, publisher creation with QoS, subscription-count gating, and teardown. Derived classes override onCreateMessage() to create the specific message type and provide typed publish methods.
Subclassed by isaacsim::ros2::nodes::ImagePublisher, isaacsim::ros2::nodes::PointCloudPublisher
Public Functions
-
PublisherBase()#
-
virtual ~PublisherBase()#
-
PublisherBase(const PublisherBase&) = delete#
-
PublisherBase &operator=(const PublisherBase&) = delete#
- 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.
-
virtual void reset()#
Release ROS 2 resources and reset the publisher to an uninitialized state.
-
inline bool isInitialized() const#
Return true if the publisher has been successfully initialized.
Protected Functions
-
virtual const void *onCreateMessage() = 0#
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.
-
virtual isaacsim::ros2::core::Ros2Message *getMessagePtr() = 0#
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.
-
PublisherBase()#