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

Add Support for Distance Button Control on Toyota TSS1 with SDSU #485

Merged
merged 3 commits into from
Nov 2, 2021
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ Here are the main parameters you can change with this fork:
- `upload_on_hotspot`: Controls whether your EON will upload driving data on your phone's hotspot
- [`update_behavior`](#Automatic-updates): `off` will never update, `alert` shows an alert on-screen. `auto` will reboot the device when an update is seen
- `disengage_on_gas`: Whether you want openpilot to disengage on gas input or not
- `hide_model_long`: Enable this to hide the Model Long button on the screen
- **Dynamic params**:
- `dynamic_gas`: Whether to use [dynamic gas](#dynamic-gas) if your car is supported
- `global_df_mod` **`(live!)`**: The multiplier for the current distance used by dynamic follow. The range is limited from 0.85 to 2.5. Smaller values will get you closer, larger will get you farther. This is applied to ALL profiles!
- `min_TR` **`(live!)`**: The minimum allowed following distance in seconds. Default is 0.9 seconds, the range of this mod is limited from 0.85 to 1.3 seconds. This is applied to ALL profiles!
- `hide_auto_df_alerts`: Hides the alert that shows what profile the model has chosen
- `df_button_alerts`: How you want to be alerted when you change your dynamic following profile, can be: 'off', 'silent', or 'audible' (default)
- `toyota_distance_btn`: Set to True to use the steering wheel distance button on Toyota vehicles to control the dynamic follow profile.
Works on TSS2 vehicles and on TSS1 vehicles with an sDSU with a [Sep. 2020](https://github.com/wocsor/panda/commit/b5120f6427551345c543b490fe47da189c1e48e1) firmware or newer.'
- [`dynamic_camera_offset`](#Dynamic-camera-offset-based-on-oncoming-traffic): Whether to automatically keep away from oncoming traffic. Works from 35 to ~60 mph
- [`dynamic_camera_offset_time`](#Dynamic-camera-offset-based-on-oncoming-traffic): How long to keep the offset after losing the oncoming lane/radar track in seconds
- `dynamic_follow`: *Deprecated, use the on-screen button to change profiles*
Expand All @@ -156,7 +160,7 @@ Here are the main parameters you can change with this fork:
- `corollaTSS2_use_indi`: Enable this to use INDI for lat with your TSS2 Corolla *(can be enabled for all years by request)*
- `standstill_hack`: Some cars support stop and go, you just need to enable this

A full list of parameters that you can modify are [located here](common/op_params.py#L40).
A full list of parameters that you can modify are [located here](common/op_params.py#L101).

An archive of opParams [lives here.](https://github.com/sshane/op_params)

Expand Down
2 changes: 1 addition & 1 deletion cereal
Submodule cereal updated 1 files
+1 −0 car.capnp
4 changes: 2 additions & 2 deletions common/op_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def __init__(self):
'corollaTSS2_use_indi': Param(False, bool, 'Enable this to use INDI for lat with your TSS2 Corolla', static=True),
'rav4TSS2_use_indi': Param(False, bool, 'Enable this to use INDI for lat with your TSS2 RAV4', static=True),
'standstill_hack': Param(False, bool, 'Some cars support stop and go, you just need to enable this', static=True),
'toyota_distance_btn': Param(False, bool, 'Set to True to use the steering wheel distance button to control the dynamic follow profile\n'
'Only works on Toyota TSS2', static=True)}
'toyota_distance_btn': Param(False, bool, 'Set to True to use the steering wheel distance button to control the dynamic follow profile.\n'
'Works on TSS2 vehicles and on TSS1 vehicles with an sDSU with a Sep. 2020 firmware or newer.', static=True)}

self._to_delete = ['enable_long_derivative'] # a list of unused params you want to delete from users' params file
self._to_reset = [] # a list of params you want reset to their default values
Expand Down
27 changes: 17 additions & 10 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ def update(self, cp, cp_cam):

if self.CP.carFingerprint in TSS2_CAR:
self.acc_type = cp_cam.vl["ACC_CONTROL"]["ACC_TYPE"]
if self.enable_distance_btn:

if self.enable_distance_btn:
if self.CP.carFingerprint in TSS2_CAR:
self.distance_btn = 1 if cp_cam.vl["ACC_CONTROL"]["DISTANCE"] == 1 else 0
distance_lines = cp.vl["PCM_CRUISE_SM"]["DISTANCE_LINES"] - 1
if distance_lines in range(3) and distance_lines != self.distance_lines:
dat = messaging.new_message('dynamicFollowButton')
dat.dynamicFollowButton.status = distance_lines
self.pm.send('dynamicFollowButton', dat)
self.distance_lines = distance_lines
elif self.CP.smartDsu:
self.distance_btn = 1 if cp.vl["SDSU"]["FD_BUTTON"] == 1 else 0

distance_lines = cp.vl["PCM_CRUISE_SM"]["DISTANCE_LINES"] - 1
if distance_lines in range(3) and distance_lines != self.distance_lines:
dat = messaging.new_message('dynamicFollowButton')
dat.dynamicFollowButton.status = distance_lines
self.pm.send('dynamicFollowButton', dat)
self.distance_lines = distance_lines

# some TSS2 cars have low speed lockout permanently set, so ignore on those cars
# these cars are identified by an ACC_TYPE value of 2.
Expand Down Expand Up @@ -172,6 +177,7 @@ def get_can_parser(CP):
("TURN_SIGNALS", "STEERING_LEVERS", 3), # 3 is no blinkers
("LKA_STATE", "EPS_STATUS", 0),
("AUTO_HIGH_BEAM", "LIGHT_STALK", 0),
("DISTANCE_LINES", "PCM_CRUISE_SM", 0),
]

checks = [
Expand All @@ -187,6 +193,7 @@ def get_can_parser(CP):
("STEER_ANGLE_SENSOR", 80),
("PCM_CRUISE", 33),
("STEER_TORQUE_SENSOR", 50),
("PCM_CRUISE_SM", 1),
]

if CP.carFingerprint == CAR.LEXUS_IS:
Expand Down Expand Up @@ -220,9 +227,9 @@ def get_can_parser(CP):
("BSM", 1)
]

if CP.carFingerprint in TSS2_CAR:
signals.append(("DISTANCE_LINES", "PCM_CRUISE_SM", 0))
checks.append(("PCM_CRUISE_SM", 1))
if CP.smartDsu:
signals.append(("FD_BUTTON", "SDSU", 0))
checks.append(("SDSU", 33))

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)

Expand Down
1 change: 1 addition & 0 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
ret.enableBsm = 0x3F6 in fingerprint[0] and candidate in TSS2_CAR
# Detect smartDSU, which intercepts ACC_CMD from the DSU allowing openpilot to send it
smartDsu = 0x2FF in fingerprint[0]
ret.smartDsu = smartDsu
# In TSS2 cars the camera does long control
found_ecus = [fw.ecu for fw in car_fw]
ret.enableDsu = (len(found_ecus) > 0) and (Ecu.dsu not in found_ecus) and (candidate not in NO_DSU_CAR)
Expand Down