Drake
Drake C++ Documentation
DrakeLcmBase Class Reference

Detailed Description

A concrete subclass of DrakeInterface that throws for all functions except the constructor and destructor.

This is useful for subclasses that only wish to implement a subset of the DrakeLcmInterface features.

#include <drake/lcm/drake_lcm_base.h>

Public Member Functions

 ~DrakeLcmBase () override
 
std::string get_lcm_url () const override
 Returns a URL describing the transport of this LCM interface. More...
 
void Publish (const std::string &channel, const void *data, int data_size, std::optional< double > time_sec) override
 Most users should use the drake::lcm::Publish() free function, instead of this interface method. More...
 
std::shared_ptr< DrakeSubscriptionInterfaceSubscribe (const std::string &channel, 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< DrakeSubscriptionInterfaceSubscribeMultichannel (std::string_view regex, MultichannelHandlerFunction) override
 Subscribes to all channels whose name matches the given regular expression. More...
 
std::shared_ptr< DrakeSubscriptionInterfaceSubscribeAllChannels (MultichannelHandlerFunction) override
 Subscribe to all channels; this is useful for logging and redirecting LCM traffic without regard to its content. More...
 
int HandleSubscriptions (int timeout_millis) override
 Invokes the HandlerFunction callbacks for all subscriptions' pending messages. More...
 
Does not allow copy, move, or assignment
 DrakeLcmBase (const DrakeLcmBase &)=delete
 
DrakeLcmBaseoperator= (const DrakeLcmBase &)=delete
 
 DrakeLcmBase (DrakeLcmBase &&)=delete
 
DrakeLcmBaseoperator= (DrakeLcmBase &&)=delete
 
- Public Member Functions inherited from DrakeLcmInterface
virtual ~DrakeLcmInterface ()
 
 DrakeLcmInterface (const DrakeLcmInterface &)=delete
 
DrakeLcmInterfaceoperator= (const DrakeLcmInterface &)=delete
 
 DrakeLcmInterface (DrakeLcmInterface &&)=delete
 
DrakeLcmInterfaceoperator= (DrakeLcmInterface &&)=delete
 

Protected Member Functions

 DrakeLcmBase ()
 
- Protected Member Functions inherited from DrakeLcmInterface
 DrakeLcmInterface ()
 

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...
 

Constructor & Destructor Documentation

◆ DrakeLcmBase() [1/3]

DrakeLcmBase ( const DrakeLcmBase )
delete

◆ DrakeLcmBase() [2/3]

DrakeLcmBase ( DrakeLcmBase &&  )
delete

◆ ~DrakeLcmBase()

~DrakeLcmBase ( )
override

◆ DrakeLcmBase() [3/3]

DrakeLcmBase ( )
protected

Member Function Documentation

◆ get_lcm_url()

std::string get_lcm_url ( ) const
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.

◆ HandleSubscriptions()

int HandleSubscriptions ( int  timeout_millis)
overridevirtual

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.

Returns
the number of messages handled, or 0 on timeout.
Exceptions
std::exceptionwhen a subscribed handler throws.

Implements DrakeLcmInterface.

◆ operator=() [1/2]

DrakeLcmBase& operator= ( DrakeLcmBase &&  )
delete

◆ operator=() [2/2]

DrakeLcmBase& operator= ( const DrakeLcmBase )
delete

◆ Publish()

void Publish ( const std::string &  channel,
const void *  data,
int  data_size,
std::optional< double time_sec 
)
overridevirtual

Most users should use the drake::lcm::Publish() free function, instead of this interface method.

Publishes an LCM message on channel channel.

Parameters
channelThe channel on which to publish the message. Must not be the empty string.
dataA buffer containing the serialized bytes of the message to publish.
data_sizeThe length of @data in bytes.
time_secTime in seconds when the publish event occurred. If unknown, use nullopt or a default-constructed optional.

Implements DrakeLcmInterface.

◆ Subscribe()

std::shared_ptr<DrakeSubscriptionInterface> Subscribe ( const std::string &  channel,
HandlerFunction   
)
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.

Parameters
channelThe channel to subscribe to. Must not be the empty string. To use a regex, see SubscribeMultichannel().
Returns
the object used to manage the subscription if that is supported, or else nullptr if not supported. The unsubscribe-on-delete default is false. Refer to the DrakeSubscriptionInterface class overview for details.

Implements DrakeLcmInterface.

◆ SubscribeAllChannels()

std::shared_ptr<DrakeSubscriptionInterface> SubscribeAllChannels ( MultichannelHandlerFunction  )
overridevirtual

Subscribe to all channels; this is useful for logging and redirecting LCM traffic without regard to its content.

Implements DrakeLcmInterface.

◆ SubscribeMultichannel()

std::shared_ptr<DrakeSubscriptionInterface> SubscribeMultichannel ( std::string_view  regex,
MultichannelHandlerFunction   
)
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.


The documentation for this class was generated from the following file: