mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 08:16:06 +08:00
long manuevers / model manager
This commit is contained in:
@@ -3,6 +3,8 @@ from __future__ import annotations
|
||||
from dataclasses import asdict, dataclass
|
||||
from typing import Any
|
||||
|
||||
from opendbc.car.gm.values import GMFlags
|
||||
|
||||
|
||||
LOW_SPEED_MANEUVER_DESCRIPTIONS = (
|
||||
"come to stop",
|
||||
@@ -31,12 +33,27 @@ def get_longitudinal_maneuver_support(CP: Any) -> LongitudinalManeuverSupport:
|
||||
openpilot_longitudinal = bool(getattr(CP, "openpilotLongitudinalControl", False))
|
||||
auto_resume_supported = bool(getattr(CP, "autoResumeSng", False))
|
||||
|
||||
brand = str(getattr(CP, "brand", "") or getattr(CP, "carName", "") or "").lower()
|
||||
fingerprint = str(getattr(CP, "carFingerprint", "") or "")
|
||||
flags = int(getattr(CP, "flags", 0) or 0)
|
||||
has_pedal = bool(getattr(CP, "enableGasInterceptorDEPRECATED", False))
|
||||
|
||||
min_enable_speed = float(getattr(CP, "minEnableSpeed", 0.0) or 0.0)
|
||||
stop_accel = float(getattr(CP, "stopAccel", 0.0) or 0.0)
|
||||
|
||||
# CarParams does not expose a dedicated "won't fully brake to zero" flag,
|
||||
# so low-speed engagement support is the closest reliable proxy.
|
||||
is_gm = brand == "gm"
|
||||
is_volt = fingerprint.startswith("CHEVROLET_VOLT")
|
||||
has_sascm = is_gm and bool(flags & GMFlags.SASCM.value)
|
||||
|
||||
# CarParams does not expose a dedicated "won't fully brake to zero" flag.
|
||||
# For most platforms, low-speed engagement support is the best proxy.
|
||||
full_stop_and_go = min_enable_speed <= 0.0
|
||||
|
||||
# GM Volt without pedal can often engage below 0 mph but still creep instead of
|
||||
# reliably achieving a true stop in these canned maneuvers, especially on SASCM paths.
|
||||
if is_volt and not has_pedal:
|
||||
full_stop_and_go = False
|
||||
|
||||
auto_resume_from_stop = full_stop_and_go and auto_resume_supported
|
||||
expected_to_reach_zero = full_stop_and_go
|
||||
requires_resume_assist = expected_to_reach_zero and not auto_resume_from_stop
|
||||
@@ -45,10 +62,14 @@ def get_longitudinal_maneuver_support(CP: Any) -> LongitudinalManeuverSupport:
|
||||
if not openpilot_longitudinal:
|
||||
caveats.append("openpilot longitudinal is disabled, so the maneuver suite cannot drive longitudinal tests on this platform.")
|
||||
|
||||
if not expected_to_reach_zero:
|
||||
if is_volt and not has_pedal:
|
||||
caveats.append("Volt without pedal is not expected to reach a true standstill in the maneuver suite. Stop, start, and creep maneuvers will be skipped.")
|
||||
elif not expected_to_reach_zero:
|
||||
caveats.append("This car is not expected to reach a true standstill in the suite. Stop, start, and creep maneuvers will be skipped.")
|
||||
elif requires_resume_assist:
|
||||
caveats.append("This car can reach a stop, but restart-from-stop needs resume assistance. Zero-speed maneuvers will allow cruise standstill instead of treating it as setup failure.")
|
||||
elif has_sascm and full_stop_and_go:
|
||||
caveats.append("SASCM is present on this GM platform. If a real standstill is reached, restart behavior can still depend on resume handling.")
|
||||
|
||||
skipped_maneuvers = LOW_SPEED_MANEUVER_DESCRIPTIONS if not expected_to_reach_zero else ()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from dataclasses import dataclass
|
||||
|
||||
from cereal import messaging, car
|
||||
from openpilot.common.constants import CV
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.common.realtime import DT_MDL, Priority, config_realtime_process
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.tools.longitudinal_maneuvers.capabilities import (
|
||||
@@ -134,6 +134,8 @@ def build_maneuvers():
|
||||
|
||||
|
||||
def main():
|
||||
config_realtime_process(5, Priority.CTRL_LOW)
|
||||
|
||||
params = Params()
|
||||
cloudlog.info("joystickd is waiting for CarParams")
|
||||
CP = messaging.log_from_bytes(params.get("CarParams", block=True), car.CarParams)
|
||||
@@ -147,7 +149,7 @@ def main():
|
||||
continue
|
||||
supported_maneuvers.append(maneuver)
|
||||
|
||||
sm = messaging.SubMaster(['carState', 'carControl', 'controlsState', 'selfdriveState', 'modelV2'], poll='modelV2')
|
||||
sm = messaging.SubMaster(['carState', 'carControl', 'modelV2'], poll='modelV2')
|
||||
pm = messaging.PubMaster(['longitudinalPlan', 'driverAssistance', 'alertDebug'])
|
||||
|
||||
maneuvers = iter(supported_maneuvers)
|
||||
@@ -163,7 +165,7 @@ def main():
|
||||
alert_msg.valid = True
|
||||
|
||||
plan_send = messaging.new_message('longitudinalPlan')
|
||||
plan_send.valid = sm.all_checks()
|
||||
plan_send.valid = sm.all_checks(['carState', 'carControl', 'modelV2'])
|
||||
|
||||
longitudinalPlan = plan_send.longitudinalPlan
|
||||
accel = 0
|
||||
@@ -184,6 +186,8 @@ def main():
|
||||
|
||||
longitudinalPlan.aTarget = accel
|
||||
longitudinalPlan.shouldStop = v_ego < CP.vEgoStopping and accel < 1e-2
|
||||
longitudinalPlan.modelMonoTime = sm.logMonoTime['modelV2']
|
||||
longitudinalPlan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.logMonoTime['modelV2']
|
||||
|
||||
longitudinalPlan.allowBrake = True
|
||||
longitudinalPlan.allowThrottle = True
|
||||
@@ -194,7 +198,7 @@ def main():
|
||||
pm.send('longitudinalPlan', plan_send)
|
||||
|
||||
assistance_send = messaging.new_message('driverAssistance')
|
||||
assistance_send.valid = True
|
||||
assistance_send.valid = sm.all_checks(['carState', 'carControl', 'modelV2'])
|
||||
pm.send('driverAssistance', assistance_send)
|
||||
|
||||
if maneuver is not None and maneuver.finished:
|
||||
|
||||
Reference in New Issue
Block a user