chrono::ros::ChROSDriverInputsHandler Class Reference
Description
Handler for interfacing a ChDriver to ROS via bidirectional IPC communication.
BIDIRECTIONAL SUBSCRIBER PATTERN:
- Main process: Calls GetSerializedData() once to send topic name → subprocess creates subscriber
- Subprocess: ROS message arrives → packs IPC data → sends back to main process
- Main process: Receives IPC → calls HandleIncomingMessage() → applies data to Chrono object
Data flow: External ROS → Subprocess subscriber → IPC channel → Main process → ChDriver
Implementation files:
- ChROSDriverInputsHandler.cpp: Main process logic (ApplyInputs, HandleIncomingMessage)
- ChROSDriverInputsHandler_ros.cpp: Subprocess ROS subscriber (compiled into chrono_ros_node)
To implement a similar bidirectional subscriber:
- Define IPC struct in handler header under namespace ipc (plain C++ types)
- Override SupportsIncomingMessages() to return true
- Override HandleIncomingMessage() to extract IPC data and apply to Chrono object
- Implement GetSerializedData() to send topic name once (empty afterwards)
- Create YourHandler_ros.cpp with subscriber callback that sends IPC back
- Register with CHRONO_ROS_REGISTER_HANDLER(YOUR_MESSAGE_TYPE, YourSetupFunction)
- Add YOUR_MESSAGE_TYPE to MessageType enum in ChROSIPCMessage.h
- Add handler recognition to ChROSManager::GetHandlerMessageType()
#include <ChROSDriverInputsHandler.h>
Inheritance diagram for chrono::ros::ChROSDriverInputsHandler:

Collaboration diagram for chrono::ros::ChROSDriverInputsHandler:

Public Member Functions | |
| ChROSDriverInputsHandler (std::shared_ptr< chrono::vehicle::ChDriver > driver, const std::string &topic_name) | |
| Constructor with default update rate. More... | |
| ChROSDriverInputsHandler (double update_rate, std::shared_ptr< chrono::vehicle::ChDriver > driver, const std::string &topic_name) | |
| Constructor with custom update rate. More... | |
| virtual bool | Initialize (std::shared_ptr< ChROSInterface > interface) override |
| Initialize handler (called once at startup in main process) In IPC mode, this does nothing. More... | |
| virtual ipc::MessageType | GetMessageType () const override |
| Get the message type of this handler. | |
| void | ApplyInputs (double steering, double throttle, double braking) |
| Apply driver inputs received from subprocess via IPC This method is called internally by HandleIncomingMessage() More... | |
| virtual void | HandleIncomingMessage (const ipc::Message &msg) override |
| Handle incoming IPC message from subprocess ROS subscriber Called by ChROSManager when IPC message of type DRIVER_INPUTS arrives. More... | |
| virtual bool | SupportsIncomingMessages () const override |
| Indicates this handler receives messages from subprocess. More... | |
Public Member Functions inherited from chrono::ros::ChROSHandler | |
| virtual | ~ChROSHandler ()=default |
| Destructor for the ChROSHandler. | |
| const double | GetUpdateRate () const |
| Get the period which this handler operates at. | |
| const uint64_t | GetTickCount () const |
| Get the number of times Tick() has been called. | |
| virtual bool | IsPublisher () const |
| Check if this handler is a publisher (data flows from Chrono to ROS) Default is true. More... | |
| virtual void | PublishFromSerialized (const std::vector< uint8_t > &data, std::shared_ptr< ChROSInterface > interface) |
| Publish data to ROS from serialized bytes. More... | |
| virtual void | ApplyFromSerialized (const std::vector< uint8_t > &data) |
| Apply data to Chrono from serialized bytes. More... | |
| virtual void | SubscribeAndForward (std::shared_ptr< ChROSInterface > interface, std::function< void(const std::vector< uint8_t > &)> callback) |
| Setup subscriber in subprocess to send data back to main process. More... | |
Protected Member Functions | |
| virtual std::vector< uint8_t > | GetSerializedData (double time) override |
| Send topic name to subprocess once to trigger subscriber creation First call: Returns topic name as bytes for subprocess setup Subsequent calls: Returns empty vector (no data to publish) More... | |
Protected Member Functions inherited from chrono::ros::ChROSHandler | |
| ChROSHandler (double update_rate) | |
| Constructor for the ChROSHandler. More... | |
| void | IncrementTickCount () |
| Increment the tick count. | |
Additional Inherited Members | |
Public Types inherited from chrono::ros::ChROSHandler | |
| typedef chrono::ros::ipc::MessageType | MessageType |
| Get the message type of this handler. More... | |
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono_ros/handlers/vehicle/ChROSDriverInputsHandler.h
- /builds/uwsbel/chrono/src/chrono_ros/handlers/vehicle/ChROSDriverInputsHandler.cpp
Public Member Functions inherited from