(env_configs, obs_configs, carla_sh_path)
| 10 | |
| 11 | |
| 12 | def check_h5_maps(env_configs, obs_configs, carla_sh_path): |
| 13 | pixels_per_meter = None |
| 14 | for agent_id, obs_cfg in obs_configs.items(): |
| 15 | for k,v in obs_cfg.items(): |
| 16 | if 'birdview' in v['module']: |
| 17 | pixels_per_meter = float(v['pixels_per_meter']) |
| 18 | |
| 19 | if pixels_per_meter is None: |
| 20 | # agent does not require birdview map as observation |
| 21 | return |
| 22 | |
| 23 | save_dir = Path(hydra.utils.get_original_cwd()) / 'carla_gym/core/obs_manager/birdview/maps' |
| 24 | txt_command = f'Please run map generation script from project root directory. \n' \ |
| 25 | f'\033[93m' \ |
| 26 | f'python -m carla_gym.utils.birdview_map ' \ |
| 27 | f'--save_dir {save_dir} --pixels_per_meter {pixels_per_meter:.2f} ' \ |
| 28 | f'--carla_sh_path {carla_sh_path}' \ |
| 29 | f'\033[0m' |
| 30 | |
| 31 | # check if pixels_per_meter match |
| 32 | for env_cfg in env_configs: |
| 33 | carla_map = env_cfg['env_configs']['carla_map'] |
| 34 | hf_file_path = save_dir / (carla_map+'.h5') |
| 35 | |
| 36 | file_exists = hf_file_path.exists() |
| 37 | if file_exists: |
| 38 | map_hf = h5py.File(hf_file_path, 'r') |
| 39 | hf_pixels_per_meter = float(map_hf.attrs['pixels_per_meter']) |
| 40 | map_hf.close() |
| 41 | pixels_per_meter_match = np.isclose(hf_pixels_per_meter, pixels_per_meter) |
| 42 | txt_assert = f'pixel_per_meter mismatch between h5 file ({hf_pixels_per_meter}) '\ |
| 43 | f'and obs_config ({pixels_per_meter}). ' |
| 44 | else: |
| 45 | txt_assert = f'{hf_file_path} does not exists. ' |
| 46 | pixels_per_meter_match = False |
| 47 | |
| 48 | assert file_exists and pixels_per_meter_match, txt_assert + txt_command |
| 49 | |
| 50 | |
| 51 | def load_entry_point(name): |
nothing calls this directly
no outgoing calls
no test coverage detected