rosrust
rosrust copied to clipboard
Allow periodic and unique logging
Both rospy
and roscpp
allow various frequencies and ways of logging. In rospy
there are most prominently logs that happen periodically or once, as described here.
In the C++ and Python solution, this is done by taking the line number and filename, and maintaining a singleton hash map of all the periodic and unique logs. So logic would be to use lazy_static to create:
- hashmap periodicLog with key "file:line" and value Time representing the next fitting time.
- hashset uniqueLog with same key structure.
- the
ros_*_throttle!
andros_*_once!
macros would check time/presence, and execute the normal log if things fit, updating the time to (now() + 1s/rate) in the former case.