From fa405968a43a45aaa78e38f78b26122ec66f6d0b Mon Sep 17 00:00:00 2001
From: "Olivier J.N. Bertrand" <olivier.bertrand@uni-bielefeld.de>
Date: Sun, 4 Mar 2018 11:50:24 +0100
Subject: [PATCH] Add blender test function to check install blender+navipy

---
 doc/source/tutorials/database.rst  | 33 ++++++++++++++++++++++++++++++
 navipy/sensors/blendnavipy_test.py | 12 +++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 doc/source/tutorials/database.rst
 create mode 100644 navipy/sensors/blendnavipy_test.py

diff --git a/doc/source/tutorials/database.rst b/doc/source/tutorials/database.rst
new file mode 100644
index 0000000..55a2059
--- /dev/null
+++ b/doc/source/tutorials/database.rst
@@ -0,0 +1,33 @@
+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: 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: 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 distances to object will be equal to \
+zero:
+
+.. literalinclude:: examples/blenddemo_beesampling.py
+   :lines: 27-28
+
+Finally we can generate the database.
+
+.. literalinclude:: examples/blenddemo_beesampling.py
+   :dedent: 4
+   :lines: 31-32
+
+(:download:`Source code <examples/blenddemo_beesampling.py>`)
+(:download:`Blender world <../../../navipy/resources/forest_world.blend>`)
diff --git a/navipy/sensors/blendnavipy_test.py b/navipy/sensors/blendnavipy_test.py
new file mode 100644
index 0000000..c410e7f
--- /dev/null
+++ b/navipy/sensors/blendnavipy_test.py
@@ -0,0 +1,12 @@
+""" A small script to test if navipy can run under blender"""
+try:
+    import navipy  # noqa F401
+except ModuleNotFoundError:  # noqa F821
+    raise NameError(
+        'navipy could not be imported within blender scripting tool. ' +
+        'This script should be run with the command blendnavipy.' +
+        'If you did, you need to check that either the virtual' +
+        ' environment can be activated under blender, or that' +
+        ' the path can be reached by blender')
+
+print('Blender has been successfully imported')
-- 
GitLab