Drake
Drake C++ Documentation
LcmBuses Class Referencefinal

Detailed Description

A mapping from {bus_name: interface} with sugar for error checking with nice error messages during access.

Note that this class is shallow-const. A user of a const LcmBuses object cannot add or remove buses, but can retrieve a non-const DrakeLcmInterface pointer and then "modify" the object it points to by subscribing to a channel.

#include <drake/systems/lcm/lcm_buses.h>

Public Member Functions

 LcmBuses ()
 Constructs an empty mapping. More...
 
 ~LcmBuses ()
 
int size () const
 Returns the total number of buses. More...
 
drake::lcm::DrakeLcmInterfaceFind (std::string_view description_of_caller, const std::string &bus_name) const
 Finds the bus of the given name, or throws if there is no such bus. More...
 
std::vector< std::string_view > GetAllBusNames () const
 Returns a list of all known bus_name keys. More...
 
void Add (std::string bus_name, drake::lcm::DrakeLcmInterface *)
 Adds a bus. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 LcmBuses (const LcmBuses &)=default
 
LcmBusesoperator= (const LcmBuses &)=default
 
 LcmBuses (LcmBuses &&)=default
 
LcmBusesoperator= (LcmBuses &&)=default
 

Static Public Attributes

static constexpr char kLcmUrlMemqNull [] = "memq://null"
 A magic LCM URL sentinel value for the "null" LCM interface. More...
 

Constructor & Destructor Documentation

◆ LcmBuses() [1/3]

LcmBuses ( const LcmBuses )
default

◆ LcmBuses() [2/3]

LcmBuses ( LcmBuses &&  )
default

◆ LcmBuses() [3/3]

LcmBuses ( )

Constructs an empty mapping.

◆ ~LcmBuses()

~LcmBuses ( )

Member Function Documentation

◆ Add()

void Add ( std::string  bus_name,
drake::lcm::DrakeLcmInterface  
)

Adds a bus.

Throws if the bus is nullptr, or if there was already a bus of the same name.

◆ Find()

drake::lcm::DrakeLcmInterface* Find ( std::string_view  description_of_caller,
const std::string &  bus_name 
) const

Finds the bus of the given name, or throws if there is no such bus.

The return value is an alias into memory owned elsewhere (typically by a DiagramBuilder or a Diagram) and is never nullptr.

Parameters
description_of_calleris a noun phrase that will be used when creating an error message. A typical value would be something like "Camera 5", "Robot controller", "The default visualizer", or etc.

◆ GetAllBusNames()

std::vector<std::string_view> GetAllBusNames ( ) const

Returns a list of all known bus_name keys.

◆ operator=() [1/2]

LcmBuses& operator= ( LcmBuses &&  )
default

◆ operator=() [2/2]

LcmBuses& operator= ( const LcmBuses )
default

◆ size()

int size ( ) const

Returns the total number of buses.

Member Data Documentation

◆ kLcmUrlMemqNull

constexpr char kLcmUrlMemqNull[] = "memq://null"
static

A magic LCM URL sentinel value for the "null" LCM interface.

In some cases, LCM messages are unwanted but we need to pass around a well-formed DrakeLcmParams or DrakeLcmInterface object. Instead of passing nullptr objects, instead we pass an object set to use this URL. For example, this URL is used when ApplyLcmBusConfig() is given a nullopt DrakeLcmParams. The expectation is that interfaces with this URL will not even be pumped (i.e., no calls to HandleSubscriptions).


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