chrono::ros::ChROSTFHandler Class Reference

Description

Handler responsible for publishing transform (tf) information via IPC.

PUBLISHER PATTERN (variable-size data):

  • Main process: Calls GetSerializedData() each tick → packs multiple transforms → sends IPC
  • Subprocess: Receives IPC → unpacks transform array → publishes to /tf

This handler supports dynamic transform lists (body-to-body) and static transforms (body-to-frame). All transforms are computed in main process and sent as serialized data to subprocess.

IPC data structures defined in ChROSIPCMessage.h:

Implementation files:

  • ChROSTFHandler.cpp: Main process logic (compute transforms, serialize)
  • ChROSTFHandler_ros.cpp: Subprocess ROS publishing (deserialize, publish tf)

#include <ChROSTFHandler.h>

Inheritance diagram for chrono::ros::ChROSTFHandler:
Collaboration diagram for chrono::ros::ChROSTFHandler:

Public Member Functions

 ChROSTFHandler (double update_rate)
 Constructor.
 
virtual bool Initialize (std::shared_ptr< ChROSInterface > interface) override
 Initializes the handler (no-op in IPC mode, broadcaster in subprocess)
 
virtual ipc::MessageType GetMessageType () const override
 Get the message type of this handler.
 
virtual std::vector< uint8_t > GetSerializedData (double time) override
 Extract transform data for IPC transmission to subprocess Computes all transforms, serializes into variable-size byte array Format: ipc::TFData header + array of ipc::TFTransform structs (see ChROSIPCMessage.h) More...
 
void AddTransform (std::shared_ptr< chrono::ChBody > parent, const std::string &parent_frame_id, std::shared_ptr< chrono::ChBody > child, const std::string &child_frame_id)
 Add a transform to be published. More...
 
void AddTransform (std::shared_ptr< chrono::ChBody > parent, const std::string &parent_frame_id, chrono::ChFrame< double > child_frame, const std::string &child_frame_id)
 Add a transform to be published. 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...
 
virtual void HandleIncomingMessage (const ipc::Message &msg)
 Handle incoming IPC message from ROS subscriber (bidirectional communication). More...
 
virtual bool SupportsIncomingMessages () const
 Returns true if this handler processes incoming IPC messages. More...
 

Additional Inherited Members

- Public Types inherited from chrono::ros::ChROSHandler
typedef chrono::ros::ipc::MessageType MessageType
 Get the message type of this handler. More...
 
- Protected Member Functions inherited from chrono::ros::ChROSHandler
 ChROSHandler (double update_rate)
 Constructor for the ChROSHandler. More...
 
void IncrementTickCount ()
 Increment the tick count.
 

Member Function Documentation

◆ AddTransform() [1/2]

void chrono::ros::ChROSTFHandler::AddTransform ( std::shared_ptr< chrono::ChBody parent,
const std::string &  parent_frame_id,
chrono::ChFrame< double >  child_frame,
const std::string &  child_frame_id 
)

Add a transform to be published.

This version of the AddTransform function will publish a static transform between the parent and child frame. This is useful for two bodies that are connected by a link.

Parameters
parentThe parent body
parent_frameThe parent frame id.
child_frameThe child frame
child_frame_idThe child frame id

◆ AddTransform() [2/2]

void chrono::ros::ChROSTFHandler::AddTransform ( std::shared_ptr< chrono::ChBody parent,
const std::string &  parent_frame_id,
std::shared_ptr< chrono::ChBody child,
const std::string &  child_frame_id 
)

Add a transform to be published.

This version of the AddTransform function will use two bodies directly and calculate the transform at each tick. This is useful for two bodies that are not connected by a link. For each iteration of this method, when the frame id for the parent and/or child is not passed, it defaults to the name of the body.

◆ GetSerializedData()

std::vector< uint8_t > chrono::ros::ChROSTFHandler::GetSerializedData ( double  time)
overridevirtual

Extract transform data for IPC transmission to subprocess Computes all transforms, serializes into variable-size byte array Format: ipc::TFData header + array of ipc::TFTransform structs (see ChROSIPCMessage.h)

Parameters
timeCurrent simulation time in seconds
Returns
Serialized transform data

Reimplemented from chrono::ros::ChROSHandler.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_ros/handlers/ChROSTFHandler.h
  • /builds/uwsbel/chrono/src/chrono_ros/handlers/ChROSTFHandler.cpp