A wrapper around a real LCM instance.
See DRAKE_ALLOW_NETWORK for an environment variable option to disable LCM network traffic (i.e., only allowing memq:// URLs).
For network issues on macOS, see https://drake.mit.edu/troubleshooting.html#lcm-macos.
#include <drake/lcm/drake_lcm.h>
Public Member Functions | |
| DrakeLcm () | |
| Constructs using LCM's default URL (either the default hard-coded URL, or else LCM_DEFAULT_URL environment variable if it is set). More... | |
| DrakeLcm (std::string lcm_url) | |
| Constructs using the given URL. More... | |
| DrakeLcm (const DrakeLcmParams ¶ms) | |
| Constructs using the given parameters. More... | |
| ~DrakeLcm () override | |
| A destructor that forces the receive thread to be stopped. More... | |
| void | Publish (const std::string &, const void *, int, std::optional< double >) override |
| Most users should use the drake::lcm::Publish() free function, instead of this interface method. More... | |
| std::string | get_lcm_url () const override |
| Returns a URL describing the transport of this LCM interface. More... | |
| std::shared_ptr< DrakeSubscriptionInterface > | Subscribe (const std::string &, HandlerFunction) override |
| Most users should use the drake::lcm::Subscribe() free function or the drake::lcm::Subscriber wrapper class, instead of this interface method. More... | |
| std::shared_ptr< DrakeSubscriptionInterface > | SubscribeMultichannel (std::string_view, MultichannelHandlerFunction) override |
| Subscribes to all channels whose name matches the given regular expression. More... | |
| std::shared_ptr< DrakeSubscriptionInterface > | SubscribeAllChannels (MultichannelHandlerFunction) override |
| Subscribe to all channels; this is useful for logging and redirecting LCM traffic without regard to its content. More... | |
| int | HandleSubscriptions (int) override |
| Invokes the HandlerFunction callbacks for all subscriptions' pending messages. More... | |
Does not allow copy, move, or assignment | |
| DrakeLcm (const DrakeLcm &)=delete | |
| DrakeLcm & | operator= (const DrakeLcm &)=delete |
| DrakeLcm (DrakeLcm &&)=delete | |
| DrakeLcm & | operator= (DrakeLcm &&)=delete |
Public Member Functions inherited from DrakeLcmInterface | |
| virtual | ~DrakeLcmInterface () |
| DrakeLcmInterface (const DrakeLcmInterface &)=delete | |
| DrakeLcmInterface & | operator= (const DrakeLcmInterface &)=delete |
| DrakeLcmInterface (DrakeLcmInterface &&)=delete | |
| DrakeLcmInterface & | operator= (DrakeLcmInterface &&)=delete |
Static Public Member Functions | |
| static bool | available () |
| Returns true if the LCM runtime library is enabled in this build of Drake. More... | |
Friends | |
| class | DrakeLcmTester |
Additional Inherited Members | |
Public Types inherited from DrakeLcmInterface | |
| using | HandlerFunction = std::function< void(const void *, int)> |
| A callback used by DrakeLcmInterface::Subscribe(), with arguments: More... | |
| using | MultichannelHandlerFunction = std::function< void(std::string_view, const void *, int)> |
| A callback used by DrakeLcmInterface::SubscribeMultipleChannels (which therefore needs the receiving channel passed in). More... | |
Protected Member Functions inherited from DrakeLcmInterface | |
| DrakeLcmInterface () | |
| DrakeLcm | ( | ) |
Constructs using LCM's default URL (either the default hard-coded URL, or else LCM_DEFAULT_URL environment variable if it is set).
|
explicit |
Constructs using the given URL.
If empty, it will use the default URL as per the no-argument constructor.
|
explicit |
Constructs using the given parameters.
|
override |
A destructor that forces the receive thread to be stopped.
|
static |
Returns true if the LCM runtime library is enabled in this build of Drake.
When false, functions that require the runtime (e.g., HandleSubscriptions and Publish) will throw an error. See //tools/flags:with_lcm_runtime.
|
overridevirtual |
Returns a URL describing the transport of this LCM interface.
When the URL refers to a transport offered by LCM itself (e.g., memq or udpm), then this function must return the conventional URL spelling. If the implementation of DrakeLcmInterface is using a non-standard back end, the result implementation-defined.
In either case, it is always formatted using URI syntax rules per the RFC(s).
Implements DrakeLcmInterface.
Invokes the HandlerFunction callbacks for all subscriptions' pending messages.
If timeout_millis is >0, blocks for up to that long until at least one message is handled.
| std::exception | when a subscribed handler throws. |
Implements DrakeLcmInterface.
|
overridevirtual |
Most users should use the drake::lcm::Publish() free function, instead of this interface method.
Publishes an LCM message on channel channel.
| channel | The channel on which to publish the message. Must not be the empty string. |
| data | A buffer containing the serialized bytes of the message to publish. |
| data_size | The length of @data in bytes. |
| time_sec | Time in seconds when the publish event occurred. If unknown, use nullopt or a default-constructed optional. |
Implements DrakeLcmInterface.
|
overridevirtual |
Most users should use the drake::lcm::Subscribe() free function or the drake::lcm::Subscriber wrapper class, instead of this interface method.
Subscribes to an LCM channel without automatic message decoding. The handler will be invoked when a message arrives on channel channel.
The handler should never throw an exception, because it is indirectly called from C functions.
| channel | The channel to subscribe to. Must not be the empty string. To use a regex, see SubscribeMultichannel(). |
false. Refer to the DrakeSubscriptionInterface class overview for details. Implements DrakeLcmInterface.
|
overridevirtual |
Subscribe to all channels; this is useful for logging and redirecting LCM traffic without regard to its content.
Implements DrakeLcmInterface.
|
overridevirtual |
Subscribes to all channels whose name matches the given regular expression.
The regex is treated as an anchored "match" not a "search", i.e., it must match the entire channel name. The specific regular expression grammar is left unspecified, so it's best to use only patterns that have identical semantics in all grammars, e.g., ".*".
Implements DrakeLcmInterface.
|
friend |