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

fix HUD and min speed problems for Honda Nidec #85

Closed
wants to merge 3 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
614 changes: 614 additions & 0 deletions CHANGELOGS-DEV.md

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import platform
import numpy as np

TICI = os.path.isfile('/TICI')
JETSON = os.path.isfile('/JETSON')

Decider('MD5-timestamp')

AddOption('--test',
Expand Down Expand Up @@ -53,6 +55,10 @@ if arch == "aarch64" and TICI:
USE_WEBCAM = os.getenv("USE_WEBCAM") is not None
QCOM_REPLAY = arch == "aarch64" and os.getenv("QCOM_REPLAY") is not None

USE_MIPI = os.getenv("USE_MIPI") is not None
if arch == "aarch64" and JETSON:
arch = "jarch64"

lenv = {
"PATH": os.environ['PATH'],
}
Expand Down Expand Up @@ -106,8 +112,19 @@ else:
cflags = []
cxxflags = []
cpppath = []
rpath = []

if arch == "Darwin":
if arch == "jarch64":
libpath = [
"#phonelibs/libyuv/larch64/lib",
"#selfdrive/common",
"/usr/lib",
"/usr/local/lib",
]
cflags = ["-DXNX", "-march=armv8.2-a"]
cxxflags = ["-DXNX", "-march=armv8.2-a"]
rpath += ["/usr/local/lib"]
elif arch == "Darwin":
yuv_dir = "mac" if real_arch != "arm64" else "mac_arm64"
libpath = [
f"#phonelibs/libyuv/{yuv_dir}/lib",
Expand All @@ -134,8 +151,9 @@ else:
"/usr/local/lib",
]

rpath = [
"phonelibs/snpe/x86_64-linux-clang",
if arch != "jarch64":
rpath += ["phonelibs/snpe/x86_64-linux-clang"]
rpath += [
"cereal",
"selfdrive/common"
]
Expand Down Expand Up @@ -306,7 +324,7 @@ else:
qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules]

qt_libs = [f"Qt5{m}" for m in qt_modules]
if arch == "larch64":
if arch == "larch64" or arch == "jarch64":
qt_libs += ["GLESv2", "wayland-client"]
elif arch != "Darwin":
qt_libs += ["GL"]
Expand Down Expand Up @@ -338,7 +356,7 @@ if GetOption("clazy"):
qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0]
qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks)

Export('env', 'qt_env', 'arch', 'real_arch', 'SHARED', 'USE_WEBCAM', 'QCOM_REPLAY')
Export('env', 'qt_env', 'arch', 'real_arch', 'SHARED', 'USE_WEBCAM', 'QCOM_REPLAY', 'USE_MIPI')

# cereal and messaging are shared with the system
SConscript(['cereal/SConscript'])
Expand Down
2 changes: 1 addition & 1 deletion cereal/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ messaging_dir = Dir('messaging')

# Build cereal

schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp']
schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp', 'dp.capnp']
env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS")
env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files],
schema_files,
Expand Down
18 changes: 17 additions & 1 deletion cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ struct CarEvent @0x9b1657f34caf3ad3 {
neosUpdateRequiredDEPRECATED @88;
modelLagWarningDEPRECATED @93;
startupOneplusDEPRECATED @82;

#dp
preLaneChangeLeftALC @99;
preLaneChangeRightALC @100;
manualSteeringRequired @101;
manualSteeringRequiredBlinkersOn @102;
leadCarMoving @103;

# timebomb assist
timebombWarn @104;
timebombBypassing @105;
timebombBypassed @106;
}
}

Expand Down Expand Up @@ -189,6 +201,10 @@ struct CarState {
leftBlindspot @33 :Bool; # Is there something blocking the left lane change
rightBlindspot @34 :Bool; # Is there something blocking the right lane change

# dp
lkMode @37 :Bool;
stopSteering @38 :Bool; # timebomb - stopSteering

struct WheelSpeeds {
# optional wheel speeds
fl @0 :Float32;
Expand Down Expand Up @@ -556,5 +572,5 @@ struct CarParams {
gateway @1; # Integration at vehicle's CAN gateway
}

isPandaBlackDEPRECATED @39: Bool;
isPandaBlack @39: Bool;
}
58 changes: 58 additions & 0 deletions cereal/dp.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal");

using Java = import "./include/java.capnp";
$Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("dp");

@0xbfa7e645486440c7;

# dp.capnp: a home for deprecated structs

# dp
struct DragonConf {
dpThermalStarted @0 :Bool;
dpThermalOverheat @1 :Bool;
dpAtl @2 :Bool;
dpAutoShutdown @3 :Bool;
dpAthenad @4 :Bool;
dpUploader @5 :Bool;
dpSteeringOnSignal @6 :Bool;
dpSignalOffDelay @7 :UInt8;
dpAssistedLcMinMph @8 :Float32;
dpAutoLc @9 :Bool;
dpAutoLcCont @10 :Bool;
dpAutoLcMinMph @11 :Float32;
dpAutoLcDelay @12 :Float32;
dpAllowGas @13 :Bool;
dpFollowingProfileCtrl @14 :Bool;
dpFollowingProfile @15 :UInt8;
dpAccelProfileCtrl @16 :Bool;
dpAccelProfile @17 :UInt8;
dpGearCheck @18 :Bool;
dpSpeedCheck @19 :Bool;
dpUiScreenOffReversing @20 :Bool;
dpUiSpeed @21 :Bool;
dpUiEvent @22 :Bool;
dpUiMaxSpeed @23 :Bool;
dpUiFace @24 :Bool;
dpUiLane @25 :Bool;
dpUiLead @26 :Bool;
dpUiDev @27 :Bool;
dpUiDevMini @28 :Bool;
dpUiBlinker @29 :Bool;
dpAppExtGps @30 :Bool;
dpAppTomtom @31 :Bool;
dpAppTomtomAuto @32 :Bool;
dpAppTomtomManual @33 :Int8;
dpAppMixplorer @34 :Bool;
dpAppMixplorerManual @35 :Int8;
dpCarDetected @36 :Text;
dpToyotaLdw @37 :Bool;
dpToyotaSng @38 :Bool;
dpVwPanda @39 :Bool;
dpVwTimebombAssist @40 :Bool;
dpIpAddr @41 :Text;
dpLocale @42 :Text;
dpDebug @43 :Bool;
}
8 changes: 7 additions & 1 deletion cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $Java.outerClassname("Log");

using Car = import "car.capnp";
using Legacy = import "legacy.capnp";
using Dp = import "dp.capnp";

@0xf3b1f17e25a4285b;

Expand Down Expand Up @@ -48,6 +49,7 @@ struct InitData {
chffrIos @3;
tici @4;
pc @5;
jetson @6;
}

struct PandaInfo {
Expand Down Expand Up @@ -617,7 +619,7 @@ struct ControlsState @0x97ff69c53601abf1 {
decelForTurnDEPRECATED @47 :Bool;
decelForModelDEPRECATED @54 :Bool;
awarenessStatusDEPRECATED @26 :Float32;
angleSteersDEPRECATED @13 :Float32;
angleSteers @13 :Float32; # dp
vCurvatureDEPRECATED @46 :Float32;
mapValidDEPRECATED @49 :Bool;
jerkFactorDEPRECATED @12 :Float32;
Expand Down Expand Up @@ -790,6 +792,9 @@ struct LateralPlan @0xe1e9318e2ae8b51e {
rawCurvature @24 :Float32;
rawCurvatureRate @25 :Float32;

# dp
dpALCAllowed @26 :Bool;

enum Desire {
none @0;
turnLeft @1;
Expand Down Expand Up @@ -1359,5 +1364,6 @@ struct Event {
kalmanOdometryDEPRECATED @65 :Legacy.KalmanOdometry;
gpsLocationDEPRECATED @21 :GpsLocationData;
uiLayoutStateDEPRECATED @57 :Legacy.UiLayoutState;
dragonConf @79 :Dp.DragonConf;
}
}
5 changes: 5 additions & 0 deletions cereal/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op
"testModel": (False, 0.),
"testLiveLocation": (False, 0.),
"testJoystick": (False, 0.),

# dp
"thermal": (True, 2., 1),
"dragonConf": (False, 2.),

}
service_list = {name: Service(new_port(idx), *vals) for # type: ignore
idx, (name, vals) in enumerate(services.items())}
Expand Down
4 changes: 2 additions & 2 deletions common/basedir.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
from pathlib import Path

from selfdrive.hardware import PC
from selfdrive.hardware import PC, JETSON

BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))

if PC:
if PC or JETSON:
PERSIST = os.path.join(str(Path.home()), ".comma", "persist")
else:
PERSIST = "/persist"
80 changes: 80 additions & 0 deletions common/dp_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python3.7
import subprocess
from cereal import car
from common.params import Params
from common.realtime import sec_since_boot
import os
params = Params()
PARAM_PATH = params.get_params_path() + '/d/'
LAST_MODIFIED = PARAM_PATH + "dp_last_modified"

def is_online():
try:
return not subprocess.call(["ping", "-W", "4", "-c", "1", "117.28.245.92"])
except ProcessLookupError:
return False

def common_controller_ctrl(enabled, dragonconf, blinker_on, steer_req, v_ego):
if enabled:
if dragonconf.dpSteeringOnSignal and blinker_on:
steer_req = 0 if isinstance(steer_req, int) else False
return steer_req

def common_interface_atl(ret, atl):
# dp
enable_acc = ret.cruiseState.enabled
if atl and ret.cruiseState.available:
enable_acc = True
if ret.gearShifter in [car.CarState.GearShifter.reverse, car.CarState.GearShifter.park]:
enable_acc = False
if ret.seatbeltUnlatched or ret.doorOpen:
enable_acc = False
return enable_acc

def common_interface_get_params_lqr(ret):
if params.get('dp_lqr') == b'1':
ret.lateralTuning.init('lqr')
ret.lateralTuning.lqr.scale = 1500.0
ret.lateralTuning.lqr.ki = 0.05

ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268]
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05]
ret.lateralTuning.lqr.c = [1., 0.]
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255]
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757]
ret.lateralTuning.lqr.dcGain = 0.002237852961363602
return ret


def get_last_modified(delay, old_check, old_modified):
new_check = sec_since_boot()
if old_check is None or new_check - old_check >= delay:
return new_check, os.stat(LAST_MODIFIED).st_mtime
else:
return old_check, old_modified

def param_get_if_updated(param, type, old_val, old_modified):
try:
modified = os.stat(PARAM_PATH + param).st_mtime
except OSError:
return old_val, old_modified
if old_modified != modified:
new_val = param_get(param, type, old_val)
new_modified = modified
else:
new_val = old_val
new_modified = old_modified
return new_val, new_modified

def param_get(param_name, type, default):
try:
val = params.get(param_name, encoding='utf8').rstrip('\x00')
if type == 'bool':
val = val == '1'
elif type == 'int':
val = int(val)
elif type == 'float':
val = float(val)
except (TypeError, ValueError):
val = default
return val
Loading