Wait for TF listern queue to not be empty
I am noticing an issue with TF LIsteren in Electric that doesn't seem to be covered by other questions. Mainly, if I create a TF listener tf_, then immediately go into a callback that calls tf_.waitForTransform(...), I get: "terminate called after throwing an instance of 'tf::ExtrapolationException' what(): Unable to lookup transform, cache is empty, when looking up transform from frame ...."
What it seems is that the listener hasn't been active long enough to get any TF information before waitForTransform is called, and when you call waitForTransform on a listener with an empty cache/queue, is throws this exception deep down (I can't catch it at the level of calling waitForTransform) and the process is ended.
I'd like to be able to first look to see if the cache is not empty, or be able to catch this at the high level.
Any suggestions?
BTW, the only way I've found around this so far is to sleep for a couple of seconds after creating the listener and before calling waitForTransform().