Skip to content

Commit

Permalink
Merge pull request commaai#132 from Hikari1023/testing
Browse files Browse the repository at this point in the history
rewrite and fix update_dp_set_offsets()
  • Loading branch information
rav4kumar committed Apr 12, 2022
2 parents 07972aa + 0cf3e12 commit 90b7238
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
6 changes: 3 additions & 3 deletions common/dp_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import time
from math import floor
from selfdrive.hardware import TICI
from selfdrive.hardware import EON, TICI

'''
* type: Bool, Int8, UInt8, UInt16, Float32
Expand Down Expand Up @@ -86,8 +86,8 @@
{'name': 'dp_ip_addr', 'default': '', 'type': 'Text', 'conf_type': ['struct']},
{'name': 'dp_fan_mode', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 2, 'conf_type': ['param']},
{'name': 'dp_last_modified', 'default': str(floor(time.time())), 'type': 'Text', 'conf_type': ['param']},
{'name': 'dp_camera_offset', 'default': -4 if TICI else 6, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']},
{'name': 'dp_path_offset', 'default': -4 if TICI else 0, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']},
{'name': 'dp_camera_offset', 'default': 6 if EON else -4 if TICI else 0, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']},
{'name': 'dp_path_offset', 'default': 0 if EON else -4 if TICI else 0, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']},

{'name': 'dp_locale', 'default': 'en-US', 'type': 'Text', 'conf_type': ['param', 'struct'], 'update_once': True},
{'name': 'dp_reg', 'default': False, 'type': 'Bool', 'conf_type': ['param']},
Expand Down
23 changes: 6 additions & 17 deletions selfdrive/controls/lib/lane_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,15 @@ 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):
if self.dp_camera_offset != camera_offset:
self.dp_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
if self.dp_wide_camera:
self.camera_offset += 8
self.camera_offset = camera_offset / 100

if self.dp_path_offset != path_offset:
self.dp_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
if self.dp_wide_camera:
self.dp_path_offset += 8
self.path_offset = path_offset / 100
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

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

0 comments on commit 90b7238

Please sign in to comment.