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

Correct blender error

Error was due to update of database, that was not rerendered
parent 34758681
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ OnGrid:
x: [-0.5,0.5,5]
y: [-0.5,0.5,5]
z: [3,3,1]
alpha_0: [1.570796 , 1.570796 ,1]
alpha_0: [0 , 0 ,1]
alpha_1: [0 , 0 ,1]
alpha_2: [0 , 0 ,1]
# The orientation convention is defined as:
......
No preview for this file type
......@@ -29,7 +29,7 @@ def parser_blend_ongrid():
'navipy', 'resources/twocylinders_world.blend')
defaultconfig = pkg_resources.resource_filename(
'navipy', 'resources/configs/BlenderOnGridRender.yaml')
defaultoutput = tempfile.NamedTemporaryFile().name
defaultoutput = tempfile.NamedTemporaryFile().name+'.db'
parser.add_argument('--blender-world',
type=str,
default=defaultworld,
......@@ -161,7 +161,8 @@ def main():
tfile.write(' sys.exit(1)\n'.encode(encoding))
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)
if args.blender_command is not None:
command += ' --blender-command {}'.format(args.blender_command)
......
......@@ -78,13 +78,13 @@ class TestBlenderRender_renderer(unittest.TestCase):
x = np.linspace(-0.5, 0.5, 5)
y = np.linspace(-0.5, 0.5, 5)
z = [3]
alpha_0 = [np.pi/2]
alpha_0 = [0]
rotconv = 'rzyx'
db_reffilename = pkg_resources.resource_filename(
'navipy', 'resources/database.db')
db_ref = DataBaseLoad(db_reffilename)
tfile = tempfile.NamedTemporaryFile()
outputfile = tfile.name
outputfile = tfile.name+'.db'
self.renderer.render_ongrid(outputfile,
x, y, z, alpha_0,
rotconv=rotconv)
......
"""
"""
import os
import sys
import argparse
import inspect
import pandas as pd
def parser_blendtraj():
"""
Parse argument for function blendtraj
"""
# Create command line options
parser = argparse.ArgumentParser()
arghelp = 'Path to the environment (.blend) in which your agent lives'
defaultworld = pkg_resources.resource_filename(
'navipy', 'resources/twocylinders_world.blend')
parser.add_argument('--blender-world',
type=str,
default=defaultworld,
help=arghelp)
arghelp = 'Command to run blender\n'
arghelp += 'If not provided, the script will try to find the command'
arghelp += " by using: shutil.which('blender')"
parser.add_argument('--blender-command',
type=str,
default=None,
help=arghelp)
arghelp = 'To display some stuff \n'
arghelp += ' * -v print command \n'
arghelp += ' * -vv print also script'
parser.add_argument('-v', '--verbose',
action='count',
default=0,
help=arghelp)
defaultfile = pkg_resources.resource_filename(
'navipy', 'resources/configs/BlenderRender.yaml')
arghelp = 'BlenderRender configuration files \n'
arghelp += 'by default: {}'.format(defaultfile)
parser.add_argument('--config',
type=str,
default=defaultfile,
help=arghelp)
arghelp = 'Trajectory of the agent\n'
arghelp += 'pandas dataframe saved in hdf'
parser.add_argument('--trajectory',
type=str,
default=defaultfile,
help=arghelp)
def render_trajectory(traj_filename, output_path, imformat='.jpg'):
# Get extension to check that file is hdf
_, ext = os.path.splitext(traj_filename)
if ext in ['h5', 'hdf']:
trajdf = pd.read_hdf(traj_filename)
else:
raise IOError(
'File {} can not be read as a trajectory'.format(traj_filename))
def main():
"""
Render a trajectory in a blender environment
"""
# encoding for temporary file
encoding = 'utf-8'
# Fetch arguments
args = parser_blendtraj().parse_args()
# Create tempfile with testing code and then call blendnavipy
header = '# Generated by {}\n'.format(sys.argv[0])
with tempfile.NamedTemporaryFile() as tfile:
# Start of file
tfile.write(header.encode(encoding))
tfile.write('import unittest \n'.encode(encoding))
for line in inspect.getsourcelines(run)[0]:
tfile.write(line.encode(encoding))
tfile.write('\n\n'.encode(encoding))
tfile.write('try:\n'.encode(encoding))
tfile.write(' run("{}")\n'.format(args.start_dir).encode(encoding))
tfile.write(' sys.exit(0)\n'.encode(encoding))
tfile.write('except Exception:\n'.encode(encoding))
tfile.write(' sys.exit(1)\n'.encode(encoding))
tfile.seek(0)
command = 'blendnavipy --blender-world {} --python-script {}'
command = command.format(args.blender_world, tfile.name)
if args.blender_command is not None:
command += ' --blender-command {}'.format(args.blender_command)
for _ in range(args.verbose):
command += ' -v'
os.system(command)
if __name__ == "__main__":
# execute only if run as a script
main()
......@@ -17,7 +17,7 @@ import pkg_resources
from navipy.maths.homogeneous_transformations import compose_matrix
from navipy.maths.quaternion import matrix as quatmatrix
import navipy.maths.constants as constants
from navipy.tools.trajectory import Trajectory
from navipy.trajectories import Trajectory
from PIL import Image
from navipy.scene import check_scene
from navipy.database import DataBaseSave
......
......@@ -36,7 +36,6 @@ class TestTrajectoryTransform(unittest.TestCase):
# Devide by two the second anle, because of gimbal lock
col = (trajectory.rotation_mode, 'alpha_1')
trajectory.loc[:, col] = trajectory.loc[:, col] / 2
print(trajectory)
# forward
for euler_axes in list(htconst._AXES2TUPLE.keys()):
trajectory.rotation_mode = euler_axes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment