How to remove lag in marker publishing?
I am publishing markers in a subscriber callback so that whenever new data is received on a topic a marker is created. Markers are published and displayed well at first but after a while markers are slow to publish and therefore become spaced at greater and greater distances apart. Any idea how to solve this? To visualise I am using RViz
and ros3djs
.
Can I use ros::Time to measure the time taken from the beginning to the end of a callback function? Also, do you know the interval between subscribing? (You can find it with
rostopic hz /tf(?)
, I think. )This is just a thought, but it may be that the time taken for the callback is longer than the interval to subscribe. Then gradually the buffer will fill up and topics will appear that are not stored in the buffer. That may be what is making the interval look large.
Are markers also deleted?
Markers are not deleted. I'll measure the callback time tomorrow. For now, I've also seen this message in the terminal output which starts exactly when the lag begins:
Could not find a connection between 'map' and 'odom' because they are not part of the same tree.Tf has two or more unconnected trees.
This appears to be related to this function which is also called within my callback:that's not necessarily a good idea. All physical systems have limits, and browsers are no exception.
re: your TF problem: you cannot create a
TransformListener
in a callback or function, there isn't sufficient time for the buffer to be filled with TF messages such that your lookups succeed.This is a very well known anti-pattern.
OK thanks for the guidance. Are there any alternate approaches to getting the robot pose in the map frame within a callback? Also, I need markers to not be deleted for visualisation.