Skip to content

Commit 4536719

Browse files
authored
longitudinal_planner: Convert self.mode to a local variable in update() (commaai#35999)
Make 'mode' variable local
1 parent b54d599 commit 4536719

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

selfdrive/controls/lib/longitudinal_planner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def parse_model(model_msg):
9090
return x, v, a, j, throttle_prob
9191

9292
def update(self, sm):
93-
self.mode = 'blended' if sm['selfdriveState'].experimentalMode else 'acc'
93+
mode = 'blended' if sm['selfdriveState'].experimentalMode else 'acc'
9494

9595
if len(sm['carControl'].orientationNED) == 3:
9696
accel_coast = get_coast_accel(sm['carControl'].orientationNED[1])
@@ -113,7 +113,7 @@ def update(self, sm):
113113
# No change cost when user is controlling the speed, or when standstill
114114
prev_accel_constraint = not (reset_state or sm['carState'].standstill)
115115

116-
if self.mode == 'acc':
116+
if mode == 'acc':
117117
accel_clip = [ACCEL_MIN, get_max_accel(v_ego)]
118118
steer_angle_without_offset = sm['carState'].steeringAngleDeg - sm['liveParameters'].angleOffsetDeg
119119
accel_clip = limit_accel_in_turns(v_ego, steer_angle_without_offset, accel_clip, self.CP)
@@ -163,7 +163,7 @@ def update(self, sm):
163163
output_a_target_e2e = sm['modelV2'].action.desiredAcceleration
164164
output_should_stop_e2e = sm['modelV2'].action.shouldStop
165165

166-
if self.mode == 'acc':
166+
if mode == 'acc':
167167
output_a_target = output_a_target_mpc
168168
self.output_should_stop = output_should_stop_mpc
169169
else:

0 commit comments

Comments
 (0)