Transports
Transports connect module streams across process boundaries and/or networks.- Module: a running component (e.g., camera, mapping, nav).
- Stream: a unidirectional flow of messages owned by a module (one broadcaster → many receivers).
- Topic: the name/identifier used by a transport or pubsub backend.
- Message: payload carried on a stream (often
dimos.msgs.*, but can be bytes / images / pointclouds / etc.).
What the transport layer guarantees (and what it doesn’t)
Modules don’t know or care how data moves. They just:- emit messages (broadcast)
- subscribe to messages (receive)
- Some are best-effort (e.g., UDP multicast / LCM): loss can happen.
- Some can be reliable (e.g., TCP-backed, Redis, some DDS configs) but may add latency/backpressure.
Benchmarks
Quick view on performance of our pubsub backends:skip
Abstraction layers
Using transports with blueprints
See Blueprints for the blueprint API. Fromunitree/go2/blueprints/smart/unitree_go2.py.
Example: rebind a few streams from the default LCMTransport to ROSTransport (defined at transport.py) so you can visualize in rviz2.
skip
Using transports with modules
Each stream on a module can use a different transport. Set.transport on the stream before starting modules.
The runnable example below uses a tiny synthetic image publisher instead of CameraModule so it works without a webcam and in CI; the wiring is the same as with a real camera.
ansi=false
Inspecting LCM traffic (CLI)
lcmspy shows topic frequency/bandwidth stats:
dimos topic echo /topic listens on typed channels like /topic#pkg.Msg and decodes automatically:
skip
Implementing a transport
At the stream layer, a transport is implemented by subclassingTransport (see core/stream.py) and implementing:
broadcast(...)subscribe(...)
Transport.__init__ args can be anything meaningful for your backend:
(ip, port)- a shared-memory segment name
- a filesystem path
- a Redis channel
Encoding helpers
Many of our message types providelcm_encode / lcm_decode for compact, language-agnostic binary encoding (often faster than pickle). For details, see LCM.
PubSub transports
Even though transport can be anything (TCP connection, unix socket) for now all our transport backends implement thePubSub interface.
publish(topic, message)subscribe(topic, callback) -> unsubscribe
LCM (UDP multicast)
LCM is UDP multicast. It’s very fast on a robot LAN, but it’s best-effort (packets can drop). For local emission it autoconfigures system in a way in which it’s more robust and faster then other more common protocols like ROS, DDSShared memory (IPC)
Shared memory is highest performance, but only works on the same machine.DDS Transport
For network communication, DDS uses the Data Distribution Service (DDS) protocol:skip session=dds_demo ansi=false
A minimal transport: Memory
The simplest toy backend is Memory (single process). Start from there when implementing a new pubsub backend.
pubsub/impl/memory.py for the complete source.
Encode/decode mixins
Transports often need to serialize messages before sending and deserialize after receiving.PubSubEncoderMixin at pubsub/encoders.py provides a clean way to add encoding/decoding to any pubsub implementation.
Available mixins
| Mixin | Encoding | Use case |
|---|---|---|
PickleEncoderMixin | Python pickle | Any Python object, Python-only |
LCMEncoderMixin | LCM binary | Cross-language (C/C++/Python/Go/…) |
JpegEncoderMixin | JPEG compressed | Image data, reduces bandwidth |
LCMEncoderMixin is especially useful: you can use LCM message definitions with any transport (not just UDP multicast). See LCM for details.
Creating a custom mixin
session=jsonencoder no-result
session=jsonencoder no-result
session=jsonencoder no-result
Testing and benchmarks
Spec tests
Seepubsub/test_spec.py for the grid tests your new backend should pass.
Benchmarks
Add your backend to benchmarks to compare in context:skip
Available transports
| Transport | Use case | Cross-process | Network | Notes |
|---|---|---|---|---|
Memory | Testing only, single process | No | No | Minimal reference impl |
SharedMemory | Multi-process on same machine | Yes | No | Highest throughput (IPC) |
LCM | Robot LAN broadcast (UDP multicast) | Yes | Yes | Best-effort; can drop packets on LAN |
Redis | Network pubsub via Redis server | Yes | Yes | Central broker; adds hop |
ROS | ROS 2 topic communication | Yes | Yes | Integrates with RViz/ROS tools |
DDS | Cyclone DDS without ROS (WIP) | Yes | Yes | WIP |
