LCM Go
Performant, native Go LCM implementation with integrated support for protobuf and compression.
Installation
go get go.einride.tech/lcm
Usage
Receiver
rx, err := lcm.ListenMulticastUDP(
ctx,
lcm.WithReceiveInterface("eth0"),
lcm.WithReceiveProtos(×tamppb.Timestamp{}),
)
if err != nil {
panic(err) // TODO: Handle error.
}
if err := rx.ReceiveProto(ctx); err != nil {
panic(err) // TODO: Handle error.
}
log.Println(rx.ProtoMessage())
Transmitter
tx, err := lcm.DialMulticastUDP(
ctx,
lcm.WithTransmitInterface("eth0"),
)
if err != nil {
panic(err) // TODO: Handle error.
}
if err := tx.TransmitProto(ctx, ×tamppb.Now()); err != nil {
panic(err) // TODO: Handle error.
}
Notable features
Protobuf messages
Protobuf messages can be transmitted and received, with encoding and decoding handled by the LCM stack.
Compression
The library can handle compression and decompression of messages at the channel-level, with the compression scheme indicated by a query-parameter on the channel name (similar to HTTP URLs).
For example an LZ4 compressed message transmitted over a channel named
google.protobuf.Timestamp?z=lz4
will be automatically decompressed.
BPF filtering
When specifying a set of channels to receive from, the library will attempt to use BPF filters to only receive messages from those channels from the kernel.
However, since there is a limit of 255 instructions on BPF filters, if there are too many channels, it will fallback and listening to everything.
Notable missing features
Fragmented messages
This library currently does not support fragmented messages.