From d819913cb10f7dd9d50024faf114e1a49ece5b3d Mon Sep 17 00:00:00 2001 From: "Simon D. Levy" Date: Sun, 3 Jun 2018 00:24:54 -0400 Subject: [PATCH] Cleanup --- examples/logmovie.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/logmovie.py b/examples/logmovie.py index 1b48cce..38c03bb 100755 --- a/examples/logmovie.py +++ b/examples/logmovie.py @@ -47,7 +47,7 @@ from time import sleep from threading import Thread import pickle -def threadfunc(robot, slam, timestamps, lidars, odometries, use_odometry, mapbytes, pose): +def threadfunc(robot, slam, timestamps, lidars, odometries, mapbytes, pose): ''' Threaded function runs SLAM, setting the map bytes and robot pose for display on the main thread. @@ -59,18 +59,18 @@ def threadfunc(robot, slam, timestamps, lidars, odometries, use_odometry, mapbyt # Loop over scans for scanno in range(len(lidars)): - if use_odometry: + if odometries is None: + # Update SLAM with lidar alone + slam.update(lidars[scanno]) + + else: + # Convert odometry to velocities velocities = robot.computeVelocities(odometries[scanno]) # Update SLAM with lidar and velocities slam.update(lidars[scanno], velocities) - - else: - - # Update SLAM with lidar alone - slam.update(lidars[scanno]) # Get new position pose[0],pose[1],pose[2] = slam.getpos() @@ -118,7 +118,7 @@ def main(): pose = [0,0,0] # Launch the data-collection / update thread - thread = Thread(target=threadfunc, args=(robot, slam, timestamps, lidars, odometries, use_odometry, mapbytes, pose)) + thread = Thread(target=threadfunc, args=(robot, slam, timestamps, lidars, odometries if use_odometry else None, mapbytes, pose)) thread.daemon = True thread.start()