chrono::ros::ChROSHandlerRegistry Class Reference

Description

Registry for handler publishing functions in the subprocess.

Each handler type registers a function that deserializes data and publishes to ROS. This makes the subprocess dispatcher completely generic - it just looks up and calls the registered function for each message type.

BIDIRECTIONAL: Handlers can also use the IPC channel to send data back to main process (e.g., subscribers sending received ROS messages back to Chrono simulation)

#include <ChROSHandlerRegistry.h>

Public Types

using PublishFunction = std::function< void(const uint8_t *, size_t, rclcpp::Node::SharedPtr, ipc::IPCChannel *)>
 Function signature for handler publish functions Takes serialized data bytes (raw pointer + size to avoid copy), ROS node, and IPC channel.
 

Public Member Functions

void RegisterPublisher (ipc::MessageType msg_type, PublishFunction publish_func)
 Register a handler's publish function. More...
 
bool Publish (ipc::MessageType msg_type, const uint8_t *data, size_t data_size, rclcpp::Node::SharedPtr node, ipc::IPCChannel *channel=nullptr)
 Publish data using the registered handler. More...
 
bool HasPublisher (ipc::MessageType msg_type) const
 Check if a handler is registered for this message type.
 

Static Public Member Functions

static ChROSHandlerRegistryGetInstance ()
 Get the singleton instance.
 

Member Function Documentation

◆ Publish()

bool chrono::ros::ChROSHandlerRegistry::Publish ( ipc::MessageType  msg_type,
const uint8_t *  data,
size_t  data_size,
rclcpp::Node::SharedPtr  node,
ipc::IPCChannel channel = nullptr 
)
inline

Publish data using the registered handler.

Parameters
msg_typeMessage type identifier
dataPointer to serialized data bytes
data_sizeSize of data in bytes
nodeROS node for publishing
channelIPC channel for bidirectional communication (can be nullptr)
Returns
true if handler was found and called, false otherwise

◆ RegisterPublisher()

void chrono::ros::ChROSHandlerRegistry::RegisterPublisher ( ipc::MessageType  msg_type,
PublishFunction  publish_func 
)
inline

Register a handler's publish function.

Parameters
msg_typeMessage type identifier
publish_funcFunction to call when this message type is received

The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono_ros/ChROSHandlerRegistry.h