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

Subaru global imperial/metric ACC speed fix #638

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion opendbc/subaru_global_2017.dbc
Expand Up @@ -321,10 +321,11 @@ BO_ 1658 NEW_MSG_39: 8 XXX
SG_ NEW_SIGNAL_3 : 33|1@1+ (1,0) [0|3] "" XXX
SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|3] "" XXX

BO_ 1677 NEW_MSG_40: 8 XXX
BO_ 1677 Dash_State: 8 XXX
SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX
SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX
SG_ NEW_SIGNAL_3 : 16|4@1+ (1,0) [0|15] "" XXX
SG_ Units : 27|5@1+ (1,0) [5|27] "" XXX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think unit should be 5 bits. Wouldn't be better:

SG_ Units : 29|3@1+ (1,0) [0|7] "" XXX
imperial = 1 (b001)
metric = 6 (b110)

?


BO_ 1743 NEW_MSG_41: 8 XXX
SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX
Expand Down
10 changes: 9 additions & 1 deletion selfdrive/car/subaru/carstate.py
Expand Up @@ -26,6 +26,7 @@ def get_powertrain_can_parser(CP):
("DOOR_OPEN_FL", "BodyInfo", 1),
("DOOR_OPEN_RR", "BodyInfo", 1),
("DOOR_OPEN_RL", "BodyInfo", 1),
("Units", "Dash_State", 5),
]

checks = [
Expand Down Expand Up @@ -89,6 +90,7 @@ def __init__(self, CP):
self.steer_torque_driver = 0
self.steer_not_allowed = False
self.main_on = False
self.is_metric = False

# vEgo kalman filter
dt = 0.01
Expand All @@ -114,7 +116,13 @@ def update(self, cp, cp_cam):
self.v_wheel_rl = cp.vl["Wheel_Speeds"]['RL'] * CV.KPH_TO_MS
self.v_wheel_rr = cp.vl["Wheel_Speeds"]['RR'] * CV.KPH_TO_MS

self.v_cruise_pcm = cp_cam.vl["ES_DashStatus"]["Cruise_Set_Speed"] * CV.MPH_TO_KPH
# 5 = imperial, 27 = metric
self.is_metric = cp.vl["Dash_State"]['Units'] == 27

if self.is_metric:
self.v_cruise_pcm = cp_cam.vl["ES_DashStatus"]['Cruise_Set_Speed']
else:
self.v_cruise_pcm = cp_cam.vl["ES_DashStatus"]['Cruise_Set_Speed'] * CV.MPH_TO_KPH

v_wheel = (self.v_wheel_fl + self.v_wheel_fr + self.v_wheel_rl + self.v_wheel_rr) / 4.
# Kalman filter, even though Hyundai raw wheel speed is heaviliy filtered by default
Expand Down