ROS Vehicle Handlers

Description

Collaboration diagram for ROS Vehicle Handlers:

Classes

class  chrono::ros::ChROSDriverInputsHandler
 Handler for interfacing a ChDriver to ROS via bidirectional IPC communication. More...
 

Functions

 chrono::ros::ChROSDriverInputsHandler::ChROSDriverInputsHandler (std::shared_ptr< chrono::vehicle::ChDriver > driver, const std::string &topic_name)
 Constructor with default update rate. More...
 
 chrono::ros::ChROSDriverInputsHandler::ChROSDriverInputsHandler (double update_rate, std::shared_ptr< chrono::vehicle::ChDriver > driver, const std::string &topic_name)
 Constructor with custom update rate. More...
 
virtual bool chrono::ros::ChROSDriverInputsHandler::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 chrono::ros::ChROSDriverInputsHandler::GetMessageType () const override
 Get the message type of this handler.
 
void chrono::ros::ChROSDriverInputsHandler::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 chrono::ros::ChROSDriverInputsHandler::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 chrono::ros::ChROSDriverInputsHandler::SupportsIncomingMessages () const override
 Indicates this handler receives messages from subprocess. More...
 
virtual std::vector< uint8_t > chrono::ros::ChROSDriverInputsHandler::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...
 

Function Documentation

◆ ApplyInputs()

void chrono::ros::ChROSDriverInputsHandler::ApplyInputs ( double  steering,
double  throttle,
double  braking 
)

Apply driver inputs received from subprocess via IPC This method is called internally by HandleIncomingMessage()

Parameters
steeringSteering value from ROS message
throttleThrottle value from ROS message
brakingBraking value from ROS message

◆ ChROSDriverInputsHandler() [1/2]

chrono::ros::ChROSDriverInputsHandler::ChROSDriverInputsHandler ( double  update_rate,
std::shared_ptr< chrono::vehicle::ChDriver driver,
const std::string &  topic_name 
)

Constructor with custom update rate.

Parameters
update_rateRate at which to apply received inputs to driver (Hz)
driverChrono vehicle driver to update with ROS commands
topic_nameROS topic to subscribe to for driver inputs

◆ ChROSDriverInputsHandler() [2/2]

chrono::ros::ChROSDriverInputsHandler::ChROSDriverInputsHandler ( std::shared_ptr< chrono::vehicle::ChDriver driver,
const std::string &  topic_name 
)

Constructor with default update rate.

Parameters
driverChrono vehicle driver to update with ROS commands
topic_nameROS topic to subscribe to for driver inputs

◆ GetSerializedData()

std::vector< uint8_t > chrono::ros::ChROSDriverInputsHandler::GetSerializedData ( double  time)
overrideprotectedvirtual

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)

Parameters
timeCurrent simulation time (unused for subscribers)
Returns
Topic name bytes on first call, empty afterwards

Reimplemented from chrono::ros::ChROSHandler.

◆ HandleIncomingMessage()

void chrono::ros::ChROSDriverInputsHandler::HandleIncomingMessage ( const ipc::Message msg)
overridevirtual

Handle incoming IPC message from subprocess ROS subscriber Called by ChROSManager when IPC message of type DRIVER_INPUTS arrives.

Extracts DriverInputsData from message payload and applies to driver.

Parameters
msgIPC message containing DriverInputsData payload

Reimplemented from chrono::ros::ChROSHandler.

◆ Initialize()

bool chrono::ros::ChROSDriverInputsHandler::Initialize ( std::shared_ptr< ChROSInterface interface)
overridevirtual

Initialize handler (called once at startup in main process) In IPC mode, this does nothing.

Subprocess will create the actual ROS subscriber.

Implements chrono::ros::ChROSHandler.

◆ SupportsIncomingMessages()

virtual bool chrono::ros::ChROSDriverInputsHandler::SupportsIncomingMessages ( ) const
inlineoverridevirtual

Indicates this handler receives messages from subprocess.

Returns
true (this is a bidirectional subscriber)

Reimplemented from chrono::ros::ChROSHandler.