carla/PythonAPI/examples/show_recorder_file_info.py

81 lines
1.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2019-03-29 17:58:05 +08:00
# Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
import glob
import os
import sys
try:
2019-03-29 02:15:13 +08:00
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
import carla
import argparse
def main():
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
help='IP of the host server (default: 127.0.0.1)')
argparser.add_argument(
'-p', '--port',
metavar='P',
default=2000,
type=int,
help='TCP port to listen to (default: 2000)')
argparser.add_argument(
'-f', '--recorder_filename',
metavar='F',
default="test1.rec",
help='recorder filename (test1.rec)')
argparser.add_argument(
'-a', '--show_all',
action='store_true',
help='show detailed info about all frames content')
Determinism for Traffic Manager (#3333) * Check for determinism * Per-vehicle random device * Parameterised random device seed. * Changing next waypoint selection logic to use bucketing random device sample. Arranging next waypoint selections right to left. * Change to numpy's random lib * Sorting blueprints to ensure determinism * New method for determinism * ResetAllTrafficLight now works in sync mode. * Moving recorder stuff to engine module * Fixed recorder for traffic lights in standalone mode. * Added check to prevent traffic light from updating during replay. * Updating old traffic lights to use the traffic light component. * Moved recorder to posttick. * Small fix to elapse time function. * Added reset group function to API. * Merge with traffic_manager/determinism_check * Changes in TL reset Option to save to file for recorder script * Added automatic signal match with OpenDRIVE. * Fixed error that caused traffic light actors to be missing in client side. * Added new frozen behavior. * Updated documentation and changelog * Updated ContentVersions.txt * Review changes. * fixes merge error * fixes merge * Update build_windows.md Added info about command execution that toke me many time to find out * Update build_windows.md Updated as requested in pull request review * Running Carla when choosing a) deb Carla install This fixes a minor error in the documentation regarding running carla, if the deb installation was choosen. * Fix for traffic manager freezing upon map change * attempt to change sys clock to sim clock * Remove manual unlock of mutex * fixing merge error * Changelog and review fixes Co-authored-by: Praveen Kumar <pravinblaze@hotmail.com> Co-authored-by: bernat <bernatx@gmail.com> Co-authored-by: Axel1092 <axellopez92@outlook.com> Co-authored-by: Axel1092 <35765780+Axel1092@users.noreply.github.com> Co-authored-by: Néstor Sabater <web.nsabater@gmail.com> Co-authored-by: ll7 <32880741+ll7@users.noreply.github.com>
2020-09-22 21:20:52 +08:00
argparser.add_argument(
'-s', '--save_to_file',
metavar='S',
help='save result to file (specify name and extension)')
args = argparser.parse_args()
try:
client = carla.Client(args.host, args.port)
client.set_timeout(60.0)
Determinism for Traffic Manager (#3333) * Check for determinism * Per-vehicle random device * Parameterised random device seed. * Changing next waypoint selection logic to use bucketing random device sample. Arranging next waypoint selections right to left. * Change to numpy's random lib * Sorting blueprints to ensure determinism * New method for determinism * ResetAllTrafficLight now works in sync mode. * Moving recorder stuff to engine module * Fixed recorder for traffic lights in standalone mode. * Added check to prevent traffic light from updating during replay. * Updating old traffic lights to use the traffic light component. * Moved recorder to posttick. * Small fix to elapse time function. * Added reset group function to API. * Merge with traffic_manager/determinism_check * Changes in TL reset Option to save to file for recorder script * Added automatic signal match with OpenDRIVE. * Fixed error that caused traffic light actors to be missing in client side. * Added new frozen behavior. * Updated documentation and changelog * Updated ContentVersions.txt * Review changes. * fixes merge error * fixes merge * Update build_windows.md Added info about command execution that toke me many time to find out * Update build_windows.md Updated as requested in pull request review * Running Carla when choosing a) deb Carla install This fixes a minor error in the documentation regarding running carla, if the deb installation was choosen. * Fix for traffic manager freezing upon map change * attempt to change sys clock to sim clock * Remove manual unlock of mutex * fixing merge error * Changelog and review fixes Co-authored-by: Praveen Kumar <pravinblaze@hotmail.com> Co-authored-by: bernat <bernatx@gmail.com> Co-authored-by: Axel1092 <axellopez92@outlook.com> Co-authored-by: Axel1092 <35765780+Axel1092@users.noreply.github.com> Co-authored-by: Néstor Sabater <web.nsabater@gmail.com> Co-authored-by: ll7 <32880741+ll7@users.noreply.github.com>
2020-09-22 21:20:52 +08:00
if args.save_to_file:
doc = open(args.save_to_file, "w+")
doc.write(client.show_recorder_file_info(args.recorder_filename, args.show_all))
doc.close()
else:
print(client.show_recorder_file_info(args.recorder_filename, args.show_all))
finally:
pass
2019-03-19 19:20:59 +08:00
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
print('\ndone.')