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

Update doc for blender sim

parent c307079d
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,8 @@ extensions = ['matplotlib.sphinxext.only_directives',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode']
'sphinx.ext.viewcode',
'sphinxarg.ext']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
......@@ -16,7 +16,7 @@ How to load a database
----------------------
.. literalinclude:: examples/get_posorients.py
:lines: 8
:lines: 8
How to load all position-orientation
------------------------------------
......@@ -30,7 +30,9 @@ speaking, loading the full table of position-orientaiton.
.. literalinclude:: examples/get_posorients.py
:lines: 9-10
.. plot:: overview/examples/get_posorients.py
.. ipython:: examples/get_posorients.py
:verbatim:
How to load an image
--------------------
......
......@@ -3,6 +3,7 @@ Example on how to use the rendering module
"""
import tempfile
import numpy as np
import os
from navipy.sensors.bee_sampling import BeeSampling
from navipy.sensors.renderer import BlenderRender
......@@ -25,6 +26,7 @@ bee_samp.create_sampling_grid(
# will be set to 0
world_dim = 50 * np.sqrt(2)
bee_samp.world_dim = world_dim
# Rendering in a tmp folder
# Rendering in a temporary folder.
with tempfile.TemporaryDirectory() as folder:
bee_samp.render(folder + '/database.db')
filename_db = os.path.join(folder, 'database.db')
bee_samp.render(filename_db)
......@@ -4,13 +4,15 @@ from matplotlib.colors import hsv_to_rgb, rgb_to_hsv
import matplotlib.pyplot as plt
from navipy.sensors.renderer import BlenderRender
# with tempfile.TemporaryDirectory() as folder:
# Configure the rendering module
cyberbee = BlenderRender()
cyberbee.cycle_samples = 50
cyberbee.camera_rotation_mode = 'XYZ'
cyberbee.camera_fov = [[-90, 90], [-180, 180]]
cyberbee.gaussian_width = 1.5
cyberbee.camera_resolution = [360, 180]
# Set the position at which to render an image/distance
posorient = pd.Series(index=['x', 'y', 'z',
'alpha_0', 'alpha_1', 'alpha_2'])
posorient.x = 0
......@@ -21,7 +23,7 @@ posorient.alpha_1 = 0
posorient.alpha_2 = 0
scene = cyberbee.scene(posorient)
# plot
f, axarr = plt.subplots(2, 1, sharex=True)
to_plot_im = scene[:, :, :3]
......
Rendering
=========
"""
Navipy & blender
----------------
What is blender?
......@@ -13,69 +13,63 @@ Explain How to create env for navipy
Using navipy in blender
~~~~~~~~~~~~~~~~~~~~~~~
Blender comes with its own python installation. Thus, we need to \
tell blender to use our virtualenv where the navigation toolbox \
is installed. To do we need to import the os module
.. literalinclude:: ../blender_run.py
:lines: 6 - 7
then activate the environment by using the following function:
.. literalinclude:: ../blender_run.py
:lines: 13 - 18
>>> blendnavipy --blender-world='/path/to/world.blend' --python-script='/path/to/script.py'
here venv_path is the path to the virtual environment within which \
navipy has been installed.
Now, blender can import all modules used by the navigation toolbox.
How to run python code with blender:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> blender path/to/world.blend --background --python path/to/code.py
.. argparse::
:filename: ../bin/blendnavipy.py
:func: parser_blendnavipy
:prog: blendnavipy
How to generate a database using blender
----------------------------------------
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 7, 8
First we configure the rendering module
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 6
:lines: 11, 12
With the toolbox at disposition we just need to configure the \
BeeSampling to render images on a regular 3D grid.
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 9
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 12-19
:lines: 13,16-23
If we want to use the distance to objects, we need to tell the \
BeeSampling what is the maximum distance to objects in the environment.\
Otherwise the distance can go until infinity, and since the image are \
compressed in the database, all distance to object will be equal to \
compressed in the database, all distances to object will be equal to \
zero:
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 23-24
:lines: 27-28
Finally we can generate the database.
.. literalinclude:: examples/blenddemo_beesampling.py
:lines: 28-29
:dedent: 4
:lines: 31-32
(:download:`Source code <examples/blenddemo_beesampling.py>`)
Custom sampling
---------------
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 5
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 5
With the toolbox at disposition we just need to configure the \
Cyberbee to render images at desired positions.
With the toolbox at disposition we just need to configure the \
Cyberbee to render images at desired positions.
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 8-13
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 8-13
To render a scene at a given positions, we assign position orientation \
to and then tell the cyberbee to get the scene at that point.
To render a scene at a given positions we just have to do:
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 16-24
.. literalinclude:: examples/blenddemo_cyberbee.py
:lines: 14-22
(:download:`Source code <examples/blenddemo_cyberbee.py>`)
......@@ -28,10 +28,18 @@ setup_dict = {'name': 'navipy',
'author_email': 'olivier.bertrand@uni-bielefeld.de',
'description': 'Insect Navigation Toolbox',
'packages': create_package_list("navipy"),
'requires': ['numpy', 'pandas', 'matplotlib', 'scipy',
'requires': ['numpy',
'pandas',
'matplotlib',
'scipy',
'networkx'],
'install_requires': ["numpy", 'pandas', 'matplotlib', 'scipy',
'sphinx_rtd_theme', 'networkx'],
'install_requires': ["numpy",
'pandas',
'matplotlib',
'scipy',
'sphinx_rtd_theme',
'networkx',
'sphinx-argparse'],
'package_data': {'navipy': ['resources/database.db',
'resources/forest_world.blend']},
'include_package_data': True, }
......
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