Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 42de3e4

Browse files
authoredSep 23, 2020
Add update_behavior param to control how SA updates (commaai#238)
* add standstill_hack param to readme * change auto_update to update_behavior * safety check * at least 10 percent sim * at least 20 percent sim * debug * 1/3 * remove debug * remove debug * debug * debug * this looks pretty cool * change * final changes * final changes
1 parent 86190e8 commit 42de3e4

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed
 

‎README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ Here are the main parameters you can change with this fork:
131131
- `camera_offset` **`(live!)`**: Your camera offset to use in lane_planner.py. Helps fix lane hugging
132132
- `steer_ratio` **`(live!)`**: The steering ratio you want to use with openpilot. If you enter None, it will use the learned steer ratio from openpilot instead
133133
- [`enable_long_derivative`](#pi---pid-controller-for-long-and-lat): This enables derivative-based integral wind-down to help overshooting within the PID loop. Useful for Toyotas with pedals or cars with bad long tuning
134+
`standstill_hack`: Some cars support stop and go, you just need to enable this
134135
- **General fork params**:
135136
- `alca_nudge_required`: Whether to wait for applied torque to the wheel (nudge) before making lane changes
136137
- `alca_min_speed`: The minimum speed allowed for an automatic lane change
137138
- `upload_on_hotspot`: Controls whether your EON will upload driving data on your phone's hotspot
138-
- [`auto_update`](#Automatic-updates): Toggles whether your device will update and reboot automatically on this fork
139+
- [`update_behavior`](#Automatic-updates): off will never update, alert shows an alert on-screen. auto will reboot the device when an update is seen
139140
- `disengage_on_gas`: Whether you want openpilot to disengage on gas input or not
140141
- **Dynamic params**:
141142
- `dynamic_gas`: Whether to use [dynamic gas](#dynamic-gas) if your car is supported
@@ -164,6 +165,7 @@ Parameters are stored at `/data/op_params.json`
164165
### Automatic updates
165166
When a new update is available on GitHub for Stock Additions, your EON/C2 will pull and reset your local branch to the remote. It then queues a reboot to occur when the following is true:
166167
- your EON has been inactive or offroad for more than 5 minutes
168+
- `update_behavior` param is set to `auto`
167169

168170
Therefore, if your device sees an update while you're driving it will reboot approximately 5 to 10 minutes after you finish your drive, it resets the timer if you start driving again before the time is up.
169171

‎SA_RELEASES.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Stock Additions v0.5.3 - 2020-9-15 (0.7.7)
33
* Properly set unsafe_mode in boardd. This might fix panda flashing issues for new users, since it won't be required
44
* Separate 2020 Prius and add PID tune
55
* Add param `standstill_hack` for stop and go hack
6+
* Add param `update_behavior` to change how SA updates. off never updates, auto reboots if there's an update, and alert shows a button offroad with changelog
67

78
Stock Additions v0.5.2 - 2020-9-11 (0.7.7)
89
===

‎common/op_params.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def __init__(self):
8181
'enable_long_derivative': Param(False, bool, 'If you have longitudinal overshooting, enable this! This enables derivative-based\n'
8282
'integral wind-down to help reduce overshooting within the long PID loop'),
8383
'disengage_on_gas': Param(True, bool, 'Whether you want openpilot to disengage on gas input or not'),
84-
'auto_update': Param(False, bool, 'Toggles whether your device will update and reboot automatically on this fork'),
84+
'update_behavior': Param('auto', str, 'Can be: (\'off\', \'alert\', \'auto\') without quotes\n'
85+
'off will never update, alert shows an alert on-screen\n'
86+
'auto will reboot the device when an update is seen'),
8587
'dynamic_gas': Param(True, bool, 'Whether to use dynamic gas if your car is supported'),
8688
'hide_auto_df_alerts': Param(False, bool, 'Hides the alert that shows what profile the model has chosen'),
8789
'log_auto_df': Param(False, bool, 'Logs dynamic follow data for auto-df'),
@@ -99,7 +101,7 @@ def __init__(self):
99101
self._backup_file = '/data/op_params_corrupt.json'
100102
self._last_read_time = sec_since_boot()
101103
self.read_frequency = 2.5 # max frequency to read with self.get(...) (sec)
102-
self._to_delete = ['lane_hug_direction', 'lane_hug_angle_offset', 'prius_use_lqr', 'no_ota_updates'] # a list of params you want to delete (unused)
104+
self._to_delete = ['no_ota_updates', 'auto_update'] # a list of unused params you want to delete
103105
self._run_init() # restores, reads, and updates params
104106

105107
def _run_init(self): # does first time initializing of default params

‎op_edit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def parse_choice(self, choice, opt_len):
130130
return 'exit', choice
131131
else: # find most similar param to user's input
132132
param_sims = [(idx, self.str_sim(choice, param.lower())) for idx, param in enumerate(self.params)]
133-
param_sims = [param for param in param_sims if param[1] > 0.5]
133+
param_sims = [param for param in param_sims if param[1] > 0.33]
134134
if len(param_sims) > 0:
135135
chosen_param = sorted(param_sims, key=lambda param: param[1], reverse=True)[0]
136136
return 'change', chosen_param[0] # return idx

‎selfdrive/manager.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515

1616
from common.basedir import BASEDIR, PARAMS
1717
from common.android import ANDROID
18+
from common.op_params import opParams
1819
WEBCAM = os.getenv("WEBCAM") is not None
1920
sys.path.append(os.path.join(BASEDIR, "pyextra"))
2021
os.environ['BASEDIR'] = BASEDIR
2122

2223
TOTAL_SCONS_NODES = 1020
2324
prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt'))
25+
kill_updated = opParams().get('update_behavior').lower().strip() == 'off' or os.path.exists('/data/no_ota_updates')
2426

2527
# Create folders needed for msgq
2628
try:
@@ -228,9 +230,11 @@ def get_running():
228230
persistent_processes += [
229231
'logcatd',
230232
'tombstoned',
231-
'updated',
233+
# 'updated',
232234
'deleter',
233235
]
236+
if not kill_updated:
237+
persistent_processes.append('updated')
234238

235239
car_started_processes = [
236240
'controlsd',

‎selfdrive/updated.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from common.op_params import opParams
4444

4545
STAGING_ROOT = "/data/safe_staging"
46+
REBOOT_ON_UPDATE = opParams().get('update_behavior').lower().strip() == 'auto' # if not auto, has to be alert
4647

4748
OVERLAY_UPPER = os.path.join(STAGING_ROOT, "upper")
4849
OVERLAY_METADATA = os.path.join(STAGING_ROOT, "metadata")
@@ -57,9 +58,6 @@
5758
ffi.cdef("int link(const char *oldpath, const char *newpath);")
5859
libc = ffi.dlopen(None)
5960

60-
op_params = opParams()
61-
auto_update = op_params.get('auto_update') and not os.path.exists('/data/no_ota_updates')
62-
6361
class WaitTimeHelper:
6462
ready_event = threading.Event()
6563
shutdown = False
@@ -321,12 +319,11 @@ def attempt_update(time_offroad, need_reboot):
321319

322320

323321
def auto_update_reboot(time_offroad, need_reboot, new_version):
324-
if not auto_update:
322+
if not REBOOT_ON_UPDATE:
325323
return False
326324

327325
min_reboot_time = 5. * 60
328-
if new_version:
329-
need_reboot = True
326+
need_reboot |= new_version
330327

331328
if need_reboot:
332329
if sec_since_boot() - time_offroad > min_reboot_time:

0 commit comments

Comments
 (0)
Please sign in to comment.