Classes | |
class | DrakeLcm |
A wrapper around a real LCM instance. More... | |
class | DrakeLcmBase |
A concrete subclass of DrakeInterface that throws for all functions except the constructor and destructor. More... | |
class | DrakeLcmInterface |
A pure virtual interface that enables LCM to be mocked. More... | |
class | DrakeLcmLog |
A LCM interface for logging LCM messages to a file or playing back from a existing log. More... | |
struct | DrakeLcmParams |
The set of parameters for configuring DrakeLcm. More... | |
class | DrakeSubscriptionInterface |
A helper class returned by DrakeLcmInterface::Subscribe() that allows for (possibly automatic) unsubscription and/or queue capacity control. More... | |
class | Subscriber |
Subscribes to and stores a copy of the most recent message on a given channel, for some Message type. More... | |
Functions | |
template<typename Message > | |
void | Publish (DrakeLcmInterface *lcm, const std::string &channel, const Message &message, std::optional< double > time_sec={}) |
Publishes an LCM message on channel channel . More... | |
template<typename Message > | |
std::shared_ptr< DrakeSubscriptionInterface > | Subscribe (DrakeLcmInterface *lcm, const std::string &channel, std::function< void(const Message &)> handler, std::function< void()> on_error={}) |
Subscribes to an LCM channel named channel and decodes messages of type Message . More... | |
int | LcmHandleSubscriptionsUntil (DrakeLcmInterface *lcm, const std::function< bool(void)> &finished, int timeout_millis=100) |
Convenience function that repeatedly calls lcm->HandleSubscriptions() with a timeout value of timeout_millis , until finished() returns true. More... | |
template<typename Message > | |
std::vector< uint8_t > | EncodeLcmMessage (const Message &message) |
Encodes an LCM message to a series of bytes. More... | |
template<typename Message > | |
Message | DecodeLcmMessage (const std::vector< uint8_t > &bytes) |
Decodes an LCM message from a series of bytes. More... | |
template<typename Message > | |
bool | AreLcmMessagesEqual (const Message &a, const Message &b) |
Compares two LCM messages of the same type to see if they are equal. More... | |
bool | CompareLcmtDrakeSignalMessages (const lcmt_drake_signal &actual_message, const lcmt_drake_signal &expected_message) |
Compares two drake::lcmt_drake_signal messages are equal. More... | |
bool drake::lcm::AreLcmMessagesEqual | ( | const Message & | a, |
const Message & | b | ||
) |
Compares two LCM messages of the same type to see if they are equal.
bool drake::lcm::CompareLcmtDrakeSignalMessages | ( | const lcmt_drake_signal & | actual_message, |
const lcmt_drake_signal & | expected_message | ||
) |
Compares two drake::lcmt_drake_signal
messages are equal.
[in] | actual_message | The actual message to be compared against expected_message . |
[in] | expected_message | The expected message to be compared against actual message. |
true
if actual_message
and expected_message
are equal. Message drake::lcm::DecodeLcmMessage | ( | const std::vector< uint8_t > & | bytes | ) |
Decodes an LCM message from a series of bytes.
std::exception | if decoding fails. |
std::vector<uint8_t> drake::lcm::EncodeLcmMessage | ( | const Message & | message | ) |
Encodes an LCM message to a series of bytes.
int drake::lcm::LcmHandleSubscriptionsUntil | ( | DrakeLcmInterface * | lcm, |
const std::function< bool(void)> & | finished, | ||
int | timeout_millis = 100 |
||
) |
Convenience function that repeatedly calls lcm->HandleSubscriptions()
with a timeout value of timeout_millis
, until finished()
returns true.
Returns the total number of messages handled.
void drake::lcm::Publish | ( | DrakeLcmInterface * | lcm, |
const std::string & | channel, | ||
const Message & | message, | ||
std::optional< double > | time_sec = {} |
||
) |
Publishes an LCM message on channel channel
.
lcm | The LCM service on which to publish the message. Must not be null. |
channel | The channel on which to publish the message. Must not be the empty string. |
message | The message to publish. |
time_sec | Time in seconds when the publish event occurred. If unknown, use the default value of nullopt. |
std::shared_ptr<DrakeSubscriptionInterface> drake::lcm::Subscribe | ( | DrakeLcmInterface * | lcm, |
const std::string & | channel, | ||
std::function< void(const Message &)> | handler, | ||
std::function< void()> | on_error = {} |
||
) |
Subscribes to an LCM channel named channel
and decodes messages of type Message
.
See also drake::lcm::Subscriber for a simple way to passively observe received messages, without the need to write a handler function.
lcm | The LCM service on which to subscribe. Must not be null. |
channel | The channel on which to subscribe. Must not be the empty string. |
handler | The callback when a message is received and decoded without error. |
on_error | The callback when a message is received and cannot be decoded; if no error handler is given, an exception is thrown instead. |
false
, so that ignoring this result leaves the subscription intact. Refer to the DrakeSubscriptionInterface class overview for details.