Skip to content

Commit cbca866

Browse files
authored
Merge pull request #1 from eFiniLan/master_dev
up to 2023-04-26 commits
2 parents aeef76b + f08c414 commit cbca866

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+470
-314
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,13 @@ build/
8383
!**/.gitkeep
8484

8585
poetry.toml
86+
87+
# rick - these are generated during compilation.
88+
selfdrive/camerad/camerad
89+
selfdrive/golden/
90+
selfdrive/legacy_modeld/_dmonitoringmodeld
91+
selfdrive/legacy_modeld/_modeld
92+
selfdrive/legacy_modeld/models/supercombo.thneed
93+
selfdrive/legacy_modeld/models/supercombo_badweights.thneed
94+
selfdrive/legacy_modeld/thneed/compile
95+
selfdrive/loggerd/bootlog

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ legacypilot is a side project that enables comma.ai EON and Comma Two devices to
1111

1212
legacypilot combines the Nuclear Grade Model with the latest openpilot (almost) codebase to create a hybrid solution. With the legacypilot project, we have stripped out nearly 99% of the dragonpilot code.
1313

14+
In summary, legacypilot is based on Openpilot 0.8.16 with the latest vehicle model support from the Openpilot master branch.
15+
16+
Please note that this build is and will always be in the experimental phase and may not be suitable for use as a daily driver.
17+
18+
I recommend using the openpilot [commatwo_master](https://github.com/commaai/openpilot/tree/commatwo_master) branch for your daily driving needs.
19+
20+
Please see [README_openpilot.md](README_openpilot.md) for the original readme.
1421

1522
## Why use legacypilot
1623

@@ -22,8 +29,9 @@ I have decided to make this side project open source for users who wish to:
2229
* Experience pure openpilot (without the modifications of dragonpilot)
2330
* Make their own EON/C2 fork without spending hundreds of hours reverting and testing code.
2431

25-
By making this project open source, I hope to alleviate some of the frustration and complaints about not being able to access the source code. However, I still encourage users to consider purchasing a [comma 3](https://shop.comma.ai) for the best and up-to-date openpilot experience.
32+
By making this project open source, I hope to alleviate some of the frustration and complaints about not being able to access the dragonpilot source code.
2633

34+
I still encourage users to consider purchasing a [comma 3](https://shop.comma.ai) for the best and up-to-date openpilot experience.
2735

2836
## Limitations
2937

@@ -33,9 +41,3 @@ By making this project open source, I hope to alleviate some of the frustration
3341
* Navigation On Openpilot (NOO) is not supported, as it requires a newer driving model that is not currently available in legacypilot.
3442
* Services are not optimized for resource usage, and using all services may result in overheating issues.
3543
* Language files can only be generated in a PC due to missing Qt5 tools.
36-
37-
In summary, legacypilot is based on Openpilot 0.8.16 with the latest vehicle model support from the Openpilot master branch.
38-
39-
However, please note that this build is still in the experimental phase and may not be suitable for use as a daily driver. We recommend using the openpilot mastertwo branch for your daily driving needs.
40-
41-
Please see README_openpilot.md for the original readme.

SConstruct

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import numpy as np
77

88
import SCons.Errors
99

10+
SCons.Warnings.warningAsException(True)
11+
1012
TICI = os.path.isfile('/TICI')
1113
AGNOS = TICI
1214

@@ -359,7 +361,9 @@ else:
359361
qt_libs = ['gui', 'adreno_utils']
360362
elif arch != "Darwin":
361363
qt_libs += ["GL"]
364+
qt_env['QT3DIR'] = qt_env['QTDIR']
362365

366+
# compatibility for older SCons versions
363367
try:
364368
qt_env.Tool('qt3')
365369
except SCons.Errors.UserError:
@@ -491,7 +495,7 @@ SConscript(['system/sensord/SConscript'])
491495
SConscript(['selfdrive/ui/SConscript'])
492496
# SConscript(['selfdrive/navd/SConscript'])
493497

494-
if arch in ['x86_64', 'Darwin'] or GetOption('extras'):
498+
if (arch in ['x86_64', 'Darwin'] and Dir('#tools/cabana/').exists()) or GetOption('extras'):
495499
SConscript(['tools/replay/SConscript'])
496500
SConscript(['tools/cabana/SConscript'])
497501

common/legacy_modeldata.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include "system/hardware/hw.h"
66

77
const int TRAJECTORY_SIZE = 33;
8-
const int LAT_MPC_N = 16;
9-
const int LON_MPC_N = 32;
108
const float MIN_DRAW_DISTANCE = 10.0;
119
const float MAX_DRAW_DISTANCE = 100.0;
1210

docs/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ WORKDIR ${OPENPILOT_PATH}
1111

1212
COPY SConstruct ${OPENPILOT_PATH}
1313

14+
COPY ./body ${OPENPILOT_PATH}/body
1415
COPY ./third_party ${OPENPILOT_PATH}/third_party
1516
COPY ./site_scons ${OPENPILOT_PATH}/site_scons
1617
COPY ./laika ${OPENPILOT_PATH}/laika

opendbc

Submodule opendbc updated 51 files

panda

Submodule panda updated 75 files

release/files_common

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ selfdrive/modeld/runners/run.h
396396
selfdrive/monitoring/dmonitoringd.py
397397
selfdrive/monitoring/driver_monitor.py
398398

399+
selfdrive/navd/.gitignore
399400
selfdrive/navd/__init__.py
400-
selfdrive/navd/navd.py
401-
selfdrive/navd/helpers.py
401+
selfdrive/navd/**
402402

403403
selfdrive/assets/.gitignore
404404
selfdrive/assets/assets.qrc

selfdrive/car/ford/carcontroller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from common.numpy_fast import clip
33
from opendbc.can.packer import CANPacker
44
from selfdrive.car import apply_std_steer_angle_limits
5-
from selfdrive.car.ford.fordcan import create_acc_command, create_acc_ui_msg, create_button_msg, create_lat_ctl_msg, \
5+
from selfdrive.car.ford.fordcan import create_acc_msg, create_acc_ui_msg, create_button_msg, create_lat_ctl_msg, \
66
create_lat_ctl2_msg, create_lka_msg, create_lkas_ui_msg
77
from selfdrive.car.ford.values import CANBUS, CANFD_CARS, CarControllerParams
88

@@ -76,7 +76,7 @@ def update(self, CC, CS, now_nanos):
7676
gas = -5.0
7777
decel = True
7878

79-
can_sends.append(create_acc_command(self.packer, CC.longActive, gas, accel, precharge_brake, decel))
79+
can_sends.append(create_acc_msg(self.packer, CC.longActive, gas, accel, precharge_brake, decel))
8080

8181
### ui ###
8282
send_ui = (self.main_on_last != main_on) or (self.lkas_enabled_last != CC.latActive) or (self.steer_alert_last != steer_alert)

selfdrive/car/ford/fordcan.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def create_lat_ctl2_msg(packer, mode: int, path_offset: float, path_angle: float
9797
return packer.make_can_msg("LateralMotionControl2", CANBUS.main, values)
9898

9999

100-
def create_acc_command(packer, long_active: bool, gas: float, accel: float, precharge_brake: bool, decel: bool):
100+
def create_acc_msg(packer, long_active: bool, gas: float, accel: float, precharge_brake: bool, decel: bool):
101101
"""
102102
Creates a CAN message for the Ford ACC Command.
103103
@@ -117,6 +117,40 @@ def create_acc_command(packer, long_active: bool, gas: float, accel: float, prec
117117
return packer.make_can_msg("ACCDATA", CANBUS.main, values)
118118

119119

120+
def create_acc_ui_msg(packer, main_on: bool, enabled: bool, hud_control, stock_values: dict):
121+
"""
122+
Creates a CAN message for the Ford IPC adaptive cruise, forward collision warning and traffic jam assist status.
123+
124+
Stock functionality is maintained by passing through unmodified signals.
125+
126+
Frequency is 20Hz.
127+
"""
128+
129+
# Tja_D_Stat
130+
if enabled:
131+
if hud_control.leftLaneDepart:
132+
status = 3 # ActiveInterventionLeft
133+
elif hud_control.rightLaneDepart:
134+
status = 4 # ActiveInterventionRight
135+
else:
136+
status = 2 # Active
137+
elif main_on:
138+
if hud_control.leftLaneDepart:
139+
status = 5 # ActiveWarningLeft
140+
elif hud_control.rightLaneDepart:
141+
status = 6 # ActiveWarningRight
142+
else:
143+
status = 1 # Standby
144+
else:
145+
status = 0 # Off
146+
147+
values = {
148+
**stock_values,
149+
"Tja_D_Stat": status,
150+
}
151+
return packer.make_can_msg("ACCDATA_3", CANBUS.main, values)
152+
153+
120154
def create_lkas_ui_msg(packer, main_on: bool, enabled: bool, steer_alert: bool, hud_control, stock_values: dict):
121155
"""
122156
Creates a CAN message for the Ford IPC IPMA/LKAS status.
@@ -168,40 +202,6 @@ def create_lkas_ui_msg(packer, main_on: bool, enabled: bool, steer_alert: bool,
168202
return packer.make_can_msg("IPMA_Data", CANBUS.main, values)
169203

170204

171-
def create_acc_ui_msg(packer, main_on: bool, enabled: bool, hud_control, stock_values: dict):
172-
"""
173-
Creates a CAN message for the Ford IPC adaptive cruise, forward collision warning and traffic jam assist status.
174-
175-
Stock functionality is maintained by passing through unmodified signals.
176-
177-
Frequency is 20Hz.
178-
"""
179-
180-
# Tja_D_Stat
181-
if enabled:
182-
if hud_control.leftLaneDepart:
183-
status = 3 # ActiveInterventionLeft
184-
elif hud_control.rightLaneDepart:
185-
status = 4 # ActiveInterventionRight
186-
else:
187-
status = 2 # Active
188-
elif main_on:
189-
if hud_control.leftLaneDepart:
190-
status = 5 # ActiveWarningLeft
191-
elif hud_control.rightLaneDepart:
192-
status = 6 # ActiveWarningRight
193-
else:
194-
status = 1 # Standby
195-
else:
196-
status = 0 # Off
197-
198-
values = {
199-
**stock_values,
200-
"Tja_D_Stat": status,
201-
}
202-
return packer.make_can_msg("ACCDATA_3", CANBUS.main, values)
203-
204-
205205
def create_button_msg(packer, stock_values: dict, cancel=False, resume=False, tja_toggle=False,
206206
bus: int = CANBUS.camera):
207207
"""

selfdrive/car/subaru/values.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ class SubaruCarInfo(CarInfo):
482482
b'\xa1 "\t\x01',
483483
b'\xa1 \x08\x02',
484484
b'\xa1 \x06\x02',
485+
b'\xa1 \x07\x02',
485486
b'\xa1 \x08\x00',
486487
b'\xa1 "\t\x00',
487488
],
@@ -493,6 +494,7 @@ class SubaruCarInfo(CarInfo):
493494
(Ecu.fwdCamera, 0x787, None): [
494495
b'\x00\x00eJ\x00\x1f@ \x19\x00',
495496
b'\000\000e\x80\000\037@ \031\000',
497+
b'\x00\x00e\x9a\x00\x00\x00\x00\x00\x00',
496498
b'\x00\x00e\x9a\x00\x1f@ 1\x00',
497499
b'\x00\x00eJ\x00\x00\x00\x00\x00\x00',
498500
],
@@ -502,6 +504,7 @@ class SubaruCarInfo(CarInfo):
502504
b'\xde"`0\a',
503505
b'\xf1\x82\xbc,\xa0q\a',
504506
b'\xf1\x82\xe3,\xa0@\x07',
507+
b'\xe2"`0\x07',
505508
b'\xe2"`p\x07',
506509
b'\xf1\x82\xe2,\xa0@\x07',
507510
b'\xbc"`q\x07',
@@ -513,6 +516,7 @@ class SubaruCarInfo(CarInfo):
513516
b'\xa5\xfe\xf6@\x00',
514517
b'\xa7\x8e\xf40\x00',
515518
b'\xf1\x82\xa7\xf6D@\x00',
519+
b'\xa7\xf6D@\x00',
516520
b'\xa7\xfe\xf4@\x00',
517521
],
518522
},

selfdrive/controls/lib/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster,
719719

720720
EventName.calibrationIncomplete: {
721721
ET.PERMANENT: calibration_incomplete_alert,
722-
ET.SOFT_DISABLE: soft_disable_alert("Calibration in Progress"),
722+
ET.SOFT_DISABLE: soft_disable_alert("Device remount detected: recalibrating"),
723723
ET.NO_ENTRY: NoEntryAlert("Calibration in Progress"),
724724
},
725725

selfdrive/locationd/calibrationd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def update_status(self) -> None:
143143
# If spread is too high, assume mounting was changed and reset to last block.
144144
# Make the transition smooth. Abrupt transitions are not good for feedback loop through supercombo model.
145145
if max(self.calib_spread) > MAX_ALLOWED_SPREAD and self.cal_status == Calibration.CALIBRATED:
146-
self.reset(self.rpys[self.block_idx - 1], valid_blocks=INPUTS_NEEDED, smooth_from=self.rpy)
146+
self.reset(self.rpys[self.block_idx - 1], valid_blocks=1, smooth_from=self.rpy)
147147

148148
write_this_cycle = (self.idx == 0) and (self.block_idx % (INPUTS_WANTED//5) == 5)
149149
if self.param_put and write_this_cycle:

selfdrive/locationd/locationd.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ void Localizer::build_live_location(cereal::LiveLocationKalman::Builder& fix) {
180180
fix.setPosenetOK(!(std_spike && this->car_speed > 5.0));
181181
fix.setDeviceStable(!this->device_fell);
182182
fix.setExcessiveResets(this->reset_tracker > MAX_RESET_TRACKER);
183+
// rick - disable it for now, compilation error, cereal looks fine, used in laikad
184+
// fix.setTimeToFirstFix(std::isnan(this->ttff) ? -1. : this->ttff);
183185
this->device_fell = false;
184186

185187
//fix.setGpsWeek(this->time.week);
@@ -573,6 +575,9 @@ void Localizer::time_check(double current_time) {
573575
if (std::isnan(this->last_reset_time)) {
574576
this->last_reset_time = current_time;
575577
}
578+
if (std::isnan(this->first_valid_log_time)) {
579+
this->first_valid_log_time = current_time;
580+
}
576581
double filter_time = this->kf->get_filter_time();
577582
bool big_time_gap = !std::isnan(filter_time) && (current_time - filter_time > 10);
578583
if (big_time_gap) {
@@ -765,6 +770,11 @@ int Localizer::locationd_thread() {
765770
bool sensorsOK = sm.allAliveAndValid({"accelerometer", "gyroscope"});
766771
#endif
767772

773+
// Log time to first fix
774+
if (gpsOK && std::isnan(this->ttff) && !std::isnan(this->first_valid_log_time)) {
775+
this->ttff = std::max(1e-3, (sm[trigger_msg].getLogMonoTime() * 1e-9) - this->first_valid_log_time);
776+
}
777+
768778
MessageBuilder msg_builder;
769779
kj::ArrayPtr<capnp::byte> bytes = this->get_message_bytes(msg_builder, inputsOK, sensorsOK, gpsOK, filterInitialized);
770780
pm.send("liveLocationKalman", bytes.begin(), bytes.size());

selfdrive/locationd/locationd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class Localizer {
7979
double reset_tracker = 0.0;
8080
bool device_fell = false;
8181
bool gps_mode = false;
82+
double first_valid_log_time = NAN;
83+
double ttff = NAN;
8284
double last_gps_msg = 0;
8385
bool ublox_available = true;
8486
bool observation_timings_invalid = false;

selfdrive/locationd/test/test_calibrationd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_calibration_auto_reset(self):
9595
[0.0, 0.0, 0.0],
9696
[0.0, 0.0, 0.0],
9797
[1e-3, 1e-3, 1e-3])
98-
self.assertEqual(c.valid_blocks, INPUTS_NEEDED)
98+
self.assertEqual(c.valid_blocks, 1)
9999
np.testing.assert_allclose(c.rpy, [0.0, 0.0, -0.05], atol=1e-2)
100100

101101
if __name__ == "__main__":

selfdrive/manager/manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID
2121
from system.swaglog import cloudlog, add_file_handler
2222
from system.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \
23-
terms_version, training_version, is_tested_branch, is_release_branch
23+
get_normalized_origin, terms_version, training_version, \
24+
is_tested_branch, is_release_branch
2425

2526

2627

@@ -92,7 +93,12 @@ def manager_init() -> None:
9293

9394
# init logging
9495
sentry.init(sentry.SentryProject.SELFDRIVE)
95-
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=is_dirty(),
96+
cloudlog.bind_global(dongle_id=dongle_id,
97+
version=get_version(),
98+
origin=get_normalized_origin(),
99+
branch=get_short_branch(),
100+
commit=get_commit(),
101+
dirty=is_dirty(),
96102
device=HARDWARE.get_device_type())
97103

98104

selfdrive/navd/SConscript

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
Import('qt_env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'transformations')
22

3-
base_libs = [common, messaging, cereal, visionipc, transformations, 'zmq',
4-
'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"]
5-
3+
map_env = qt_env.Clone()
4+
libs = ['qt_widgets', 'qt_util', 'qmapboxgl', common, messaging, cereal, visionipc, transformations,
5+
'zmq', 'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread', 'json11'] + map_env["LIBS"]
66
if arch == 'larch64':
7-
base_libs.append('EGL')
7+
libs.append('EGL')
88

99
if arch in ['larch64', 'x86_64']:
1010
if arch == 'x86_64':
11-
rpath = [Dir(f"#third_party/mapbox-gl-native-qt/{arch}").srcnode().abspath]
12-
qt_env["RPATH"] += rpath
11+
rpath = Dir(f"#third_party/mapbox-gl-native-qt/{arch}").srcnode().abspath
12+
map_env["RPATH"] += [rpath, ]
1313

1414
style_path = File("style.json").abspath
15-
qt_env['CXXFLAGS'].append(f'-DSTYLE_PATH=\\"{style_path}\\"')
16-
qt_libs = ["qt_widgets", "qt_util", "qmapboxgl"] + base_libs
17-
18-
nav_src = ["main.cc", "map_renderer.cc"]
19-
qt_env.Program("map_renderer", nav_src, LIBS=qt_libs + ['common', 'json11'])
15+
map_env['CXXFLAGS'].append(f'-DSTYLE_PATH=\\"{style_path}\\"')
2016

21-
qt_env.SharedLibrary("map_renderer", ["map_renderer.cc"], LIBS=qt_libs + ['common', 'messaging'])
17+
map_env["RPATH"].append(Dir('.').abspath)
18+
map_env["LIBPATH"].append(Dir('.').abspath)
19+
maplib = map_env.SharedLibrary("maprender", ["map_renderer.cc"], LIBS=libs)
20+
map_env.Program("map_renderer", ["main.cc", ], LIBS=[maplib[0].get_path(), ] + libs)

selfdrive/test/process_replay/process_replay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def ublox_rcv_callback(msg, CP, cfg, fsm):
279279
fake_pubsubmaster=True,
280280
submaster_config={
281281
'ignore_avg_freq': ['radarState', 'longitudinalPlan', 'driverCameraState', 'driverMonitoringState'], # dcam is expected at 20 Hz
282-
'ignore_alive': ['wideRoadCameraState'], # TODO: Add to regen
282+
'ignore_alive': [],
283283
}
284284
),
285285
ProcessConfig(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28ac0bf6aa9142446917301071cf03797a724bf2
1+
627aa0f54e377d1f3954c58e37c0a15b555e20b3

0 commit comments

Comments
 (0)