pydrake.lcm¶
-
class
pydrake.lcm.
DrakeLcm
¶ Bases:
pydrake.lcm.DrakeLcmInterface
A wrapper around a real LCM instance.
-
__init__
(*args, **kwargs)¶ Overloaded function.
- __init__(self: pydrake.lcm.DrakeLcm) -> None
Constructs using LCM’s default URL (either the default hard-coded URL, or else LCM_DEFAULT_URL environment variable if it is set).
- __init__(self: pydrake.lcm.DrakeLcm, lcm_url: str) -> None
Constructs using the given URL. If empty, it will use the default URL as per the no-argument constructor.
-
Subscribe
(self: pydrake.lcm.DrakeLcm, channel: str, handler: Callable[[bytes], None]) → None¶
-
-
class
pydrake.lcm.
DrakeLcmInterface
¶ A pure virtual interface that enables LCM to be mocked.
Because it must be pure, in general it will receive breaking API changes without notice. Users should not subclass this interface directly, but rather use one of the existing subclasses instead.
Similarly, method arguments will receive breaking API changes without notice. Users should not call this interface directly, but rather use drake::lcm::Publish() or drake::lcm::Subscribe() instead.
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
HandleSubscriptions
(self: pydrake.lcm.DrakeLcmInterface, timeout_millis: int) → int¶ 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. Raises: RuntimeError when a subscribed handler throws.
-
Publish
(self: pydrake.lcm.DrakeLcmInterface, channel: str, buffer: bytes, time_sec: Optional[float] = None) → None¶ Most users should use the drake::lcm::Publish() free function, instead of this interface method.
Publishes an LCM message on channel
channel
.- Parameter
channel
: - The channel on which to publish the message. Must not be the empty string.
- Parameter
data
: - A buffer containing the serialized bytes of the message to publish.
- Parameter
data_size
: - The length of @data in bytes.
- Parameter
time_sec
: - Time in seconds when the publish event occurred. If unknown, use nullopt or a default-constructed optional.
- Parameter
-
-
class
pydrake.lcm.
DrakeMockLcm
¶ Bases:
pydrake.lcm.DrakeLcm
An implementation of DrakeLcmInterface that manipulates LCM messages in memory, not on the wire. Other than the class name, it is identical to a
DrakeLcm("memq://")
, i.e., an object constructed with the <a href=”https://lcm-proj.github.io/group__LcmC__lcm__t.html#gaf29963ef43edadf45296d5ad82c18d4b”>memq provider</a>.-
__init__
(self: pydrake.lcm.DrakeMockLcm) → None¶
-
-
class
pydrake.lcm.
Subscriber
(lcm, channel, lcm_type)¶ Bases:
object
Subscribes to and stores a copy of the most recent message on a given channel, for some message type. This class does NOT provide any mutex behavior for multi-threaded locking; it should only be used in cases where the governing DrakeLcmInterface.HandleSubscriptions is called from the same thread that owns all copies of this object.
-
__init__
(lcm, channel, lcm_type)¶ Creates a subscriber and subscribes to channel on lcm.
Parameters: - lcm – LCM service instance (a pydrake.lcm.DrakeLcmInterface).
- channel – LCM channel name.
- lcm_type – Python class generated by lcmgen.
-
clear
()¶
-