GithubHelp home page GithubHelp logo

opparams's Introduction

opParams parameter manager

This repo is just a backup of op_params. To install into your own fork, just grab the files in the openpilot folder and place them into your repository in their respective directories.

  1. Make sure you add your new parameter to op_params.py filling out the default, allowed_types, and live keys. (Update: allowed types, description, and live are no longer required but recommended if you want to give your users the ability to change parameters safely and easily. Live is assumed to be False by default if not specified. default is still required!)
    • You can also change the read, or update frequency in that file for live tuning.
  2. In the file you want to receive updates, use this code in place of the variable you want to use.
    • So for camera offset, we can do this in lane_planner.py:
    from common.op_params import opParams
    op_params = opParams()
    CAMERA_OFFSET = op_params.get('camera_offset')
  3. Param class arguments explaination:
    • Param(1., NUMBER): No matter how often you use opParams's .get() function on this param, it will update only once per 10 seconds (customizable in the base Param class).
    • Param(1., NUMBER, live=True): Same thing as above, but the update frequency is reduced to 1 second. It also will show up in opEdit in the special live! menu.
    • Param(False, bool, static=True): Only specifying static=True tells opParams to never refresh its value from the file it's stored in. Great for a toggle used on openpilot startup. It's only read on opParams initialization.
  4. Important: for variables you want to be live tunable, you need to use the op_params.get() function to set the variable on each update. So for example, with classes, you need to initialize opParams and the variable in the __init__ function, and then in the class's update function, set it again at the top. Here's a fake example for longcontrol.py:
from common.op_params import opParams


class LongControl():
  def __init__():
    self.op_params = opParams()  # always init opParams first
    self.your_live_tunable_variable = self.op_params.get('whatever_param')  # initializes the variable
  
  def update(stuff...):
    self.your_live_tunable_variable = self.op_params.get('whatever_param')  # and this updates it as you tune. will not update live if you don't occasionally call .get() on your parameter.
    
    # then we use the variable down here...
  1. Now to change live parameters over ssh, you can connect to your EON with your WiFi hotspot, then change directory to /data/openpilot and run python op_edit.py (which now fully supports live tuning). It's important to make sure you set 'live' to True for any parameters you want to be live.
    • Here's an old gif of the tuner:

opparams's People

Contributors

sshane avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

opparams's Issues

Remove the outdated kegman.json restoration

Remove the outdated kegman.json restoration when a new user uses a fork with op_params. This causes op_params.json to house a bunch of parameters that are unsupported and unneeded in the current fork that is using op_params

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.