Skip to content

Commit

Permalink
Merge branch 'commaai:master' into PA-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Edison-CBS authored Feb 4, 2024
2 parents 11b6806 + 81f52f2 commit 332ed27
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
9 changes: 9 additions & 0 deletions common/swaglog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ class SwaglogState {
if (char* dongle_id = getenv("DONGLE_ID")) {
ctx_j["dongle_id"] = dongle_id;
}
if (char* git_origin = getenv("GIT_ORIGIN")) {
ctx_j["origin"] = git_origin;
}
if (char* git_branch = getenv("GIT_BRANCH")) {
ctx_j["branch"] = git_branch;
}
if (char* git_commit = getenv("GIT_COMMIT")) {
ctx_j["commit"] = git_commit;
}
if (char* daemon_name = getenv("MANAGER_DAEMON")) {
ctx_j["daemon"] = daemon_name;
}
Expand Down
11 changes: 9 additions & 2 deletions selfdrive/athena/manage_athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
from openpilot.common.params import Params
from openpilot.selfdrive.manager.process import launcher
from openpilot.common.swaglog import cloudlog
from openpilot.system.version import get_version, is_dirty
from openpilot.system.hardware import HARDWARE
from openpilot.system.version import get_version, get_normalized_origin, get_short_branch, get_commit, is_dirty

ATHENA_MGR_PID_PARAM = "AthenadPid"


def main():
params = Params()
dongle_id = params.get("DongleId").decode('utf-8')
cloudlog.bind_global(dongle_id=dongle_id, version=get_version(), dirty=is_dirty())
cloudlog.bind_global(dongle_id=dongle_id,
version=get_version(),
origin=get_normalized_origin(),
branch=get_short_branch(),
commit=get_commit(),
dirty=is_dirty(),
device=HARDWARE.get_device_type())

try:
while 1:
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ def fingerprint(logcan, sendcan, num_pandas):

cloudlog.event("fingerprinted", car_fingerprint=car_fingerprint, source=source, fuzzy=not exact_match, cached=cached,
fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), vin_rx_addr=vin_rx_addr, vin_rx_bus=vin_rx_bus,
fingerprints=finger, fw_query_time=fw_query_time, error=True)
fingerprints=repr(finger), fw_query_time=fw_query_time, error=True)
return car_fingerprint, finger, vin, car_fw, source, exact_match


def get_car(logcan, sendcan, experimental_long_allowed, num_pandas=1):
candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan, num_pandas)

if candidate is None:
cloudlog.event("car doesn't match any fingerprints", fingerprints=fingerprints, error=True)
cloudlog.event("car doesn't match any fingerprints", fingerprints=repr(fingerprints), error=True)
candidate = "mock"

CarInterface, CarController, CarState = interfaces[candidate]
Expand Down
15 changes: 15 additions & 0 deletions selfdrive/car/tests/test_car_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from openpilot.selfdrive.car.fingerprints import all_known_cars
from openpilot.selfdrive.car.fw_versions import FW_VERSIONS
from openpilot.selfdrive.car.interfaces import get_interface_attr
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
from openpilot.selfdrive.controls.lib.longcontrol import LongControl
from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator

ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()})
Expand Down Expand Up @@ -108,6 +112,17 @@ def test_car_interfaces(self, car_name, data):
car_interface.apply(CC, now_nanos)
now_nanos += DT_CTRL * 1e9 # 10ms

# Test controller initialization
# TODO: wait until card refactor is merged to run controller a few times,
# hypothesis also slows down significantly with just one more message draw
LongControl(car_params)
if car_params.steerControlType == car.CarParams.SteerControlType.angle:
LatControlAngle(car_params, car_interface)
elif car_params.lateralTuning.which() == 'pid':
LatControlPID(car_params, car_interface)
elif car_params.lateralTuning.which() == 'torque':
LatControlTorque(car_params, car_interface)

# Test radar interface
RadarInterface = importlib.import_module(f'selfdrive.car.{car_params.carName}.radar_interface').RadarInterface
radar_interface = RadarInterface(car_params)
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def manager_init() -> None:
serial = params.get("HardwareSerial")
raise Exception(f"Registration failed for device {serial}")
os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog
os.environ['GIT_ORIGIN'] = get_normalized_origin() # Needed for swaglog
os.environ['GIT_BRANCH'] = get_short_branch() # Needed for swaglog
os.environ['GIT_COMMIT'] = get_commit() # Needed for swaglog

if not is_dirty():
os.environ['CLEAN'] = '1'
Expand Down

0 comments on commit 332ed27

Please sign in to comment.