From adf844eb305388a9fc20c3d12e61b2e8d1508001 Mon Sep 17 00:00:00 2001 From: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Sun, 19 Feb 2023 22:04:35 -0500 Subject: [PATCH] move-fast: v-tsc fix (#40) --- selfdrive/controls/lib/lateral_planner.py | 4 ++++ selfdrive/controls/lib/vision_turn_controller.py | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py index fd02468b79..030de797ff 100644 --- a/selfdrive/controls/lib/lateral_planner.py +++ b/selfdrive/controls/lib/lateral_planner.py @@ -41,6 +41,7 @@ class LateralPlanner: self.plan_yaw_rate = np.zeros((TRAJECTORY_SIZE,)) self.t_idxs = np.arange(TRAJECTORY_SIZE) self.y_pts = np.zeros(TRAJECTORY_SIZE) + self.d_path_w_lines_xyz = np.zeros((TRAJECTORY_SIZE, 3)) self.lat_mpc = LateralMpc() self.reset_mpc(np.zeros(4)) @@ -181,6 +182,9 @@ class LateralPlanner: lateralPlan.dynamicLaneProfile = int(self.dynamic_lane_profile) lateralPlan.dynamicLaneProfileStatus = bool(self.dynamic_lane_profile_status) + lateralPlan.dPathWLinesX = [float(x) for x in self.d_path_w_lines_xyz[:, 0]] + lateralPlan.dPathWLinesY = [float(y) for y in self.d_path_w_lines_xyz[:, 1]] + if self.standstill: self.standstill_elapsed += DT_MDL else: diff --git a/selfdrive/controls/lib/vision_turn_controller.py b/selfdrive/controls/lib/vision_turn_controller.py index e267f98d5b..76dc7cb52c 100644 --- a/selfdrive/controls/lib/vision_turn_controller.py +++ b/selfdrive/controls/lib/vision_turn_controller.py @@ -6,7 +6,7 @@ from common.params import Params from common.realtime import sec_since_boot from common.conversions import Conversions as CV from selfdrive.controls.lib.lateral_planner import TRAJECTORY_SIZE -from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N +from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX _MIN_V = 5.6 # Do not operate under 20km/h @@ -186,10 +186,11 @@ class VisionTurnController(): c_y = width_pts / 2 + lll_y path_poly = np.polyfit(ll_x, c_y, 3) - # 2. If not polynomial derived from lanes, then derive it from driving path as provided by `lateralPlanner`. - if path_poly is None and lat_planner_data is not None and len(lat_planner_data.psis) == CONTROL_N \ - and lat_planner_data.dPathPoints[0] > 0: - path_poly = np.polyfit(lat_planner_data.psis, lat_planner_data.dPathPoints, 3) + # 2. If not polynomial derived from lanes, then derive it from compensated driving path with lanes as + # provided by `lateralPlanner`. + if path_poly is None and lat_planner_data is not None and len(lat_planner_data.dPathWLinesX) > 0 \ + and lat_planner_data.dPathWLinesX[0] > 0: + path_poly = np.polyfit(lat_planner_data.dPathWLinesX, lat_planner_data.dPathWLinesY, 3) # 3. If no polynomial derived from lanes or driving path, then provide a straight line poly. if path_poly is None: