-
Notifications
You must be signed in to change notification settings - Fork 6
/
motec_to_pickle.py
62 lines (51 loc) · 2.26 KB
/
motec_to_pickle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import sys
import logging
from pathlib import Path
import argparse
from omegaconf import OmegaConf
# Custom module imports
sys.path.append(os.path.abspath('./assetto_corsa_gym'))
import AssettoCorsaEnv.ac_env as ac_env
import AssettoCorsaEnv.motec_loader as motec_loader
import AssettoCorsaEnv.data_loader as data_loader
import AssettoCorsaEnv.assettoCorsa as assettoCorsa
def setup_logging():
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
)
def parse_arguments():
parser = argparse.ArgumentParser(description="Process dataset for Assetto Corsa.")
parser.add_argument("--config", default="config.yml", type=str, help="Path to configuration file")
parser.add_argument("overrides", nargs=argparse.REMAINDER, help="Any key=value arguments to override config values")
return parser.parse_args()
def main():
setup_logging()
logger = logging.getLogger(__name__)
# cmd line args and config
args = parse_arguments()
config = OmegaConf.load(args.config)
cli_conf = OmegaConf.from_dotlist(args.overrides)
config = OmegaConf.merge(config, cli_conf)
# Path configurations
dataset_path = Path(config.dataset_path)
work_dir = "outputs"
# Module configuration
config.AssettoCorsa.enable_out_of_track_termination = False
config.AssettoCorsa.enable_low_speed_termination = False
load_paths = data_loader.get_all_paths_in_file(dataset_path=dataset_path, file='motec_to_pickle_config.yml', filter_tags={"type": "human", "data_type": "motec"})
for laps_path, car, track in load_paths:
logger.info(f"******************************************")
logger.info(f"Processing {track} {car}")
logger.info(f"from {laps_path}")
logger.info(f"******************************************")
laps_path = Path(laps_path)
assert laps_path.exists(), f"{laps_path} not found"
config.AssettoCorsa.track = track
config.AssettoCorsa.car = car
env = assettoCorsa.make_ac_env(cfg=config, work_dir=work_dir)
motec_loader.convert_all_in_path(laps_path.as_posix(), env, ac_fps=50, target_freq=25, ignore_fps_missmatch=True)
if __name__ == "__main__":
main()