Skip to content

Commit

Permalink
MultiLogIterator: remove wraparound mode (commaai#23360)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Jan 2, 2022
1 parent 9d3a821 commit 92f194d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion selfdrive/debug/fingerprint_from_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ def get_fingerprint(lr):
sys.exit(1)

route = Route(sys.argv[1])
lr = MultiLogIterator(route.log_paths()[:5], wraparound=False)
lr = MultiLogIterator(route.log_paths()[:5])
get_fingerprint(lr)
2 changes: 1 addition & 1 deletion selfdrive/debug/run_process_on_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cfg = [c for c in CONFIGS if c.proc_name == args.process][0]

route = Route(args.route)
lr = MultiLogIterator(route.log_paths(), wraparound=False)
lr = MultiLogIterator(route.log_paths())
inputs = list(lr)

outputs = replay_process(cfg, inputs)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/debug/toyota_eps_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ def get_eps_factor(lr, plot=False):

if __name__ == "__main__":
r = Route(sys.argv[1])
lr = MultiLogIterator(r.log_paths(), wraparound=False)
lr = MultiLogIterator(r.log_paths())
n = get_eps_factor(lr, plot="--plot" in sys.argv)
print("EPS torque factor: ", n)
9 changes: 2 additions & 7 deletions tools/lib/logreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

# this is an iterator itself, and uses private variables from LogReader
class MultiLogIterator:
def __init__(self, log_paths, wraparound=False, sort_by_time=False):
def __init__(self, log_paths, sort_by_time=False):
self._log_paths = log_paths
self._wraparound = wraparound

self._first_log_idx = next(i for i in range(len(log_paths)) if log_paths[i] is not None)
self._current_log = self._first_log_idx
Expand All @@ -42,12 +41,8 @@ def _inc(self):
self._idx = 0
self._current_log = next(i for i in range(self._current_log + 1, len(self._log_readers) + 1)
if i == len(self._log_readers) or self._log_paths[i] is not None)
# wraparound
if self._current_log == len(self._log_readers):
if self._wraparound:
self._current_log = self._first_log_idx
else:
raise StopIteration
raise StopIteration

def __next__(self):
while 1:
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/save_ubloxraw_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main(argv):
args.data_dir = os.path.dirname(args.data_dir)

route = Route(args.route_name, args.data_dir)
lr = MultiLogIterator(route.log_paths(), wraparound=False)
lr = MultiLogIterator(route.log_paths())

with open(args.out_path, 'wb') as f:
try:
Expand Down

0 comments on commit 92f194d

Please sign in to comment.