Пример #1
0
def op_edit():  # use by running `python /data/openpilot/op_edit.py`
    op_params = opParams()
    params = op_params.params
    print('Welcome to the opParams command line editor!')
    print('Here are your parameters:\n')
    values_list = [
        params[i] if len(str(params[i])) < 20 else '{} ... {}'.format(
            str(params[i])[:30],
            str(params[i])[-15:]) for i in params
    ]
    while True:
        print('\n'.join([
            '{}. {}: {} ({})'.format(idx + 1, i, values_list[idx],
                                     str(type(params[i]))[7:-2])
            for idx, i in enumerate(params)
        ]))
        print('\nChoose a parameter to edit (by index): ')
        choice = raw_input('>> ')
        try:
            choice = int(choice)
        except:
            print('Not an integer, exiting!')
            return
        if choice not in range(1, len(params) + 1):
            print('Not in range!\n')
            continue
        chosen_key = list(params)[choice - 1]
        old_value = params[chosen_key]
        print('Chosen parameter: {}'.format(chosen_key))
        print('Enter your new value:')
        new_value = raw_input('>> ')
        try:
            new_value = ast.literal_eval(new_value)
            print('New value: {} ({})\nOld value: {} ({})'.format(
                new_value,
                str(type(new_value))[7:-2], old_value,
                str(type(old_value))[7:-2]))
            print('Do you want to save this?')
            choice = raw_input('[Y/n]: ').lower()
            if choice == 'y':
                op_params.put(chosen_key, new_value)
                print('Saved! Anything else?')
                choice = raw_input('[Y/n]: ').lower()
                if choice == 'n':
                    return
            else:
                print('Did not save that...\n')
        except:
            print('Cannot parse input, exiting!')
            break
Пример #2
0
from cereal import arne182
from common.params import Params
from common.numpy_fast import interp

import selfdrive.messaging as messaging
from cereal import car
from common.realtime import sec_since_boot, DT_PLAN
from selfdrive.swaglog import cloudlog
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.speed_smoother import speed_smoother
from selfdrive.controls.lib.longcontrol import LongCtrlState, MIN_CAN_SPEED
from selfdrive.controls.lib.fcw import FCWChecker
from selfdrive.controls.lib.long_mpc import LongitudinalMpc
from selfdrive.op_params import opParams

op_params = opParams()
offset = op_params.get('speed_offset', 0)  # m/s
osm = op_params.get('osm', True)

NO_CURVATURE_SPEED = 90.0

MAX_SPEED = 255.0

LON_MPC_STEP = 0.2  # first step is 0.2s
MAX_SPEED_ERROR = 2.0
AWARENESS_DECEL = -0.2  # car smoothly decel at .2m/s^2 when user is distracted

# lookup tables VS speed to determine min and max accels in cruise
# make sure these accelerations are smaller than mpc limits
_A_CRUISE_MIN_V = [-0.8, -0.7, -0.6, -0.5, -0.3]
_A_CRUISE_MIN_BP = [0.0, 5.0, 10.0, 20.0, 55.0]