diff --git a/social_mpc/path.py b/social_mpc/path.py index 97a6f48102b45987d30660e18f216172727bceeb..29300cae823e01655f5dd324c1fe169a2152a0f6 100644 --- a/social_mpc/path.py +++ b/social_mpc/path.py @@ -69,6 +69,9 @@ class PathPlanner(): dx=dx, coords=(x, y), max_distance=self.max_d) + + if len(xl) == 0 or len(yl) == 0 or len(vxl) == 0 or len(vyl) == 0: + return [] d_angle = np.arctan2(vxl[0], -vyl[0]) - pos[2] if dl[0] < self.max_d_orientation: # if within range, set waypoint = target wpt_pos = [self.target[0], self.target[1], self.target[2]] @@ -142,9 +145,10 @@ class PathPlanner(): continue wpt = self.get_next_waypoint(robot_pose) - - with lock: - shared_waypoint[0] = True - shared_waypoint[1] = float(wpt[0]) - shared_waypoint[2] = float(wpt[1]) - shared_waypoint[3] = float(wpt[2]) + + if wpt: + with lock: + shared_waypoint[0] = True + shared_waypoint[1] = float(wpt[0]) + shared_waypoint[2] = float(wpt[1]) + shared_waypoint[3] = float(wpt[2]) \ No newline at end of file