diff --git a/doc/source/conf.py b/doc/source/conf.py index bbb7a3e5462bd16caa423f1188db0286e91f0d23..28a9b83331208555006976e0dfca80c6a2e230e5 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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'] diff --git a/doc/source/overview/database.rst b/doc/source/overview/database.rst index 26694db5b5098954dfc8ad25f84ccd613ae14413..54d674f256c736e01ee4cfa50f2482525c81fc4d 100644 --- a/doc/source/overview/database.rst +++ b/doc/source/overview/database.rst @@ -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 -------------------- diff --git a/doc/source/overview/examples/blenddemo_beesampling.py b/doc/source/overview/examples/blenddemo_beesampling.py index 214c8801713edc1776dc868810bede232a802830..a948ef8a824fdc6ef48d4644096a9fe3174d43f3 100644 --- a/doc/source/overview/examples/blenddemo_beesampling.py +++ b/doc/source/overview/examples/blenddemo_beesampling.py @@ -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) diff --git a/doc/source/overview/examples/blenddemo_cyberbee.py b/doc/source/overview/examples/blenddemo_cyberbee.py index 37f6e440cb70db36da93b16871aaf6376624ccee..e9e1b2c9ff21d86c2a6bcdf850a2685c08e2aa89 100644 --- a/doc/source/overview/examples/blenddemo_cyberbee.py +++ b/doc/source/overview/examples/blenddemo_cyberbee.py @@ -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] diff --git a/doc/source/overview/rendering.rst b/doc/source/overview/rendering.rst index 58a546b65c752af603ebea216e43ada1cb464587..91efae6ee535cc6c10df22f93f672d4777c26da9 100644 --- a/doc/source/overview/rendering.rst +++ b/doc/source/overview/rendering.rst @@ -1,6 +1,6 @@ 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>`) diff --git a/setup.py b/setup.py index 201168ed1809436cbb29fa30f2899a59a0455cf4..c74c85778069bde13ef7e1fee57932184cd72540 100644 --- a/setup.py +++ b/setup.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, }