Some bug fixes in new util examples
This commit is contained in:
parent
d1f6aa256e
commit
ee36e3993b
|
@ -1,9 +1,20 @@
|
|||
""" CARLA map spawn points extractor """
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import argparse
|
||||
import logging
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
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
|
||||
|
||||
|
||||
|
@ -24,7 +35,7 @@ def extract(args):
|
|||
logging.info('Please add some Vehicle Spawn Point to your UE4 scene.')
|
||||
sys.exit(1)
|
||||
spawn_points = _map.get_spawn_points()
|
||||
with open("spawn_points.csv", "w", encoding='utf8') as file:
|
||||
with open(args.output_dir+"/spawn_points.csv", "w", encoding='utf8') as file:
|
||||
index = 0
|
||||
for index, spawn_point in enumerate(spawn_points):
|
||||
file.write(f'{index},{spawn_point.location.x},{spawn_point.location.y}\n')
|
||||
|
@ -51,8 +62,14 @@ def main():
|
|||
default=2000,
|
||||
type=int,
|
||||
help='TCP port to listen to (default: 2000)')
|
||||
argparser.add_argument(
|
||||
'-o', '--output-dir',
|
||||
help='Output directory path for extraction result')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.output_dir is None or not os.path.exists(args.output_dir):
|
||||
print('output directory not found.')
|
||||
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||
|
||||
logging.info('listening to server %s:%s', args.host, args.port)
|
||||
|
@ -61,11 +78,15 @@ def main():
|
|||
|
||||
try:
|
||||
extract(args)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print('\nCancelled by user. Bye!')
|
||||
except:
|
||||
print('\nAn error has occurred in extraction.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print('\nCancelled by user. Bye!')
|
||||
except RuntimeError as e:
|
||||
print(e)
|
|
@ -51,6 +51,10 @@ def convert(args):
|
|||
with open(args.output_path, "w", encoding="utf-8") as xodrFile:
|
||||
xodrFile.write(xodr_data)
|
||||
|
||||
# ==============================================================================
|
||||
# -- main() --------------------------------------------------------------------
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
def main():
|
||||
argparser = argparse.ArgumentParser(
|
||||
|
@ -91,8 +95,10 @@ def main():
|
|||
if args.output_path is None:
|
||||
print('output file path not found.')
|
||||
|
||||
print(__doc__)
|
||||
|
||||
try:
|
||||
convert()
|
||||
convert(args)
|
||||
except:
|
||||
print('\nAn error has occurred in conversion.')
|
||||
|
||||
|
|
Loading…
Reference in New Issue