DAIRLab / dairlib

MIT License
66 stars 26 forks source link

Our current version of LcmDrivenLoop might be getting old message #229

Open yminchen opened 3 years ago

yminchen commented 3 years ago

Per discussion with @mposa, we should keep an eye on the issue of LcmDrivenLoop potentially getting old lcm messages.

Problem description: After calling drake::lcm::Subscriber.clear() and LcmHandleSubscriptionsUntil() to wait for a new message, it's still possible that we read an old message when we call drake::lcm::Subscriber.message().
This problem is not critical unless the LcmDrivenLoop is intended to be run at a lower rate than the incoming message's rate.

Potentially the best solution: The problem is probably caused by us running LcmHandleSubscriptionsUntil in the main thread. A solution could be running the lcm subscriber on a different thread so that it's constantly updating the message buffer.
https://github.com/RobotLocomotion/drake/blob/b09e40db4b1c01232b22f7705fb98aa99ef91f87/lcm/test/drake_lcm_thread_test.cc

Hacky solution: Call clear() and LcmHandleSubscriptionsUntil() twice.