carla/PythonAPI/examples/start_replaying.py

92 lines
2.1 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(
'-s', '--start',
metavar='S',
default=0.0,
type=float,
help='starting time (default: 0.0)')
argparser.add_argument(
'-d', '--duration',
metavar='D',
default=0.0,
type=float,
help='duration (default: 0.0)')
argparser.add_argument(
'-f', '--recorder_filename',
metavar='F',
2019-02-28 19:37:02 +08:00
default="test1.log",
help='recorder filename (test1.log)')
argparser.add_argument(
'-c', '--camera',
metavar='C',
default=0,
type=int,
help='camera follows an actor (ex: 82)')
argparser.add_argument(
'-x', '--time_factor',
metavar='X',
default=1.0,
type=float,
help='time factor (default 1.0)')
args = argparser.parse_args()
try:
client = carla.Client(args.host, args.port)
client.set_timeout(60.0)
client.set_replayer_time_factor(args.time_factor)
2019-02-28 19:37:02 +08:00
print(client.replay_file(args.recorder_filename, args.start, args.duration, args.camera))
finally:
pass
2019-03-19 19:20:59 +08:00
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
print('\ndone.')