Skip to content

Commit

Permalink
Minor performance improve for lane planner update_dp_set_offsets()
Browse files Browse the repository at this point in the history
  • Loading branch information
Hikari1023 committed Apr 18, 2022
1 parent 90b7238 commit 6de6af4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions selfdrive/controls/lib/lane_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,23 @@ def __init__(self, wide_camera=False):
self.camera_offset = -CAMERA_OFFSET if wide_camera else CAMERA_OFFSET
self.path_offset = -PATH_OFFSET if wide_camera else PATH_OFFSET

self.dp_camera_offset = None
self.dp_path_offset = None
self.dp_wide_camera = wide_camera

def update_dp_set_offsets(self, camera_offset, path_offset):
camera_offset = -camera_offset
path_offset = -path_offset
# from 0.04 to -0.04, difference is -0.08
# so we can assume the distance between C3's 2 cameras is 8 cm
self.camera_offset = (camera_offset - 8) * 0.01 if self.dp_wide_camera else camera_offset * 0.01
self.path_offset = (path_offset - 8) * 0.01 if self.dp_wide_camera else path_offset * 0.01
if self.dp_camera_offset != camera_offset:
self.dp_camera_offset = camera_offset
camera_offset = -camera_offset
# from 0.04 to -0.04, difference is -0.08
# so we can assume the distance between C3's 2 cameras is 8 cm
self.camera_offset = (camera_offset - 8) * 0.01 if self.dp_wide_camera else camera_offset * 0.01
if self.dp_path_offset != path_offset:
self.dp_path_offset = path_offset
path_offset = -path_offset
# from 0.04 to -0.04, difference is -0.08
# so we can assume the distance between C3's 2 cameras is 8 cm
self.path_offset = (path_offset - 8) * 0.01 if self.dp_wide_camera else path_offset * 0.01

def parse_model(self, md):
lane_lines = md.laneLines
Expand Down

0 comments on commit 6de6af4

Please sign in to comment.