LCM Messages
DimOS uses LCM (Lightweight Communications and Marshalling) for inter-process communication on a local machine (similar to how ROS uses DDS). LCM is a simple UDP multicast pubsub protocol with a straightforward message definition language. The LCM project provides pubsub clients and code generators for many languages. For us the power of LCM is its message definition format, multi-language classes that encode themselves to a compact binary format. This means LCM messages can be sent over any transport (WebSocket, SSH, shared memory, etc.) between differnt programming languages. Our messages are ported from ROS (they are structurally compatible in order to facilitate easy communication to ROS if needed) Repo that hosts our message definitions and autogenerators is at dimos-lcm our LCM implementation significantly outperforms ROS for local communicationSupported languages
Apart from python, we have examples of LCM integrations for: In our /examples/language-interop/ dir Types generated (but no examples yet) for: C# and JavaNative Modules
Given LCM is so portable, we can easily run dimos Modules written in third party languagesdimos-lcm Package
Thedimos-lcm package provides base message types that mirror ROS message definitions:
session=lcm_demo ansi=false
Dimos Message Overlays
Dimos subclasses the base LCM types to add Python-friendly features while preserving binary compatibility. For example,dimos.msgs.geometry_msgs.Vector3 extends the LCM base with:
- Multiple constructor overloads (from tuples, numpy arrays, etc.)
- Math operations (
+,-,*,/, dot product, cross product) - Conversions to numpy, quaternions, etc.
session=lcm_demo ansi=false
PointCloud2 with Open3D
A more complex example isPointCloud2, which wraps Open3D point clouds while maintaining LCM binary compatibility:
session=lcm_demo ansi=false
Transport Independence
Since LCM messages encode to bytes, you can use them over any transport:session=lcm_demo ansi=false
Available Message Types
Dimos provides overlays for common message types:| Package | Messages |
|---|---|
geometry_msgs | Vector3, Quaternion, Pose, Twist, Transform |
sensor_msgs | Image, PointCloud2, CameraInfo, LaserScan |
nav_msgs | Odometry, Path, OccupancyGrid |
vision_msgs | Detection2D, Detection3D, BoundingBox2D |
dimos_lcm.*.
Creating Custom Message Types
To create a new message type:- Define the LCM message in
.lcmformat (or use existingdimos_lcmbase) - Create a Python overlay that subclasses the LCM type
- Add
lcm_encode()andlcm_decode()methods if custom serialization is needed
PointCloud2.py and Vector3.py for examples.