28 from __future__
import print_function
33 parser = argparse.ArgumentParser(usage=
'Export meshes and convert them')
34 parser.add_argument(
'-b',
'--blenderdir', default=
'/usr/bin',
35 help=
'location of your blender directory')
36 parser.add_argument(
'-f',
'--file', default=
'nao-v4.blend',
37 help=
'full path of the blender file to process')
38 parser.add_argument(
'-o',
'--outputmeshdir', default=
None,
39 help=
'directory to export the meshes to')
41 args = parser.parse_args()
43 if os.path.basename(args.file).lower().startswith(
'nao'):
48 elif os.path.basename(args.file).lower().startswith(
'juliette')
or \
49 os.path.basename(args.file).lower().startswith(
'pepper'):
52 suffix =
'_description' 54 elif os.path.basename(args.file).lower().startswith(
'romeo'):
57 suffix =
'_description' 60 print(
'robot name unknown')
62 package = robot + suffix
64 if args.outputmeshdir
is None:
65 print(
'\nno valid output directory, looking for ' + package +
67 cmd =
'rospack find ' + package
68 path_meshes = subprocess.check_output(cmd,
69 stderr=subprocess.STDOUT,
72 print(
'package "' + path_meshes +
'" not found')
74 if not os.path.isdir(args.outputmeshdir):
75 print(
'creating the output folder because it does not exist')
76 os.makedirs(args.outputmeshdir)
77 path_meshes = args.outputmeshdir
79 extractor_path = subprocess.check_output(
'rospack find naoqi_tools',
80 stderr=subprocess.STDOUT,
82 script_path = os.path.join(extractor_path,
86 path_meshes = os.path.join(path_meshes, version)
88 print(
"extractor path :" + extractor_path)
91 os.system(
'./run_blender_script.py -s io_export_visual.py -o ' + path_meshes +
96 os.system(
'./run_blender_script.py -s io_export_ogre.py -i ' + path_meshes)
99 os.system(
'./run_blender_script.py -s normalize_meshes.py -i ' + path_meshes +
100 ' --scale ' + str(scale))
103 os.system(
'./run_blender_script.py -s io_export_collision.py -i ' +
107 file_list = sorted(os.listdir(path_meshes))
108 for file
in file_list:
109 if file.endswith(
'.mesh.xml')
or file.endswith(
'.mesh')
or \
110 file.endswith(
'.material'):
111 print(
'removing ' + file)
112 os.remove(os.path.join(path_meshes, file))