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

Update doc for blendnavipy

parent ab9b659c
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,8 @@ extensions = ['matplotlib.sphinxext.only_directives', ...@@ -42,7 +42,8 @@ extensions = ['matplotlib.sphinxext.only_directives',
'sphinx.ext.coverage', 'sphinx.ext.coverage',
'sphinx.ext.mathjax', 'sphinx.ext.mathjax',
'sphinx.ext.viewcode', 'sphinx.ext.viewcode',
'sphinxarg.ext'] 'sphinxarg.ext',
'sphinx.ext.inheritance_diagram']
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
......
...@@ -3,6 +3,10 @@ Getting started ...@@ -3,6 +3,10 @@ Getting started
Installing navipy Installing navipy
----------------- -----------------
It is recommanded to install navipy in a \
`virtual environment <https://virtualenvwrapper.readthedocs.io/en/latest/install.html>`_ . By doing \
so, the python version installed on the system and the one used by \
navipy may differ, and ease the use of blender rendering engine.
.. code-block:: bash .. code-block:: bash
...@@ -15,6 +19,15 @@ Testing navipy ...@@ -15,6 +19,15 @@ Testing navipy
python -m unittest discover navipy python -m unittest discover navipy
Testing blender
---------------
Navipy comes with a command line tool to run your script under blender.\
It is however required that the python version used by blender, and the one use by navipy matche. To test your installation of blender and navipy you can download the (:download:`script <../../navipy/sensors/blendnavipy_test.py>`) and run it under blender with the following command:
.. code-block:: bash
blendnavipy --python-script='blendnavipy_test.py'
The core modules The core modules
---------------- ----------------
......
...@@ -8,3 +8,8 @@ Overview ...@@ -8,3 +8,8 @@ Overview
Summary Summary
******* *******
.. automodule:: navipy.moving.agent .. automodule:: navipy.moving.agent
Inheritance
***********
.. inheritance-diagram:: navipy.moving.agent
...@@ -7,6 +7,8 @@ import shutil ...@@ -7,6 +7,8 @@ import shutil
import inspect import inspect
import tempfile import tempfile
import argparse import argparse
from platform import system
from distutils.spawn import find_executable
def activate_virtualenv(venv_path): def activate_virtualenv(venv_path):
...@@ -52,7 +54,7 @@ def parser_blendnavipy(): ...@@ -52,7 +54,7 @@ def parser_blendnavipy():
arghelp = 'Path to the environment (.blend) in which your agent lives' arghelp = 'Path to the environment (.blend) in which your agent lives'
parser.add_argument('--blender-world', parser.add_argument('--blender-world',
type=str, type=str,
default=None, default='',
help=arghelp) help=arghelp)
arghelp = 'Path to your python script to be run in blender' arghelp = 'Path to your python script to be run in blender'
parser.add_argument('--python-script', parser.add_argument('--python-script',
...@@ -98,9 +100,14 @@ def main(): ...@@ -98,9 +100,14 @@ def main():
args = parser_blendnavipy().parse_args() args = parser_blendnavipy().parse_args()
if args.blender_command is None: if args.blender_command is None:
# Find blender command to do a system call if system() == 'Windows':
args.blender_command = shutil.which('blender') args.blender_command = find_executable("blender")
else:
# Find blender command to do a system call
args.blender_command = shutil.which('blender')
if args.blender_command is None:
raise NameError('Blender executable could not be found. ' +
'Please specify the full path to it')
python_script = args.python_script python_script = args.python_script
header = '""" Script generated by {}"""\n'.format(sys.argv[0]) header = '""" Script generated by {}"""\n'.format(sys.argv[0])
...@@ -119,15 +126,15 @@ def main(): ...@@ -119,15 +126,15 @@ def main():
'# activate virtualenv within blender\n'.encode(encoding)) '# activate virtualenv within blender\n'.encode(encoding))
for line in inspect.getsourcelines(activate_virtualenv)[0]: for line in inspect.getsourcelines(activate_virtualenv)[0]:
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
line = 'activate_virtualenv(\"{}\")\n'.format(venv_path) line = 'activate_virtualenv(\"{}\")\n'.format(venv_path)
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
elif syspath is not None: elif syspath is not None:
tfile.write( tfile.write(
'# add navipy path within blender\n'.encode(encoding)) '# add navipy path within blender\n'.encode(encoding))
for line in inspect.getsourcelines(append_path)[0]: for line in inspect.getsourcelines(append_path)[0]:
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
line = 'activate_virtualenv({})\n'.format(str(syspath)) line = 'append_path({})\n'.format(str(syspath))
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
else: else:
raise NameError('The path to navipy could not be found') raise NameError('The path to navipy could not be found')
......
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