Skip to content

Commit

Permalink
October 15th, 2024 Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogAi committed Oct 13, 2024
1 parent c45170d commit 108b3e2
Show file tree
Hide file tree
Showing 64 changed files with 660 additions and 1,461 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ FrogPilot is a fully open-sourced fork of openpilot, featuring clear and concise
------
FrogPilot was last updated on:

**October 7th, 2024**
**October 15th, 2024**

Features
------
Expand Down
3 changes: 1 addition & 2 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -1958,8 +1958,7 @@ struct Joystick {
struct DriverStateV2 {
frameId @0 :UInt32;
modelExecutionTime @1 :Float32;
dspExecutionTimeDEPRECATED @2 :Float32;
gpuExecutionTime @8 :Float32;
dspExecutionTime @2 :Float32;
rawPredictions @3 :Data;

poorVisionProb @4 :Float32;
Expand Down
2 changes: 1 addition & 1 deletion common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"ConditionalExperimental", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS},
{"CrosstrekTorque", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VEHICLES},
{"CurrentHolidayTheme", CLEAR_ON_MANAGER_START},
{"CurrentModelName", CLEAR_ON_MANAGER_START},
{"CurveSensitivity", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS},
{"CurveSpeedControl", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS},
{"CustomAlerts", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS},
Expand Down Expand Up @@ -390,7 +391,6 @@ std::unordered_map<std::string, uint32_t> keys = {
{"MapsSelected", PERSISTENT | FROGPILOT_OTHER},
{"MapSpeedLimit", PERSISTENT},
{"MapStyle", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_VISUALS},
{"MapTargetLatA", PERSISTENT},
{"MapTargetVelocities", PERSISTENT},
{"MaxDesiredAcceleration", PERSISTENT | FROGPILOT_STORAGE | FROGPILOT_CONTROLS},
{"MinimumBackupSize", PERSISTENT},
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
def get_startup_event(car_recognized, controller_available, fw_seen, block_user, frogpilot_toggles):
if block_user:
return EventName.blockUser
elif frogpilot_toggles.personalize_openpilot:
event = EventName.customStartupAlert
else:
event = EventName.startupMaster
event = EventName.customStartupAlert

if not car_recognized:
if fw_seen:
Expand Down
49 changes: 23 additions & 26 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
# - prolonged high driver torque: 17 (permanent)
PERM_STEER_FAULTS = (3, 17)

ZSS_THRESHOLD = 4.0
ZSS_THRESHOLD_COUNT = 10

# Traffic signals for Speed Limit Controller - Credit goes to the DragonPilot team!
@staticmethod
def calculate_speed_limit(cp_cam, frogpilot_toggles):
Expand Down Expand Up @@ -70,11 +67,11 @@ def __init__(self, CP):
self.slope_angle = 0.0

# FrogPilot variables
self.zss_compute = False
self.zss_cruise_active_last = False
self.latActive_previous = False
self.needs_angle_offset_zss = True

self.zss_angle_offset = 0
self.zss_threshold_count = 0
self.angle_offset_zss = 0
self.zorro_steer_value = 0

def update(self, cp, cp_cam, CC, frogpilot_toggles):
ret = car.CarState.new_message()
Expand Down Expand Up @@ -243,28 +240,27 @@ def update(self, cp, cp_cam, CC, frogpilot_toggles):
self.lkas_previously_enabled = self.lkas_enabled
self.lkas_enabled = self.lkas_hud.get("LDA_ON_MESSAGE") == 1

# ZSS Support - Credit goes to the DragonPilot team!
if self.CP.flags & ToyotaFlags.ZSS and self.zss_threshold_count <= ZSS_THRESHOLD_COUNT:
zorro_steer = cp.vl["SECONDARY_STEER_ANGLE"]["ZORRO_STEER"]
# ZSS Support - Credit goes to Erich!
if self.CP.flags & ToyotaFlags.ZSS:
if abs(torque_sensor_angle_deg) > 1e-3:
self.accurate_steer_angle_seen = True

# Only compute ZSS offset when control is active
if CC.latActive and not self.zss_cruise_active_last:
self.zss_threshold_count = 0
self.zss_compute = True # Control was just activated, so allow offset to be recomputed
self.zss_cruise_active_last = CC.latActive
if CC.latActive and not self.latActive_previous:
self.needs_angle_offset_zss = True
self.latActive_previous = CC.latActive

# Compute ZSS offset
if self.zss_compute:
if self.needs_angle_offset_zss:
zorro_steer = cp.vl["SECONDARY_STEER_ANGLE"]["ZORRO_STEER"]
if abs(ret.steeringAngleDeg) > 1e-3 and abs(zorro_steer) > 1e-3:
self.zss_compute = False
self.zss_angle_offset = zorro_steer - ret.steeringAngleDeg
self.needs_angle_offset_zss = False
self.angle_offset_zss = zorro_steer - ret.steeringAngleDeg
self.zorro_steer_value = cp.vl["SECONDARY_STEER_ANGLE"]["ZORRO_STEER"] - self.angle_offset_zss

# Safety checks
steering_angle_deg = zorro_steer - self.zss_angle_offset
if abs(ret.steeringAngleDeg - steering_angle_deg) > ZSS_THRESHOLD:
self.zss_threshold_count += 1
else:
ret.steeringAngleDeg = steering_angle_deg
if not self.needs_angle_offset_zss:
if abs(ret.steeringAngleDeg - self.zorro_steer_value) > 4.0:
ret.steeringAngleDeg = ret.steeringAngleDeg
else:
ret.steeringAngleDeg = self.zorro_steer_value

return ret, fp_ret

Expand Down Expand Up @@ -325,7 +321,8 @@ def get_can_parser(CP):
("SDSU", 100),
]

messages += [("SECONDARY_STEER_ANGLE", 0)]
if CP.flags & ToyotaFlags.ZSS:
messages += [("SECONDARY_STEER_ANGLE", 0)]

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

Expand Down
10 changes: 5 additions & 5 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay
ret.steerLimitTimer = 0.4

if 0x23 in fingerprint[0]: # Detect if ZSS is present
ret.flags |= ToyotaFlags.ZSS.value

ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop

# Detect smartDSU, which intercepts ACC_CMD from the DSU (or radar) allowing openpilot to send it
Expand Down Expand Up @@ -73,6 +70,9 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp
ret.steerActuatorDelay = 0.25
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning, steering_angle_deadzone_deg=0.2)

if 0x23 in fingerprint[0]: # Detect if ZSS is present
ret.flags |= ToyotaFlags.ZSS.value

elif candidate in (CAR.LEXUS_RX, CAR.LEXUS_RX_TSS2):
ret.wheelSpeedFactor = 1.035

Expand Down Expand Up @@ -156,8 +156,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, disable_openpilot_long, exp
tune.kiV = [3.6, 2.4, 1.5]

if params.get_bool("FrogsGoMoosTweak"):
if candidate in TSS2_CAR or ret.flags & ToyotaFlags.NEW_TOYOTA_TUNE:
tune.kiV = [0.5]
if ret.flags & ToyotaFlags.NEW_TOYOTA_TUNE or ret.flags & ToyotaFlags.RAISED_ACCEL_LIMIT:
tune.kiV = [0.3]

ret.stoppingDecelRate = 0.1 # reach stopping target smoothly
ret.vEgoStopping = 0.15
Expand Down
5 changes: 3 additions & 2 deletions selfdrive/classic_modeld/classic_modeld.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def __init__(self, context: CLContext, frogpilot_toggles: SimpleNamespace):
self.enable_navigation = not frogpilot_toggles.navigationless_model
self.radarless = frogpilot_toggles.radarless_model

if frogpilot_toggles.model != DEFAULT_MODEL:
MODEL_PATHS[ModelRunner.THNEED] = Path(__file__).parent / f'{MODELS_PATH}/{frogpilot_toggles.model}.thneed'
model_path = Path(__file__).parent / f'{MODELS_PATH}/{frogpilot_toggles.model}.thneed'
if frogpilot_toggles.model != DEFAULT_MODEL and model_path.exists():
MODEL_PATHS[ModelRunner.THNEED] = model_path

self.frame = ModelFrame(context)
self.wide_frame = ModelFrame(context)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ def update_frogpilot_variables(self, CS):
self.always_on_lateral_active &= not (CS.brakePressed and CS.vEgo < self.frogpilot_toggles.always_on_lateral_pause_speed) or CS.standstill
self.always_on_lateral_active = bool(self.always_on_lateral_active)

if self.frogpilot_toggles.conditional_experimental_mode:
if self.frogpilot_toggles.conditional_experimental_mode or self.frogpilot_toggles.slc_fallback_experimental:
self.experimental_mode = self.sm['frogpilotPlan'].experimentalMode

if any(be.pressed and be.type == FrogPilotButtonType.lkas for be in CS.buttonEvents):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/lib/latcontrol_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def update(self, active, CS, VM, params, steer_limited, desired_curvature, llk,
steer_feedforward = self.get_steer_feedforward(angle_steers_des_no_offset, CS.vEgo)

output_steer = self.pid.update(error, override=CS.steeringPressed,
feedforward=steer_feedforward, speed=CS.vEgo, frogpilot_toggles=frogpilot_toggles)
feedforward=steer_feedforward, speed=CS.vEgo)
pid_log.active = True
pid_log.p = self.pid.p
pid_log.i = self.pid.i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"alpha": 255
},
"Path": {
"red": 242,
"green": 117,
"blue": 3,
"red": 134,
"green": 47,
"blue": 224,
"alpha": 255
},
"PathEdge": {
"red": 194,
"green": 94,
"blue": 2,
"red": 161,
"green": 56,
"blue": 255,
"alpha": 255
},
"RoadEdges": {
Expand All @@ -30,9 +30,9 @@
"alpha": 255
},
"Sidebar1": {
"red": 242,
"green": 117,
"blue": 3,
"red": 134,
"green": 47,
"blue": 224,
"alpha": 255
},
"Sidebar2": {
Expand All @@ -42,9 +42,9 @@
"alpha": 255
},
"Sidebar3": {
"red": 242,
"green": 117,
"blue": 3,
"red": 80,
"green": 184,
"blue": 72,
"alpha": 255
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
28 changes: 12 additions & 16 deletions selfdrive/frogpilot/assets/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,22 @@ def validate_models(self):

def copy_default_model(self):
default_model_path = os.path.join(MODELS_PATH, f"{DEFAULT_MODEL}.thneed")
source_path = os.path.join(BASEDIR, "selfdrive", "classic_modeld", "models", "supercombo.thneed")

if not os.path.isfile(default_model_path):
source_path = os.path.join(BASEDIR, "selfdrive", "classic_modeld", "models", "supercombo.thneed")

if os.path.isfile(source_path):
shutil.copyfile(source_path, default_model_path)
print(f"Copied default model from {source_path} to {default_model_path}")
else:
print(f"Source default model not found at {source_path}. Exiting...")
if os.path.isfile(source_path):
shutil.copyfile(source_path, default_model_path)
print(f"Copied default model from {source_path} to {default_model_path}")
else:
print(f"Source default model not found at {source_path}. Exiting...")

sgo_model_path = os.path.join(MODELS_PATH, "secret-good-openpilot.thneed")
source_path = os.path.join(BASEDIR, "selfdrive", "modeld", "models", "supercombo.thneed")

if not os.path.isfile(sgo_model_path):
source_path = os.path.join(BASEDIR, "selfdrive", "modeld", "models", "supercombo.thneed")

if os.path.isfile(source_path):
shutil.copyfile(source_path, sgo_model_path)
print(f"Copied 'secret-good-openpilot' model from {source_path} to {sgo_model_path}")
else:
print(f"Source 'secret-good-openpilot' model not found at {source_path}. Exiting...")
if os.path.isfile(source_path):
shutil.copyfile(source_path, sgo_model_path)
print(f"Copied 'secret-good-openpilot' model from {source_path} to {sgo_model_path}")
else:
print(f"Source 'secret-good-openpilot' model not found at {source_path}. Exiting...")

def update_models(self, boot_run=False):
if boot_run:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 4 additions & 7 deletions selfdrive/frogpilot/assets/theme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
import requests
import shutil
import time
import zipfile

from openpilot.common.basedir import BASEDIR
Expand Down Expand Up @@ -72,10 +71,10 @@ def update_distance_icons(pack, holiday_theme):
def update_wheel_image(image, holiday_theme=None, random_event=True):
if image == "stock":
wheel_location = os.path.join(BASEDIR, "selfdrive", "frogpilot", "assets", "stock_theme", "steering_wheel")
elif holiday_theme:
wheel_location = os.path.join(BASEDIR, "selfdrive", "frogpilot", "assets", "holiday_themes", holiday_theme, "steering_wheel")
elif random_event:
wheel_location = os.path.join(BASEDIR, "selfdrive", "frogpilot", "assets", "random_events", "icons")
elif holiday_theme:
wheel_location = os.path.join(BASEDIR, "selfdrive", "frogpilot", "assets", "holiday_themes", holiday_theme, "icons")
else:
wheel_location = os.path.join(THEME_SAVE_PATH, "steering_wheels")

Expand All @@ -89,7 +88,7 @@ def update_wheel_image(image, holiday_theme=None, random_event=True):

image_name = image.replace(" ", "_").lower()
for filename in os.listdir(wheel_location):
if os.path.splitext(filename)[0].lower() == image_name:
if os.path.splitext(filename)[0].lower() in (image_name, "wheel"):
source_file = os.path.join(wheel_location, filename)
destination_file = os.path.join(wheel_save_location, f"wheel{os.path.splitext(filename)[1]}")
shutil.copy2(source_file, destination_file)
Expand Down Expand Up @@ -158,7 +157,7 @@ def update_holiday(self, now):
if (holiday.endswith("_week") and self.is_within_week_of(date, now)) or (now.date() == date.date()):
if holiday != self.previous_assets.get("holiday_theme"):
self.params.put("CurrentHolidayTheme", holiday)
self.update_active_theme()
self.params_memory.put_bool("UpdateTheme", True)
return

if "holiday_theme" in self.previous_assets:
Expand Down Expand Up @@ -198,8 +197,6 @@ def update_active_theme(self):
self.previous_assets[toggle] = current_value

self.previous_assets["holiday_theme"] = current_holiday_theme

self.params_memory.remove("UpdateTheme")
update_frogpilot_toggles()

def extract_zip(self, zip_file, extract_path):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/frogpilot/controls/frogpilot_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState
self.road_curvature = calculate_road_curvature(modelData, v_ego) if not carState.standstill else 1

if frogpilot_toggles.random_events and v_ego > CRUISING_SPEED and driving_gear:
self.taking_curve_quickly = v_ego > (1 / self.road_curvature)**0.5 * 2 > CRUISING_SPEED * 2 and abs(carState.steeringAngleDeg) > 30
self.taking_curve_quickly = v_ego > (1 / self.road_curvature)**0.75 * 2 > CRUISING_SPEED * 2 and abs(carState.steeringAngleDeg) > 30
else:
self.taking_curve_quickly = False

Expand Down
10 changes: 8 additions & 2 deletions selfdrive/frogpilot/controls/lib/frogpilot_acceleration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from openpilot.selfdrive.car.interfaces import ACCEL_MIN, ACCEL_MAX
from openpilot.selfdrive.controls.lib.longitudinal_planner import A_CRUISE_MIN, get_max_accel

from openpilot.selfdrive.frogpilot.frogpilot_variables import CRUISING_SPEED
from openpilot.selfdrive.frogpilot.frogpilot_variables import CITY_SPEED_LIMIT, CRUISING_SPEED

A_CRUISE_MIN_ECO = A_CRUISE_MIN / 4
A_CRUISE_MIN_SPORT = A_CRUISE_MIN / 2
Expand All @@ -26,6 +26,9 @@ def get_max_accel_sport_plus(v_ego):
def get_max_accel_ramp_off(max_accel, v_cruise, v_ego):
return interp(v_ego, [0., v_cruise * 0.5, v_cruise * 0.75, v_cruise], [max_accel, max_accel, max_accel / 2, max_accel / 4])

def get_max_accel_ramp_off_highway(max_accel, v_cruise, v_ego):
return interp(v_ego, [0., v_cruise * 0.75, v_cruise], [max_accel, max_accel, max_accel / 2])

def get_max_allowed_accel(v_ego):
return interp(v_ego, [0., 5., 20.], [4.0, 4.0, 2.0]) # ISO 15622:2018

Expand Down Expand Up @@ -74,7 +77,10 @@ def update(self, controlsState, frogpilotCarState, v_cruise, v_ego, frogpilot_to
if frogpilot_toggles.human_acceleration:
if self.frogpilot_planner.frogpilot_following.following_lead and not frogpilotCarState.trafficModeActive:
self.max_accel = clip(self.frogpilot_planner.lead_one.aLeadK, get_max_accel_sport_plus(v_ego), get_max_allowed_accel(v_ego))
self.max_accel = get_max_accel_ramp_off(self.max_accel, self.frogpilot_planner.v_cruise, v_ego)
if self.frogpilot_planner.v_cruise < CITY_SPEED_LIMIT:
self.max_accel = get_max_accel_ramp_off(self.max_accel, self.frogpilot_planner.v_cruise, v_ego)
else:
self.max_accel = get_max_accel_ramp_off_highway(self.max_accel, self.frogpilot_planner.v_cruise, v_ego)

self.max_accel = min(self.max_accel, frogpilot_toggles.max_desired_accel)

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/frogpilot/controls/lib/frogpilot_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState
if self.random_event_played:
self.random_event_timer += DT_MDL
if self.random_event_timer >= 4:
update_wheel_image(frogpilot_toggles.wheel_image, None, False)
update_wheel_image(frogpilot_toggles.wheel_image, frogpilot_toggles.current_holiday_theme, False)
self.params_memory.put_bool("UpdateWheelImage", True)
self.random_event_played = False
self.random_event_timer = 0
Expand Down Expand Up @@ -126,7 +126,7 @@ def update(self, carState, controlsState, frogpilotCarControl, frogpilotCarState
if not self.goat_played:
event_choices.append("goatSteerSaturated")

if event_choices and self.frame % (100 // len(event_choices)) == 0:
if self.frame % 100 == 0 and event_choices:
event_choice = random.choice(event_choices)
if event_choice == "firefoxSteerSaturated":
self.events.add(EventName.firefoxSteerSaturated)
Expand Down
Loading

0 comments on commit 108b3e2

Please sign in to comment.