Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Add support for opParams()['param_name'] (commaai#242)
Browse files Browse the repository at this point in the history
* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* clean up

* add simple op_params

* here's how op_params.camera_offset() would work

* clean up

* clean up

* add live

* clean up
  • Loading branch information
sshane committed Oct 2, 2020
1 parent ac51cec commit 55b6ef3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/op_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self):
- Finally, the live arg tells both opParams and opEdit that it's a live parameter that will change. Therefore, you must place the `op_params.get()` call in the update function so that it can update.
Here's an example of a good fork_param entry:
self.fork_params = {'camera_offset': Param(default=0.06, allowed_types=VT.number)} # VT.number allows both floats and ints
self.fork_params = {'camera_offset': Param(default=0.06, allowed_types=VT.number), live=True} # VT.number allows both floats and ints
"""

VT = ValueTypes()
Expand Down Expand Up @@ -152,6 +152,9 @@ def put(self, key, value):
self.params.update({key: value})
self._write()

def __getitem__(self, s): # can also do op_params['param_name']
return self.get(s)

def delete(self, key): # todo: might be obsolete. remove?
if key in self.params:
del self.params[key]
Expand Down

0 comments on commit 55b6ef3

Please sign in to comment.