A LCM interface for logging LCM messages to a file or playing back from a existing log.
Note the user is responsible for offsetting the clock used to generate the log and the clock used for playback. For example, if the log is generated by some external logger (the lcm-logger binary), which uses the unix epoch time clock to record message arrival time, the user needs to offset those timestamps properly to match and the clock used for playback.
|
| DrakeLcmLog (const std::string &file_name, bool is_write, bool overwrite_publish_time_with_system_clock=false) |
| Constructs a DrakeLcmLog. More...
|
|
| ~DrakeLcmLog () override |
|
void | Publish (const std::string &channel, const void *data, int data_size, std::optional< double > time_sec) override |
| Writes an entry occurred at timestamp with content data to the log file. More...
|
|
std::shared_ptr< DrakeSubscriptionInterface > | Subscribe (const std::string &channel, HandlerFunction handler) override |
| Subscribes handler to channel . More...
|
|
std::shared_ptr< DrakeSubscriptionInterface > | SubscribeMultichannel (std::string_view regex, MultichannelHandlerFunction) override |
| This function is not yet supported for LCM logs, and will always throw. 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 |
| This is a no-op for Read mode, and an exception in Write mode. More...
|
|
double | GetNextMessageTime () const |
| Returns the time in seconds for the next logged message's occurrence time or infinity if there are no more messages in the current log. More...
|
|
void | DispatchMessageAndAdvanceLog (double current_time) |
| Let MSG be the next message event in the log, if current_time matches MSG 's timestamp, for every DrakeLcmMessageHandlerInterface sub that's subscribed to MSG 's channel, invoke sub 's HandleMessage method. More...
|
|
bool | is_write () const |
| Returns true if this instance is constructed in write-only mode. More...
|
|
double | timestamp_to_second (uint64_t timestamp) const |
| Converts timestamp (in microseconds) to time (in seconds) relative to the starting time passed to the constructor. More...
|
|
uint64_t | second_to_timestamp (double sec) const |
| Converts time (in seconds) relative to the starting time passed to the constructor to a timestamp in microseconds. More...
|
|
std::string | get_lcm_url () const override |
| Returns a URL describing the transport of this LCM interface. More...
|
|
|
| DrakeLcmLog (const DrakeLcmLog &)=delete |
|
DrakeLcmLog & | operator= (const DrakeLcmLog &)=delete |
|
| DrakeLcmLog (DrakeLcmLog &&)=delete |
|
DrakeLcmLog & | operator= (DrakeLcmLog &&)=delete |
|
virtual | ~DrakeLcmInterface () |
|
| DrakeLcmInterface (const DrakeLcmInterface &)=delete |
|
DrakeLcmInterface & | operator= (const DrakeLcmInterface &)=delete |
|
| DrakeLcmInterface (DrakeLcmInterface &&)=delete |
|
DrakeLcmInterface & | operator= (DrakeLcmInterface &&)=delete |
|
void DispatchMessageAndAdvanceLog |
( |
double |
current_time | ) |
|
Let MSG
be the next message event in the log, if current_time
matches MSG
's timestamp, for every DrakeLcmMessageHandlerInterface sub
that's subscribed to MSG
's channel, invoke sub
's HandleMessage method.
Then, this function advances the log by exactly one message. This function does nothing if MSG
is null (end of log) or current_time
does not match MSG
's timestamp.
- Exceptions
-
std::exception | if this instance is not constructed in read-only mode. |
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.