Skip to content

Commit

Permalink
Merge branch 'commaai:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasloetkolben authored Jan 27, 2025
2 parents d03339b + 8bfce09 commit e69fa77
Show file tree
Hide file tree
Showing 58 changed files with 546 additions and 383 deletions.
4 changes: 2 additions & 2 deletions cereal/messaging/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

ExitHandler do_exit;

static std::vector<std::string> get_services(std::string whitelist_str, bool zmq_to_msgq) {
static std::vector<std::string> get_services(const std::string &whitelist_str, bool zmq_to_msgq) {
std::vector<std::string> service_list;
for (const auto& it : services) {
std::string name = it.second.name;
bool in_whitelist = whitelist_str.find(name) != std::string::npos;
if (name == "plusFrame" || name == "uiLayoutState" || (zmq_to_msgq && !in_whitelist)) {
if (zmq_to_msgq && !in_whitelist) {
continue;
}
service_list.push_back(name);
Expand Down
1 change: 1 addition & 0 deletions common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class FileLock {

std::unordered_map<std::string, uint32_t> keys = {
{"AccessToken", CLEAR_ON_MANAGER_START | DONT_LOG},
{"AdbEnabled", PERSISTENT},
{"AlwaysOnDM", PERSISTENT},
{"ApiCache_Device", PERSISTENT},
{"AssistNowToken", PERSISTENT},
Expand Down
16 changes: 16 additions & 0 deletions docs/how-to/connect-to-comma.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ Here's an example command for connecting to your device using its tethered conne

For doing development work on device, it's recommended to use [SSH agent forwarding](https://docs.github.com/en/developers/overview/using-ssh-agent-forwarding).


## ADB

In order to use ADB on your device, you'll need to enable it in the device's settings.

* Enable ADB in your device's settings
* Connect to your device
* `adb shell` over USB
* `adb connect` over WiFi
* Here's an example command for connecting to your device using its tethered connection: `adb connect 192.168.43.1:5555`

> [!NOTE]
> The default port for ADB is 5555 on the comma 3/3X.
For more info on ADB, see the [Android Debug Bridge (ADB) documentation](https://developer.android.com/tools/adb).

### Notes

The public keys are only fetched from your GitHub account once. In order to update your device's authorized keys, you'll need to re-enter your GitHub username.
Expand Down
2 changes: 1 addition & 1 deletion launch_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export OPENBLAS_NUM_THREADS=1
export VECLIB_MAXIMUM_THREADS=1

if [ -z "$AGNOS_VERSION" ]; then
export AGNOS_VERSION="11.4"
export AGNOS_VERSION="11.6"
fi

export STAGING_ROOT="/data/safe_staging"
2 changes: 1 addition & 1 deletion panda
22 changes: 11 additions & 11 deletions selfdrive/car/car_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ def __init__(self, CP: structs.CarParams):
self.cruise_buttons: deque = deque([], maxlen=HYUNDAI_PREV_BUTTON_SAMPLES)

def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
if self.CP.carName in ('body', 'mock'):
if self.CP.brand in ('body', 'mock'):
events = Events()

elif self.CP.carName in ('subaru', 'mazda'):
elif self.CP.brand in ('subaru', 'mazda'):
events = self.create_common_events(CS, CS_prev)

elif self.CP.carName == 'ford':
elif self.CP.brand == 'ford':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.manumatic])

elif self.CP.carName == 'nissan':
elif self.CP.brand == 'nissan':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.brake])

elif self.CP.carName == 'chrysler':
elif self.CP.brand == 'chrysler':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.low])

# Low speed steer alert hysteresis logic
Expand All @@ -65,7 +65,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
if self.low_speed_alert:
events.add(EventName.belowSteerSpeed)

elif self.CP.carName == 'honda':
elif self.CP.brand == 'honda':
events = self.create_common_events(CS, CS_prev, pcm_enable=False)

if self.CP.pcmCruise and CS.vEgo < self.CP.minEnableSpeed:
Expand All @@ -86,7 +86,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
if self.CP.minEnableSpeed > 0 and CS.vEgo < 0.001:
events.add(EventName.manualRestart)

elif self.CP.carName == 'toyota':
elif self.CP.brand == 'toyota':
events = self.create_common_events(CS, CS_prev)

if self.CP.openpilotLongitudinalControl:
Expand All @@ -101,7 +101,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
# while in standstill, send a user alert
events.add(EventName.manualRestart)

elif self.CP.carName == 'gm':
elif self.CP.brand == 'gm':
# The ECM allows enabling on falling edge of set, but only rising edge of resume
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.sport, GearShifter.low,
GearShifter.eco, GearShifter.manumatic],
Expand All @@ -120,7 +120,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
if CS.vEgo < self.CP.minSteerSpeed:
events.add(EventName.belowSteerSpeed)

elif self.CP.carName == 'volkswagen':
elif self.CP.brand == 'volkswagen':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],
pcm_enable=self.CP.pcmCruise,
enable_buttons=(ButtonType.setCruise, ButtonType.resumeCruise))
Expand All @@ -143,7 +143,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
# if CC.eps_timer_soft_disable_alert: # type: ignore[attr-defined]
# events.add(EventName.steerTimeLimit)

elif self.CP.carName == 'hyundai':
elif self.CP.brand == 'hyundai':
# On some newer model years, the CANCEL button acts as a pause/resume button based on the PCM state
# To avoid re-engaging when openpilot cancels, check user engagement intention via buttons
# Main button also can trigger an engagement on these cars
Expand All @@ -160,7 +160,7 @@ def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl):
events.add(EventName.belowSteerSpeed)

else:
raise ValueError(f"Unsupported car: {self.CP.carName}")
raise ValueError(f"Unsupported car: {self.CP.brand}")

return events

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def state_update(self) -> tuple[car.CarState, structs.RadarDataT | None]:

# Update carState from CAN
CS = self.CI.update(can_list)
if self.CP.carName == 'mock':
if self.CP.brand == 'mock':
CS = self.mock_carstate.update(CS)

# Update radar tracks from CAN
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ def test_panda_safety_carstate_fuzzy(self, data):
if self.safety.get_vehicle_moving() != prev_panda_vehicle_moving:
self.assertEqual(not CS.standstill, self.safety.get_vehicle_moving())

if not (self.CP.carName == "honda" and not (self.CP.flags & HondaFlags.BOSCH)):
if not (self.CP.brand == "honda" and not (self.CP.flags & HondaFlags.BOSCH)):
if self.safety.get_cruise_engaged_prev() != prev_panda_cruise_engaged:
self.assertEqual(CS.cruiseState.enabled, self.safety.get_cruise_engaged_prev())

if self.CP.carName == "honda":
if self.CP.brand == "honda":
if self.safety.get_acc_main_on() != prev_panda_acc_main_on:
self.assertEqual(CS.cruiseState.available, self.safety.get_acc_main_on())

Expand Down Expand Up @@ -421,7 +421,7 @@ def test_panda_safety_carstate(self):
# On most pcmCruise cars, openpilot's state is always tied to the PCM's cruise state.
# On Honda Nidec, we always engage on the rising edge of the PCM cruise state, but
# openpilot brakes to zero even if the min ACC speed is non-zero (i.e. the PCM disengages).
if self.CP.carName == "honda" and not (self.CP.flags & HondaFlags.BOSCH):
if self.CP.brand == "honda" and not (self.CP.flags & HondaFlags.BOSCH):
# only the rising edges are expected to match
if CS.cruiseState.enabled and not CS_prev.cruiseState.enabled:
checks['controlsAllowed'] += not self.safety.get_controls_allowed()
Expand All @@ -443,7 +443,7 @@ def test_panda_safety_carstate(self):
if button_enable and not mismatch:
self.safety.set_controls_allowed(False)

if self.CP.carName == "honda":
if self.CP.brand == "honda":
checks['mainOn'] += CS.cruiseState.available != self.safety.get_acc_main_on()

CS_prev = CS
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/plannerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():
cloudlog.info("plannerd is waiting for CarParams")
params = Params()
CP = messaging.log_from_bytes(params.get("CarParams", block=True), car.CarParams)
cloudlog.info("plannerd got CarParams: %s", CP.carName)
cloudlog.info("plannerd got CarParams: %s", CP.brand)

ldw = LaneDepartureWarning()
longitudinal_planner = LongitudinalPlanner(CP)
Expand Down
11 changes: 0 additions & 11 deletions selfdrive/debug/adb.sh

This file was deleted.

27 changes: 15 additions & 12 deletions selfdrive/locationd/locationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
MAX_FILTER_REWIND_TIME = 0.8 # s
MAX_SENSOR_TIME_DIFF = 0.1 # s
YAWRATE_CROSS_ERR_CHECK_FACTOR = 30
INPUT_INVALID_THRESHOLD = 0.5 # 0 bad inputs ignored
TIMING_INVALID_THRESHOLD = 2.5 # 2 bad timings ignored
INPUT_INVALID_DECAY = 0.9993 # ~10 secs to resume after exceeding allowed bad inputs by one (at 100hz)
TIMING_INVALID_DECAY = 0.9990 # ~2 secs to resume after exceeding allowed bad timings by one (at 100hz)
INPUT_INVALID_LIMIT = 2.0 # 1 (camodo) / 9 (sensor) bad input[s] ignored
INPUT_INVALID_RECOVERY = 10.0 # ~10 secs to resume after exceeding allowed bad inputs by one
POSENET_STD_INITIAL_VALUE = 10.0
POSENET_STD_HIST_HALF = 20


def calculate_invalid_input_decay(invalid_limit, recovery_time, frequency):
return (1 - 1 / (2 * invalid_limit)) ** (1 / (recovery_time * frequency))


def init_xyz_measurement(measurement: capnp._DynamicStructBuilder, values: np.ndarray, stds: np.ndarray, valid: bool):
assert len(values) == len(stds) == 3
measurement.x, measurement.y, measurement.z = map(float, values)
Expand Down Expand Up @@ -269,11 +271,11 @@ def main():

filter_initialized = False
critcal_services = ["accelerometer", "gyroscope", "cameraOdometry"]
observation_timing_invalid = defaultdict(int)
observation_input_invalid = defaultdict(int)

input_invalid_decay = {s: INPUT_INVALID_DECAY ** (100. / SERVICE_LIST[s].frequency) for s in critcal_services}
timing_invalid_decay = {s: TIMING_INVALID_DECAY ** (100. / SERVICE_LIST[s].frequency) for s in critcal_services}
input_invalid_limit = {s: round(INPUT_INVALID_LIMIT * (SERVICE_LIST[s].frequency / 20.)) for s in critcal_services}
input_invalid_threshold = {s: input_invalid_limit[s] - 0.5 for s in critcal_services}
input_invalid_decay = {s: calculate_invalid_input_decay(input_invalid_limit[s], INPUT_INVALID_RECOVERY, SERVICE_LIST[s].frequency) for s in critcal_services}

initial_pose = params.get("LocationFilterInitialState")
if initial_pose is not None:
Expand Down Expand Up @@ -306,19 +308,20 @@ def main():
continue

if res == HandleLogResult.TIMING_INVALID:
observation_timing_invalid[which] += 1
print(f"Observation {which} ignored due to failed timing check")
observation_input_invalid[which] += 1
print(observation_input_invalid[which])
elif res == HandleLogResult.INPUT_INVALID:
print(f"Observation {which} ignored due to failed sanity check")
observation_input_invalid[which] += 1
else:
observation_input_invalid[which] *= input_invalid_decay[which]
observation_timing_invalid[which] *= timing_invalid_decay[which]
else:
filter_initialized = sm.all_checks() and sensor_all_checks(acc_msgs, gyro_msgs, sensor_valid, sensor_recv_time, sensor_alive, SIMULATION)

if sm.updated["cameraOdometry"]:
critical_service_inputs_valid = all(observation_input_invalid[s] < INPUT_INVALID_THRESHOLD for s in critcal_services)
critical_service_timing_valid = all(observation_timing_invalid[s] < TIMING_INVALID_THRESHOLD for s in critcal_services)
inputs_valid = sm.all_valid() and critical_service_inputs_valid and critical_service_timing_valid
critical_service_inputs_valid = all(observation_input_invalid[s] < input_invalid_threshold[s] for s in critcal_services)
inputs_valid = sm.all_valid() and critical_service_inputs_valid
sensors_valid = sensor_all_checks(acc_msgs, gyro_msgs, sensor_valid, sensor_recv_time, sensor_alive, SIMULATION)

msg = estimator.get_msg(sensors_valid, inputs_valid, filter_initialized)
Expand Down
56 changes: 0 additions & 56 deletions selfdrive/locationd/test/test_locationd.py

This file was deleted.

Loading

0 comments on commit e69fa77

Please sign in to comment.