#!/usr/bin/env python3
import sys
import subprocess
from azure . storage . blob import BlockBlobService # pylint: disable=import-error
from selfdrive . car . tests . routes import routes as test_car_models_routes
Live torque (#25456)
* wip torqued
* add basic logic
* setup in manager
* check sanity and publish msg
* add first order filter to outputs
* wire up controlsd, and update gains
* rename intercept to offset
* add cloudlog, live values are not updated
* fix bugs, do not reset points for now
* fix crashes
* rename to main
* fix bugs, works offline
* fix float in cereal bug
* add latacc filter
* randomly choose points, approx for iid
* add variable decay
* local param to capnp instead of dict
* verify works in replay
* use torqued output in controlsd
* use in controlsd; use points from past routes
* controlsd bugfix
* filter before updating gains, needs to be replaced
* save all points to ensure smooth transition across routes, revert friction factor to 1.5
* add filters to prevent noisy low-speed data points; improve fit sanity
* add engaged buffer
* revert lat_acc thresh
* use paramsd realtime process config
* make latacc-to-torque generic, and overrideable
* move freq to 4Hz, avoid storing in np.array, don't publish points in the message
* float instead of np
* remove constant while storing pts
* rename slope, offset to lat_accet_factor, offset
* resolve issues
* use camelcase in all capnp params
* use camelcase everywhere
* reduce latacc threshold or sanity, add car_sane todo, save points properly
* add and check tag
* write param to disk at end of route
* remove args
* rebase op, cereal
* save on exit
* restore default handler
* cpu usage check
* add to process replay
* handle reset better, reduce unnecessary computation
* always publish raw values - useful for debug
* regen routes
* update refs
* checks on cache restore
* check tuning vals too
* clean that up
* reduce cpu usage
* reduce cpu usage by 75%
* cleanup
* optimize further
* handle reset condition better, don't put points in init, use only in corolla
* bump cereal after rebasing
* update refs
* Update common/params.cc
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
* remove unnecessary checks
* Update RELEASES.md
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
3 years ago
from selfdrive . test . process_replay . test_processes import source_segments as replay_segments
from xx . chffr . lib import azureutil # pylint: disable=import-error
from xx . chffr . lib . storage import _DATA_ACCOUNT_PRODUCTION , _DATA_ACCOUNT_CI , _DATA_BUCKET_PRODUCTION # pylint: disable=import-error
SOURCES = [
( _DATA_ACCOUNT_PRODUCTION , _DATA_BUCKET_PRODUCTION ) ,
( _DATA_ACCOUNT_PRODUCTION , " preserve " ) ,
( _DATA_ACCOUNT_CI , " commadataci " ) ,
]
def get_azure_keys ( ) :
dest_key = azureutil . get_user_token ( _DATA_ACCOUNT_CI , " openpilotci " )
source_keys = [ azureutil . get_user_token ( account , bucket ) for account , bucket in SOURCES ]
service = BlockBlobService ( _DATA_ACCOUNT_CI , sas_token = dest_key )
return dest_key , source_keys , service
def upload_route ( path , exclude_patterns = None ) :
dest_key , _ , _ = get_azure_keys ( )
if exclude_patterns is None :
exclude_patterns = [ ' */dcamera.hevc ' ]
r , n = path . rsplit ( " -- " , 1 )
r = ' / ' . join ( r . split ( ' / ' ) [ - 2 : ] ) # strip out anything extra in the path
destpath = f " { r } / { n } "
cmd = [
" azcopy " ,
" copy " ,
f " { path } /* " ,
f " https:// { _DATA_ACCOUNT_CI } .blob.core.windows.net/openpilotci/ { destpath } ? { dest_key } " ,
" --recursive=false " ,
" --overwrite=false " ,
] + [ f " --exclude-pattern= { p } " for p in exclude_patterns ]
subprocess . check_call ( cmd )
def sync_to_ci_public ( route ) :
dest_key , source_keys , service = get_azure_keys ( )
key_prefix = route . replace ( ' | ' , ' / ' )
dongle_id = key_prefix . split ( ' / ' ) [ 0 ]
if next ( azureutil . list_all_blobs ( service , " openpilotci " , prefix = key_prefix ) , None ) is not None :
return True
print ( f " Uploading { route } " )
for ( source_account , source_bucket ) , source_key in zip ( SOURCES , source_keys ) :
print ( f " Trying { source_account } / { source_bucket } " )
cmd = [
" azcopy " ,
" copy " ,
f " https:// { source_account } .blob.core.windows.net/ { source_bucket } / { key_prefix } ? { source_key } " ,
f " https:// { _DATA_ACCOUNT_CI } .blob.core.windows.net/openpilotci/ { dongle_id } ? { dest_key } " ,
" --recursive=true " ,
" --overwrite=false " ,
" --exclude-pattern=*/dcamera.hevc " ,
]
try :
result = subprocess . call ( cmd , stdout = subprocess . DEVNULL )
if result == 0 :
print ( " Success " )
return True
except subprocess . CalledProcessError :
print ( " Failed " )
return False
if __name__ == " __main__ " :
failed_routes = [ ]
to_sync = sys . argv [ 1 : ]
if not len ( to_sync ) :
# sync routes from the car tests routes and process replay
to_sync . extend ( [ rt . route for rt in test_car_models_routes ] )
to_sync . extend ( [ s [ 1 ] . rsplit ( ' -- ' , 1 ) [ 0 ] for s in replay_segments ] )
for r in to_sync :
if not sync_to_ci_public ( r ) :
failed_routes . append ( r )
if len ( failed_routes ) :
print ( " failed routes: " , failed_routes )