Skip to content

Commit

Permalink
Fix Memory leaks from merge issues. update scons
Browse files Browse the repository at this point in the history
Update SConstruct
Update Scons, Fix runner, fix args in rgb_to_yuv.c
more scons fixes
Fix Memory leaks from merge issues. update scons
  • Loading branch information
SippieCup committed Apr 18, 2020
1 parent 78dc78c commit 48c86d4
Show file tree
Hide file tree
Showing 26 changed files with 284 additions and 274 deletions.
112 changes: 50 additions & 62 deletions README.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Version 0.7.5 (2020-04-23)
Version 0.7.5 (2020-xx-xx)
========================
* Right-Hand Drive support for both driving and driver monitoring!
* New driving model:
* New driver monitoring model: overall improvement on comma two
* Driver camera preview in settings to improve mounting position
* Added support for many Hyundai, Kia, Genesis models thanks to xx979xx!
* 2019 Nissan X-Trail and 2018 Nissan Leaf support thanks to avolmensky!
* Improved lateral tuning for 2020 Toyota Rav 4 (hybrid)

Version 0.7.4 (2020-03-20)
========================
Expand Down
118 changes: 65 additions & 53 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,28 @@ AddOption('--asan',

arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
is_tbp = os.path.isfile('/data/tinkla_buddy_pro')
if arch == "aarch64" and is_tbp:
arch = "jarch64"
if platform.system() == "Darwin":
arch = "Darwin"
if arch == "aarch64" and (not os.path.isdir("/system")) and not is_tbp:
if arch == "aarch64" and (not os.path.isdir("/system")):
arch = "larch64"

webcam = bool(ARGUMENTS.get("use_webcam", 0))

if arch == "aarch64":
if is_tbp:
webcam=True
lenv = {
"LD_LIBRARY_PATH": '/usr/lib:/usr/local/lib/:/usr/lib/aarch64-linux-gnu',
"PATH": os.environ['PATH'],
"ANDROID_DATA": "/data",
"ANDROID_ROOT": "/",
}
else:
lenv = {
"LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib',
"PATH": os.environ['PATH'],
"ANDROID_DATA": os.environ['ANDROID_DATA'],
"ANDROID_ROOT": os.environ['ANDROID_ROOT'],
}
if arch == "aarch64" or arch == "larch64":
lenv = {
"LD_LIBRARY_PATH": '/data/data/com.termux/files/usr/lib',
"PATH": os.environ['PATH'],
}

if arch == "aarch64":
# android
lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA']
lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT']

cpppath = [
"#phonelibs/opencl/include",
"#phonelibs/snpe/include",
]

libpath = [
Expand All @@ -48,43 +43,57 @@ if arch == "aarch64":
"/system/vendor/lib64",
"/system/comma/usr/lib",
"#phonelibs/nanovg",
"#phonelibs/snpe/aarch64",
"#phonelibs/libyuv/lib",
]

if is_tbp:
cflags = []
cxxflags = []
cpppath = [
"/usr/local/include",
"/usr/local/include/opencv4",
"/usr/include/khronos-api",
"/usr/include",
"#phonelibs/snpe/include",
"/usr/include/aarch64-linux-gnu",
]
libpath = [
"/usr/local/lib",
"/usr/lib/aarch64-linux-gnu",
"/usr/lib",
"/data/op_rk3399_setup/external/snpe/lib/lib",
"/data/data/com.termux/files/usr/lib",
"#phonelibs/nanovg",
"/data/op_rk3399_setup/support_files/lib",
]
rpath = ["/system/vendor/lib64",
"/usr/local/lib",
"/usr/lib/aarch64-linux-gnu",
"/usr/lib",
"/data/op_rk3399_setup/external/snpe/lib/lib",
"/data/op_rk3399_setup/support_files/lib",
"cereal",
"selfdrive/common",
]

if arch == "larch64":
cpppath += ["#phonelibs/capnp-cpp/include", "#phonelibs/capnp-c/include"]
libpath += ["#phonelibs/snpe/larch64"]
libpath += ["#phonelibs/libyuv/larch64/lib"]
libpath += ["#external/capnparm/lib", "/usr/lib/aarch64-linux-gnu"]
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
rpath = ["/usr/local/lib"]
else:
libpath += ["#phonelibs/snpe/aarch64"]
libpath += ["#phonelibs/libyuv/lib"]
cflags = ["-DQCOM", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM", "-mcpu=cortex-a57"]
rpath = ["/system/vendor/lib64"]
elif arch == "jarch64":
webcam=True
lenv = {
"LD_LIBRARY_PATH": '/usr/lib:/usr/local/lib/:/usr/lib/aarch64-linux-gnu',
"PATH": os.environ['PATH'],
"ANDROID_DATA": "/data",
"ANDROID_ROOT": "/",
}
cflags = []
cxxflags = []
cpppath = [
"/usr/local/include",
"/usr/local/include/opencv4",
"/usr/include/khronos-api",
"/usr/include",
"#phonelibs/snpe/include",
"/usr/include/aarch64-linux-gnu",
]
libpath = [
"/usr/local/lib",
"/usr/lib/aarch64-linux-gnu",
"/usr/lib",
"/data/op_rk3399_setup/external/snpe/lib/lib",
"/data/data/com.termux/files/usr/lib",
"#phonelibs/nanovg",
"/data/op_rk3399_setup/support_files/lib",
]
rpath = ["/usr/local/lib",
"/usr/lib/aarch64-linux-gnu",
"/usr/lib",
"/data/op_rk3399_setup/external/snpe/lib/lib",
"/data/op_rk3399_setup/support_files/lib",
"cereal",
"selfdrive/common",
]
else:
lenv = {
"PATH": "#external/bin:" + os.environ['PATH'],
Expand Down Expand Up @@ -221,10 +230,13 @@ def abspath(x):
return x[0].path.rsplit("/", 1)[1][:-3]

# still needed for apks
zmq = FindFile("libzmq.a", libpath)
if arch == 'larch64':
zmq = 'zmq'
else:
zmq = FindFile("libzmq.a", libpath)
if is_tbp:
zmq = FindFile("libzmq.so", libpath)
Export('env', 'arch', 'zmq', 'SHARED', 'webcam', 'is_tbp')
Export('env', 'arch', 'zmq', 'SHARED', 'webcam')

# cereal and messaging are shared with the system
SConscript(['cereal/SConscript'])
Expand Down Expand Up @@ -269,7 +281,7 @@ SConscript(['selfdrive/proclogd/SConscript'])
SConscript(['selfdrive/ui/SConscript'])
SConscript(['selfdrive/loggerd/SConscript'])

if arch == "aarch64" and not is_tbp:
if arch == "aarch64":
SConscript(['selfdrive/logcatd/SConscript'])
SConscript(['selfdrive/sensord/SConscript'])
SConscript(['selfdrive/clocksd/SConscript'])
Expand Down
4 changes: 2 additions & 2 deletions common/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_cdma_level(cdmadbm, cdmaecio):
if network_type == NetworkType.none:
return network_strength
if network_type == NetworkType.wifi:
out = subprocess.check_output('dumpsys connectivity', shell=True).decode('utf-8')
out = subprocess.check_output('dumpsys connectivity', shell=True).decode('ascii')
network_strength = NetworkStrength.unknown
for line in out.split('\n'):
signal_str = "SignalStrength: "
Expand All @@ -251,7 +251,7 @@ def get_cdma_level(cdmadbm, cdmaecio):
return network_strength
else:
# check cell strength
out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('utf-8')
out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('ascii')
for line in out.split('\n'):
if "mSignalStrength" in line:
arr = line.split(' ')
Expand Down
4 changes: 1 addition & 3 deletions common/realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ def remaining(self):
return self._remaining

# Maintain loop rate by calling this at the end of each loop
def keep_time(self, offset=0.):
def keep_time(self):
lagged = self.monitor_time()
if self._remaining > 0:
time.sleep(self._remaining)
elif not offset == 0.:
self._next_frame_time += offset
return lagged

# this only monitor the cumulative lag, but does not enforce a rate
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/boardd/boardd_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ARCH_DIR = 'x64'
else:
libraries = [':libcan_list_to_can_capnp.a', 'capnp', 'kj']
if os.path.isdir("/system") or os.path.isdir('/data/oprun'):
if os.path.isdir("/system"):
ARCH_DIR = 'aarch64'
else:
ARCH_DIR = 'larch64'
Expand Down
12 changes: 4 additions & 8 deletions selfdrive/camerad/SConscript
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Import('env', 'arch', 'messaging', 'is_tbp', 'common', 'gpucommon', 'visionipc', 'cereal', 'webcam')
Import('env', 'arch', 'messaging', 'common', 'gpucommon', 'visionipc', 'cereal', 'webcam')

libs = ['m', 'pthread', common, 'jpeg', 'json', cereal, 'OpenCL', messaging, 'czmq', 'zmq', 'capnp', 'kj', 'capnp_c', visionipc, gpucommon]

if is_tbp:
larch = "aarch64_TBP"
else:
larch = arch
if larch == "aarch64":
if arch == "aarch64":
libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui']
cameras = ['cameras/camera_qcom.c']
elif larch == "larch64":
elif arch == "larch64":
libs += []
cameras = ['cameras/camera_qcom2.c']
elif larch == "aarch64_TBP":
elif arch == "jarch64":
libs += ['opencv_core', 'opencv_highgui', 'opencv_video', 'opencv_imgproc', 'opencv_videoio']
cameras = ['cameras/camera_webcam.cc']
env = env.Clone()
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/camerad/transforms/rgb_to_yuv.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void rgb_to_yuv_init(RGBToYUVState* s, cl_context ctx, cl_device_id device_id, i
assert(height % 2 == 0);
s->width = width;
s->height = height;
char args[8024];
char args[1024];
printf("snprintf");
snprintf(args, sizeof(args),
"-cl-fast-relaxed-math -cl-denorms-are-zero "
Expand Down
6 changes: 5 additions & 1 deletion selfdrive/car/tesla/readconfig.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CFG_FILE=/data/bb_openpilot.cfg
CFG_CONTENT=$(cat $CFG_FILE | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g')
CFG_CONTENT=$(cat $CFG_FILE | sed -r "s/'/SINGLE_Q/" | sed -r '/[^=]+=[^=]+/!d' | sed -r 's/\s+=\s/=/g' | sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
-e 's/#.*$//' \
-e 's/[[:space:]]*$//' \
-e 's/^[[:space:]]*//' \
-e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" | sed -r "s/SINGLE_Q/'/" )
eval "export $CFG_CONTENT"
4 changes: 2 additions & 2 deletions selfdrive/common/SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import('env', 'arch', 'SHARED','is_tbp')
Import('env', 'arch', 'SHARED')

if SHARED:
fxn = env.SharedLibrary
Expand All @@ -17,7 +17,7 @@ files = [
]


if is_tbp:
if arch == "jarch64":
defines = {} #{"CLU_NO_CACHE": None}
files += [
'visionbuf_cl.c',
Expand Down
5 changes: 2 additions & 3 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


LANE_DEPARTURE_THRESHOLD = 0.1
EER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL
STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL
STEER_ANGLE_SATURATION_THRESHOLD = 250 # Degrees

ThermalStatus = log.ThermalData.ThermalStatus
Expand Down Expand Up @@ -119,7 +119,7 @@ def data_sample(CI, CC, sm, can_sock, state, mismatch_counter, can_error_counter
else:
events.append(create_event('calibrationInvalid', [ET.NO_ENTRY, ET.SOFT_DISABLE]))

if CS.vEgo > 150 * CV.MPH_TO_MS:
if CS.vEgo > 150 * CV.MPH_TO_MS:
events.append(create_event('speedTooHigh', [ET.NO_ENTRY, ET.SOFT_DISABLE]))

# When the panda and controlsd do not agree on controls_allowed
Expand Down Expand Up @@ -544,7 +544,6 @@ def controlsd_thread(sm=None, pm=None, can_sock=None):
# controlsd is driven by can recv, expected at 100Hz
rk = Ratekeeper(100, print_delay_threshold=None)

internet_needed = params.get("Offroad_ConnectivityNeeded", encoding='utf8') is not None

prof = Profiler(False) # off by default

Expand Down
21 changes: 18 additions & 3 deletions selfdrive/controls/lib/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __gt__(self, alert2):

Alert(
"preDriverDistracted",
"KEEP EYES ON ROAD: Driver Appears Distracted",
"KEEP EYES ON ROAD: Driver Distracted",
"",
AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75),
Expand Down Expand Up @@ -272,7 +272,7 @@ def __gt__(self, alert2):
Alert(
"dataNeededNoEntry",
"openpilot Unavailable",
"Data Needed for Calibration. Upload Drive, Try Again",
"Calibration Needs Data. Upload Drive, Try Again",
AlertStatus.normal, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 0., 3.),

Expand Down Expand Up @@ -526,6 +526,13 @@ def __gt__(self, alert2):
AlertStatus.normal, AlertSize.mid,
Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.),

Alert(
"speedTooHigh",
"Speed Too High",
"Slow down to resume operation",
AlertStatus.normal, AlertSize.mid,
Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.),

# Cancellation alerts causing non-entry
Alert(
"overheatNoEntry",
Expand All @@ -544,7 +551,7 @@ def __gt__(self, alert2):
Alert(
"calibrationInvalidNoEntry",
"openpilot Unavailable",
"Calibration Invalid: Reposition Device and Recalibrate",
"Calibration Invalid: Reposition Device & Recalibrate",
AlertStatus.normal, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.),

Expand Down Expand Up @@ -745,6 +752,13 @@ def __gt__(self, alert2):
AlertStatus.normal, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),

Alert(
"invalidLkasSettingPermanent",
"Stock LKAS is turned on",
"Turn off stock LKAS to engage",
AlertStatus.normal, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),

Alert(
"internetConnectivityNeededPermanent",
"Please connect to Internet",
Expand Down Expand Up @@ -801,6 +815,7 @@ def __gt__(self, alert2):
AlertStatus.normal, AlertSize.small,
Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1),

# offroad alerts
Alert(
"ldwPermanent",
"TAKE CONTROL",
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/pathplanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def update(self, sm, pm, CP, VM):

# starting
elif self.lane_change_state == LaneChangeState.laneChangeStarting:
# fade out lanelines over .5s
self.lane_change_ll_prob = max(self.lane_change_ll_prob - 2*DT_MDL, 0.0)
# fade out lanelines over 1s
self.lane_change_ll_prob = max(self.lane_change_ll_prob - DT_MDL, 0.0)
# 98% certainty
if lane_change_prob < 0.02 and self.lane_change_ll_prob < 0.01:
self.lane_change_state = LaneChangeState.laneChangeFinishing
Expand All @@ -157,7 +157,7 @@ def update(self, sm, pm, CP, VM):
if desire == log.PathPlan.Desire.laneChangeRight or desire == log.PathPlan.Desire.laneChangeLeft:
self.LP.l_prob *= self.lane_change_ll_prob
self.LP.r_prob *= self.lane_change_ll_prob
self.libmpc.init_weights(MPC_COST_LAT.PATH / 3.0, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost)
self.libmpc.init_weights(MPC_COST_LAT.PATH / 10.0, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost)
else:
self.libmpc.init_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.LANE, MPC_COST_LAT.HEADING, self.steer_rate_cost)

Expand Down
Loading

0 comments on commit 48c86d4

Please sign in to comment.