Added frecad2gazebo script as a command line tool with arguments

This commit is contained in:
Dawit Abate 2019-07-04 15:50:06 +03:00
parent a78c3ef73a
commit 17a91d11d3

35
scripts/freecad2gazebo.py Normal file
View file

@ -0,0 +1,35 @@
import os
from freecad_to_gazebo import freecad_exporter
import argparse
import json
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('assembly', type=str, help='filename of the assembly')
parser.add_argument('model_dir', type=str, help='model output directory')
parser.add_argument('--sdf-only',
action='store_true',
default=False,
help='export only sdf')
parser.add_argument('--noexport',
action="store_true",
default=False,
help='export mesh files')
parser.add_argument('--config', type=str, help='model configuration file (json)')
args = parser.parse_args()
default_config = os.path.join(os.path.split(args.assembly)[0],'robot_config.json')
config_file = args.config or default_config if os.path.exists(default_config) else None
print(config_file)
configs = {}
if config_file:
configs = json.load(open(config_file, 'r'))
configs['export'] = not args.noexport
configs['sdf_only'] = args.sdf_only
freecad_exporter.export_gazebo_model(args.assembly, args.model_dir, configs)