anki_vector.opengl.opengl_viewer

This module provides a 3D visualizer for Vector’s world state and a 2D camera window.

It uses PyOpenGL, a Python OpenGL 3D graphics library which is available on most platforms. It also depends on the Pillow library for image processing.

Example

import time

import anki_vector

with anki_vector.Robot(show_viewer=True,
                       show_3d_viewer=True,
                       enable_camera_feed=True,
                       enable_face_detection=True,
                       enable_custom_object_detection=True,
                       enable_nav_map_feed=True) as robot:
    time.sleep(10)

Warning

This package requires Python to have the PyOpenGL package installed, along with an implementation of GLUT (OpenGL Utility Toolkit).

To install the Python packages on Mac and Linux do python3 -m pip install --user "anki_vector[3dviewer]"

To install the Python packages on Windows do py -3 -m pip install --user "anki_vector[3dviewer]"

On Windows and Linux you must also install freeglut (macOS / OSX has one preinstalled).

On Linux: sudo apt-get install freeglut3

On Windows: Go to http://freeglut.sourceforge.net/ to get a freeglut.dll file. It’s included in any of the Windows binaries downloads. Place the DLL next to your Python script, or install it somewhere in your PATH to allow any script to use it.”

Classes

OpenGLViewer(close_event, …[, resolution, …]) OpenGL-based 3D Viewer.
class anki_vector.opengl.opengl_viewer.OpenGLViewer(close_event, input_intent_queue, nav_map_queue, world_frame_queue, extra_render_function_queue, user_data_queue, resolution=None, projector=None, camera=None, lights=None, show_viewer_controls=True)

OpenGL-based 3D Viewer.

Handles rendering of a 3D world view including navigation map.

Parameters:
  • close_event (multiprocessing.Event) – Used to notify each process when done rendering.
  • input_intent_queue (multiprocessing.Queue) – Sends key commands from the 3D viewer process to the main process.
  • nav_map_queue (multiprocessing.Queue) – Updates the 3D viewer process with the latest navigation map.
  • world_frame_queue (multiprocessing.Queue) – Provides the 3D viewer with details about the world.
  • extra_render_function_queue (multiprocessing.Queue) – Functions to be executed in the 3D viewer process.
  • user_data_queue (multiprocessing.Queue) – A queue that may be used outside the SDK to pass information to the viewer process. May be used by extra_render_function_queue functions.
  • resolution (Optional[List[int]]) – Specifies whether to draw controls on the view.
  • projector (Optional[Projector]) – Specifies whether to draw controls on the view.
  • camera (Optional[Camera]) – Specifies whether to draw controls on the view.
  • lights (Optional[List[Light]]) – Specifies whether to draw controls on the view.
  • show_viewer_controls (bool) – Specifies whether to draw controls on the view.
close()

Called from the SDK when the program is complete and it’s time to exit.

run()

Turns control of the current thread over to the OpenGL viewer