Skip to content
Snippets Groups Projects
Commit 20d18048 authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Add tool to render along trajectory

parent 0f41d98e
No related branches found
No related tags found
No related merge requests found
...@@ -22,12 +22,12 @@ def parser_blend_alongtraj(): ...@@ -22,12 +22,12 @@ def parser_blend_alongtraj():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
arghelp = 'Path to the environment (.blend) in which your agent lives' arghelp = 'Path to the environment (.blend) in which your agent lives'
defaultworld = pkg_resources.resource_filename( defaultworld = pkg_resources.resource_filename(
'navipy', 'resources/twocylinders_world.blend') 'navipy', 'resources/corridor.blend')
defaulttraj = pkg_resources.resource_filename(
'navipy', 'resources/corridor_traj.csv')
defaultconfig = pkg_resources.resource_filename( defaultconfig = pkg_resources.resource_filename(
'navipy', 'resources/configs/BlenderRender.yaml') 'navipy', 'resources/configs/BlenderRender.yaml')
defaultoutput = tempfile.NamedTemporaryFile().name defaultoutput = tempfile.NamedTemporaryFile().name
defaulttraj = pkg_resources.resource_filename(
'navipy', 'resources/twocylinders_traj.hdf')
parser.add_argument('--blender-world', parser.add_argument('--blender-world',
type=str, type=str,
default=defaultworld, default=defaultworld,
...@@ -70,7 +70,7 @@ def run(config_file, outputfile, trajfile): ...@@ -70,7 +70,7 @@ def run(config_file, outputfile, trajfile):
renderer = BlenderRender() renderer = BlenderRender()
renderer.config_file = config_file renderer.config_file = config_file
# Load trajectory # Load trajectory
trajectory = Trajectory().fromfile(trajfile) trajectory = Trajectory().read_csv(trajfile)
renderer.render_trajectory(outputfile, trajectory) renderer.render_trajectory(outputfile, trajectory)
...@@ -81,11 +81,6 @@ def main(): ...@@ -81,11 +81,6 @@ def main():
# Fetch arguments # Fetch arguments
args = parser_blend_alongtraj().parse_args() args = parser_blend_alongtraj().parse_args()
# Some output # Some output
print('-----')
print('Config file:\n{}'.format(args.config_file))
print('Blender file:\n{}'.format(args.blender_world))
print('Output file:\n{}'.format(args.output_file))
print('-----')
# Create tempfile with testing code and then call blendnavipy # Create tempfile with testing code and then call blendnavipy
header = '# Generated by {}\n'.format(sys.argv[0]) header = '# Generated by {}\n'.format(sys.argv[0])
with tempfile.NamedTemporaryFile() as tfile: with tempfile.NamedTemporaryFile() as tfile:
...@@ -107,7 +102,8 @@ def main(): ...@@ -107,7 +102,8 @@ def main():
tfile.write(' sys.exit(1)\n'.encode(encoding)) tfile.write(' sys.exit(1)\n'.encode(encoding))
tfile.seek(0) tfile.seek(0)
command = 'blendnavipy --blender-world {} --python-script {}' command = 'blendnavipy --background '
command += '--blender-world {} --python-script {}'
command = command.format(args.blender_world, tfile.name) command = command.format(args.blender_world, tfile.name)
if args.blender_command is not None: if args.blender_command is not None:
command += ' --blender-command {}'.format(args.blender_command) command += ' --blender-command {}'.format(args.blender_command)
......
...@@ -60,7 +60,8 @@ setup_dict = {'name': 'navipy', ...@@ -60,7 +60,8 @@ setup_dict = {'name': 'navipy',
'blendnavipy=navipy.sensors.blendnavipy:main', 'blendnavipy=navipy.sensors.blendnavipy:main',
'blendunittest=navipy.sensors.blendunittest:main', 'blendunittest=navipy.sensors.blendunittest:main',
'blendongrid=navipy.sensors.blend_ongrid:main', 'blendongrid=navipy.sensors.blend_ongrid:main',
'blendoverlaytraj=navipy.sensors.blend_overlaytraj:main' 'blendoverlaytraj=navipy.sensors.blend_overlaytraj:main',
'blendalongtraj=navipy.sensors.blend_alongtraj:main'
]}, ]},
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment