Skip to content

Commit 7a6b569

Browse files
committed
hackily log conditions
1 parent e583d6e commit 7a6b569

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

selfdrive/controls/controlsd.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def state_control(self, CS):
503503
if not self.joystick_mode:
504504
# accel PID loop
505505
pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_kph * CV.KPH_TO_MS)
506-
actuators.accel = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits)
506+
actuators.accel, stopping, starting = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits)
507507

508508
# Steering PID loop and lateral MPC
509509
lat_active = self.active and not CS.steerWarning and not CS.steerError and CS.vEgo > self.CP.minSteerSpeed
@@ -513,6 +513,8 @@ def state_control(self, CS):
513513
lat_plan.curvatureRates)
514514
actuators.steer, actuators.steeringAngleDeg, lac_log = self.LaC.update(lat_active, CS, self.CP, self.VM, params, self.last_actuators,
515515
desired_curvature, desired_curvature_rate)
516+
lac_log.saturated = starting
517+
lac_log.active = stopping
516518
else:
517519
lac_log = log.ControlsState.LateralDebugState.new_message()
518520
if self.sm.rcv_frame['testJoystick'] > 0 and self.active:
@@ -537,17 +539,17 @@ def state_control(self, CS):
537539
self.saturated_count = 0
538540

539541
# Send a "steering required alert" if saturation count has reached the limit
540-
if (lac_log.saturated and not CS.steeringPressed) or \
541-
(self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT):
542-
543-
if len(lat_plan.dPathPoints):
544-
# Check if we deviated from the path
545-
# TODO use desired vs actual curvature
546-
left_deviation = actuators.steer > 0 and lat_plan.dPathPoints[0] < -0.20
547-
right_deviation = actuators.steer < 0 and lat_plan.dPathPoints[0] > 0.20
548-
549-
if left_deviation or right_deviation:
550-
self.events.add(EventName.steerSaturated)
542+
# if (lac_log.saturated and not CS.steeringPressed) or \
543+
# (self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT):
544+
#
545+
# if len(lat_plan.dPathPoints):
546+
# # Check if we deviated from the path
547+
# # TODO use desired vs actual curvature
548+
# left_deviation = actuators.steer > 0 and lat_plan.dPathPoints[0] < -0.20
549+
# right_deviation = actuators.steer < 0 and lat_plan.dPathPoints[0] > 0.20
550+
#
551+
# if left_deviation or right_deviation:
552+
# self.events.add(EventName.steerSaturated)
551553

552554
# Ensure no NaNs/Infs
553555
for p in ACTUATOR_FIELDS:

selfdrive/controls/lib/longcontrol.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def long_control_state_trans(CP, active, long_control_state, v_ego, v_target_fut
4444
elif output_accel >= CP.startAccel:
4545
long_control_state = LongCtrlState.pid
4646

47-
return long_control_state
47+
return long_control_state, stopping_condition, starting_condition
4848

4949

5050
class LongControl():
@@ -89,9 +89,9 @@ def update(self, active, CS, CP, long_plan, accel_limits):
8989

9090
# Update state machine
9191
output_accel = self.last_output_accel
92-
self.long_control_state = long_control_state_trans(CP, active, self.long_control_state, CS.vEgo,
93-
v_target_future, v_target, output_accel,
94-
CS.brakePressed, CS.cruiseState.standstill)
92+
self.long_control_state, stopping, starting = long_control_state_trans(CP, active, self.long_control_state, CS.vEgo,
93+
v_target_future, v_target, output_accel,
94+
CS.brakePressed, CS.cruiseState.standstill)
9595

9696
if self.long_control_state == LongCtrlState.off or CS.gasPressed:
9797
self.reset(CS.vEgo)
@@ -129,4 +129,4 @@ def update(self, active, CS, CP, long_plan, accel_limits):
129129
self.last_output_accel = output_accel
130130
final_accel = clip(output_accel, accel_limits[0], accel_limits[1])
131131

132-
return final_accel
132+
return final_accel, stopping, starting

0 commit comments

Comments
 (0)