Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 0.6.0.3 #41

Merged
merged 27 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Version 0.6.0.4-ku7 (2019-07-**)
========================
* HKG - Log to cloudlog rather than print to stdout
* HKG - WIP: mapd is going to need a lot of reworking
* HKG - Forward LKAS_Icon (not really an icon)
* HKG - Disengage Properly
* HKG - Fixed Brute Force Checksum Learner
* HKG - Detect Genesis and default min speed
* HLG - Fix Min Speed Code


Version 0.6.0.3-ku7 (2019-07-09)
========================
* HKG - Send fingerprints to Sentry
Expand Down
39 changes: 17 additions & 22 deletions selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import selfdrive.messaging as messaging
from selfdrive.config import Conversions as CV
from common.params import Params
from selfdrive.swaglog import cloudlog



# Steer torque limits
Expand All @@ -34,9 +36,8 @@ def __init__(self, dbc_name, car_fingerprint):
self.last_resume_cnt = 0

self.map_speed = 0
#context = zmq.Context()
#self.map_data_sock = messaging.sub_sock(context, service_list['liveMapData'].port, conflate=True)
#self.params = Params()
self.map_data_sock = messaging.sub_sock(service_list['liveMapData'].port)
self.params = Params()
self.speed_conv = 3.6
self.speed_offset = 1.03 # Multiplier for cruise speed vs speed limit TODO: Add to UI
self.speed_enable = True # Enable Auto Speed Set TODO: Add to UI
Expand All @@ -46,7 +47,6 @@ def __init__(self, dbc_name, car_fingerprint):
self.checksum_learn_cnt = 0

self.turning_signal_timer = 0
self.min_steer_speed = 0.
self.camera_disconnected = False

self.packer = CANPacker(dbc_name)
Expand All @@ -61,41 +61,35 @@ def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert):
# Learn Checksum from the Camera
if self.checksum == "NONE":
self.checksum = learn_checksum(self.packer, CS.lkas11)
print ("Discovered Checksum", self.checksum)
cloudlog.info("Discovered Checksum")
if self.checksum == "NONE" and self.checksum_learn_cnt < 50:
self.checksum_learn_cnt += 1
return

# If MDPS is faulted from bad checksum, then cycle through all Checksums until 1 works
if CS.steer_error == 1:
self.camera_disconnected = True
print ("Camera Not Detected: Brute Forcing Checksums")
cloudlog.warning("Camera Not Detected: Brute Forcing Checksums")
if self.checksum_learn_cnt > 250:
self.checksum_learn_cnt = 50
if self.checksum == "NONE":
print ("Testing 6B Checksum")
self.checksum == "6B"
cloudlog.info("Testing 6B Checksum")
self.checksum = "6B"
elif self.checksum == "6B":
print ("Testing 7B Checksum")
self.checksum == "7B"
cloudlog.info("Testing 7B Checksum")
self.checksum = "7B"
elif self.checksum == "7B":
print ("Testing CRC8 Checksum")
self.checksum == "crc8"
cloudlog.info("Testing CRC8 Checksum")
self.checksum = "crc8"
else:
self.checksum == "NONE"
self.checksum = "NONE"
else:
self.checksum_learn_cnt += 1

### Minimum Steer Speed ###

# Learn Minimum Steer Speed
if CS.mdps12_flt != 0 and CS.v_ego_raw > 0. and abs(CS.angle_steers) < 10.0 :
if CS.v_ego_raw > self.min_steer_speed:
self.min_steer_speed = CS.v_ego_raw + 0.1
print ("Discovered new Min Speed as", self.min_steer_speed)

# Apply Usage of Minimum Steer Speed
if CS.v_ego_raw < self.min_steer_speed:
if CS.v_ego_raw < CS.min_steer_speed:
disable_steer = True

### Turning Indicators ###
Expand All @@ -112,8 +106,9 @@ def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert):

if not enabled or disable_steer:
apply_steer = 0

steer_req = 1 if enabled else 0
steer_req = 0
else:
steer_req = 1

self.apply_steer_last = apply_steer

Expand Down
17 changes: 11 additions & 6 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def get_camera_parser(CP):

return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2, timeout=100)


class CarState(object):
def __init__(self, CP):

Expand All @@ -160,9 +159,6 @@ def __init__(self, CP):
self.right_blinker_flash = 0
self.has_scc = False
self.min_steer_speed = 0

def update_min_speed(speed):
self.min_steer_speed = speed

def update(self, cp, cp_cam):
if (cp.vl["SCC11"]['TauGapSet'] > 0):
Expand Down Expand Up @@ -224,8 +220,9 @@ def update(self, cp, cp_cam):
self.steer_torque_driver = cp.vl["MDPS12"]['CR_Mdps_StrColTq']
self.steer_torque_motor = cp.vl["MDPS12"]['CR_Mdps_OutTq']
self.stopped = cp.vl["SCC11"]['SCCInfoDisplay'] == 4. if self.has_scc else False
self.mdps11_strang = cp.vl["MDPS11"]["CR_Mdps_StrAng"]
self.mdps11_stat = cp.vl["MDPS11"]["CF_Mdps_Stat"]
self.mdps11_strang = cp.vl["MDPS11"]['CR_Mdps_StrAng']
self.mdps11_stat = cp.vl["MDPS11"]['CF_Mdps_Stat']
self.lkas11_icon = cp_cam.vl["LKAS11"]['CF_Lkas_Icon']
self.mdps12_flt = cp.vl["MDPS12"]['CF_Mdps_ToiFlt']

self.user_brake = 0
Expand All @@ -238,6 +235,14 @@ def update(self, cp, cp_cam):
self.pedal_gas = cp.vl["EMS12"]['TPS']
self.car_gas = cp.vl["EMS12"]['TPS']

# Learn Minimum Steer Speed
if self.mdps12_flt != 0 and self.v_ego_raw > 0. and abs(self.angle_steers) < 5.0 and self.lkas11_icon != 2:
if self.v_ego_raw > self.min_steer_speed:
self.min_steer_speed = self.v_ego_raw + 0.1
# If we have LKAS_Icon == 2, then we know its 16.7m/s
elif self.lkas11_icon == 2 and self.min_steer_speed < 16.7:
self.min_steer_speed = 16.7

# Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with
gear = cp.vl["LVR12"]["CF_Lvr_Gear"]
if gear == 5:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def make_can_msg(addr, dat, alt):

def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock, checksum):
values = {
"CF_Lkas_Icon": 2,
"CF_Lkas_Icon": lkas11["CF_Lkas_Icon"] if keep_stock else 3,
"CF_Lkas_LdwsSysState": 3 if steer_req else 1,
"CF_Lkas_SysWarning": hud_alert,
"CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0,
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ def update(self, c):
ret.seatbeltUnlatched = not self.CS.seatbelt

# low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s)
if ret.vEgo < (self.CS.min_steer_speed + 2.) and self.CS.min_steer_speed > 10.:
self.low_speed_alert = True
if ret.vEgo > (self.CS.min_steer_speed + 4.):
self.low_speed_alert = False
#if self.CS.v_ego_raw < (self.CS.min_steer_speed) and self.CS.min_steer_speed > 2.:
# self.low_speed_alert = True
#if self.CS.v_ego_raw > (self.CS.min_steer_speed + 0.2):
self.low_speed_alert = False

events = []
if (self.CS.gear_shifter != 'drive') and (self.CS.gear_tcu != 'drive') and (self.CS.gear_shifter_cluster != 'drive'):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/common/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMMA_VERSION "0.6.0.3-ku7"
#define COMMA_VERSION "0.6.0.4-dev"
4 changes: 2 additions & 2 deletions selfdrive/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def unblock_stdout():
"plannerd": "selfdrive.controls.plannerd",
"radard": "selfdrive.controls.radard",
"ubloxd": ("selfdrive/locationd", ["./ubloxd"]),
# "mapd": "selfdrive.mapd.mapd",
#"mapd": "selfdrive.mapd.mapd",
"loggerd": ("selfdrive/loggerd", ["./loggerd"]),
"logmessaged": "selfdrive.logmessaged",
"tombstoned": "selfdrive.tombstoned",
Expand Down Expand Up @@ -152,7 +152,7 @@ def get_running():
'proclogd',
'ubloxd',
'gpsd',
# 'mapd',
#'mapd',
'deleter',
]

Expand Down
7 changes: 3 additions & 4 deletions selfdrive/mapd/mapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ def save_gps_data(gps):
def mapsd_thread():
global last_gps

context = zmq.Context()
poller = zmq.Poller()
gps_sock = messaging.sub_sock(context, service_list['gpsLocation'].port, conflate=True)
gps_external_sock = messaging.sub_sock(context, service_list['gpsLocationExternal'].port, conflate=True, poller=poller)
map_data_sock = messaging.pub_sock(context, service_list['liveMapData'].port)
gps_sock = messaging.sub_sock(service_list['gpsLocation'].port)
gps_external_sock = messaging.sub_sock(service_list['gpsLocationExternal'].port)
map_data_sock = messaging.pub_sock(service_list['liveMapData'].port)

cur_way = None
curvature_valid = False
Expand Down