Avatar

Avatar class
short_sha = repo.git.rev_parse(repo.head.commit.hexsha, short=7)
repo.head.commit.author.name
repo.head.commit.message
'[add] generated code back\n\nfor CI\n'

gpus = tf.config.experimental.list_physical_devices(‘GPU’) tf.config.experimental.set_memory_growth(gpus[0], True)

os.environ[“CUDA_VISIBLE_DEVICES”] = “-1” os.environ[“TF_FORCE_GPU_ALLOW_GROWTH”] = “true”

system warnings and numpy warnings handling np.warnings.filterwarnings(‘ignore’, category=DeprecationWarning)


source

Avatar

 Avatar (_truck:Union[tspace.config.vehicles.TruckInField,tspace.config.ve
         hicles.TruckInCloud], _driver:tspace.config.drivers.Driver,
         _can_server:tspace.config.messengers.CANMessenger,
         _trip_server:Optional[tspace.config.messengers.TripMessenger],
         _agent:tspace.agent.dpg.DPG, logger:logging.Logger,
         dict_logger:dict, vehicle_interface:Union[tspace.dataflow.kvaser.
         Kvaser,tspace.dataflow.cloud.Cloud]=None, _resume:bool=True,
         _infer_mode:bool=False,
         cruncher:Optional[tspace.dataflow.cruncher.Cruncher]=None,
         data_root:pathlib.Path=Path('data'),
         log_root:Optional[pathlib.Path]=None)

*Description: Implement realtime reinforcement learning algorithm for training and inference convergence of ddpg and rdpg agent

Args:

_truck: TruckInField or TruckInCloud
_driver: Driver
_agent: DDPG or RDPG
_can_server: CANMessenger
_trip_server: TripMessenger
_resume: bool
_infer_mode: bool
logger: logging.Logger
dict_logger: dict
data_root: Path
log_root: Optional[Path]*

source

Avatar.__post_init__

 Avatar.__post_init__ ()

*Initialize logging, vehicle interface (Kvaser or Cloud), cruncher.

Agent should have been initialized and passed in as argument.*

class C:
    pass


c = C()
# parser.parse_args(args=['-v', 'VB7_FIELD'], namespace=c)
# parser.parse_args(args=['-d', 'wang-kai'], namespace=c)
# parser.parse_args(args=['-i', 'can_udp_svc'], namespace=c)
# parser.parse_args(args=['-t', 'local_udp'], namespace=c)
# parser.parse_args(args=['-c', 'UDP'], namespace=c)
# parser.parse_args(args=['-a', 'ddpg'], namespace=c)
# parser.parse_args(args=['-r'], namespace=c)
# parser.parse_args(args=['-l'], namespace=c)
# parser.parse_args(args=['-p', '.'], namespace=c)
# parser.parse_args(args=['-o', 'mongo_local'], namespace=c)
args = parser.parse_args(
    args=['-v', 'VB7_FIELD', 
    '-d', 'wang-kai', 
    '-i', 'can_udp_svc', 
    '-t', 'local_udp', 
    '-c', 'UDP', 
    '-a', 'ddpg', 
    '-l', 
    '-p', '.', 
    '-o', 'mongo_local', 
    '--watchdog_nap_time', '10', # test with 10 seconds nap time
    '--watchdog_capture_error_upper_bound', '1',  # test with 1 failuire, since no hardware is connected
    '--watchdog_flash_error_upper_bound', '1' ], namespace=c)    # test with 1 failuire, since no hardware is connected
#| output: true
args.__dict__
{'vehicle': 'VB7_FIELD',
 'driver': 'wang-kai',
 'interface': 'can_udp_svc',
 'trip': 'local_udp',
 'control': 'UDP',
 'agent': 'ddpg',
 'resume': False,
 'learning': True,
 'path': '.',
 'output': 'mongo_local',
 'watchdog_nap_time': '10',
 'watchdog_capture_error_upper_bound': '1',
 'watchdog_flash_error_upper_bound': '1'}

source

main

 main (args:argparse.Namespace)

*Description: main function to start the Avatar.

Initialize the Avatar with truck, driver, can server, trip server, and agent for input arguments. Create the first tier of the cascaded threading pools for vehicle interface and crucher.*

!pwd
/Users/x/devel/tspace/nbs
!cp ../tspace/res/tbox/xcp_driver/json/example.json /dev/shm/out.json
cp: ../tspace/res/tbox/xcp_driver/json/example.json: No such file or directory
#main(args)