From da5093045075ee7f8253fe071c74bc5b04117b34 Mon Sep 17 00:00:00 2001 From: xx979xx <40252818+xx979xx@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:04:41 +0300 Subject: [PATCH] tools: add MultiLogIterator example to readme (#23917) * update LogReader doc use MultiLogIterator to read the entire route, get timestamps and deal with exceptions * bring back the old example * clean f-strings * simplify Co-authored-by: Adeeb Shihadeh --- tools/lib/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/lib/README.md b/tools/lib/README.md index c681809eae..241232eae2 100644 --- a/tools/lib/README.md +++ b/tools/lib/README.md @@ -31,3 +31,21 @@ for msg in lr: if msg.which() == "carState": print(msg.carState.steeringAngleDeg) ``` + +### MultiLogIterator + +`MultiLogIterator` is similar to `LogReader`, but reads multiple logs. + +```python +from tools.lib.route import Route +from tools.lib.logreader import MultiLogIterator + +# setup a MultiLogIterator to read all the logs in the route +r = Route("4cf7a6ad03080c90|2021-09-29--13-46-36") +lr = MultiLogIterator(r.log_paths()) + +# print all the steering angles values from all the logs in the route +for msg in lr: + if msg.which() == "carState": + print(msg.carState.steeringAngleDeg) +```