External rendering plugin for PyBullet
Project description
pybullet_rendering
External rendering for PyBullet simulator.
Install
Using pip
pip install pybullet_rendering
From source code
Install NumPy
pip install numpy
Install PyBullet from source code
git clone https://github.com/bulletphysics/bullet3.git
cd bullet3
python setup.py install
export BULLET_ROOT_DIR="$PWD"
Install the package
cd ..
git clone https://github.com/ikalevatykh/pybullet_rendering.git
cd pybullet_rendering
python setup.py install --bullet_dir "$BULLET_ROOT_DIR"
Run tests
python -m unittest discover tests -v
Run examples
Example of using Panda3D for rendering in GUI mode:
python -m pybullet_rendering.examples.panda3d_gui --multisamples 8
Test performance of diferent renderers:
python -m pybullet_rendering.examples.performance
Renderers
This package provide example renderers based on Panda3D and pyrender.
Example of usage
import pybullet as pb
from pybullet_rendering import RenderingPlugin
from pybullet_rendering.render.panda3d import P3dRenderer # panda3d-based renderer
from pybullet_rendering.render.pyrender import PyrRenderer # pyrender-based renderer
client_id = pb.connect(pb.DIRECT)
# bind your renderer to pybullet
renderer = P3dRenderer(multisamples=4) # or PyrRenderer(platform='egl', egl_device=1)
plugin = RenderingPlugin(client_id, renderer)
# render thru the standard pybullet API
w, h, rgba, depth, mask = pb.getCameraImage(w, h, projectionMatrix=..., viewMatrix=...)
Implement your own renderer in Python
Your renderer should inherit from the BaseRenderer
class and implement its update_scene
and render_frame
methods. To get an idea of their parameters, see examples and tests.
from pybullet_rendering import BaseRenderer
class MyRenderer(BaseRenderer):
def __init__(self):
"""The base class initializer have to be called first."""
BaseRenderer.__init__(self)
def update_scene(self, scene_graph, materials_only):
"""Update a scene using scene_graph description
Arguments:
scene_graph {SceneGraph} -- scene description
materials_only {bool} -- update only shape materials
"""
for uid, pb_node in scene_graph.nodes.items():
"update nodes of your scene"
def render_frame(self, scene_state, scene_view, frame):
"""Render a scene at scene_state with a scene_view settings
Arguments:
scene_state {SceneState} -- scene state, e.g. transformations of all objects
scene_view {SceneView} -- view settings, e.g. camera, light, viewport parameters
frame {FrameData} -- output image buffer
"""
w, h = scene_view.viewport
if return_to_bullet:
frame.color_img[:] = ... # np.uint8, (h,w,4)
frame.depth_img[:] = ... # np.float32 (h,w)
frame.mask_img[:] = ... # np.int32 (h,w)
return True
return False
Citation
If you find pybullet_rendering useful in your research, please cite the repository using the following BibTeX entry.
@Misc{kalevatykh2020pybullet_rendering,
author = {Kalevatykh, Igor et al.},
title = {pybullet_rendering - External rendering for the PyBullet simulator},
howpublished = {Github},
year = {2020},
url = {https://github.com/ikalevatykh/pybullet_rendering}
}
License
mano_pybullet is released under the GPLv3 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pybullet_rendering-0.6.5-cp39-cp39-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pybullet_rendering-0.6.5-cp39-cp39-manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a17adc9b37e85e53910117d265f2f3f4f7af9dec86de4a21e588013da14d44b1 |
|
MD5 | 637845f6c90043cca08474ae5cbfc223 |
|
BLAKE2b-256 | 06a578235f70711277d72ed3f7d21aa30f3c667c6ccf2198e4de8905e61ac179 |
File details
Details for the file pybullet_rendering-0.6.5-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pybullet_rendering-0.6.5-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 498e76de544cad53121c179f3bb71d4e67e64a905330e48c9cba0142e1b30d46 |
|
MD5 | f3002f672aa8abd660c2c925c0e0ce1a |
|
BLAKE2b-256 | 49fc0c908a483f5c17539bf6ccabaa9e27f67889cf86461cd31fda36e9a19ee3 |
File details
Details for the file pybullet_rendering-0.6.5-cp37-cp37m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pybullet_rendering-0.6.5-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 746bc9c03f82f8e33bdf937a33067168dedf87f10cc18e08d196de4f72a6ce02 |
|
MD5 | 732d423902d972afa8aa9ff8ccb8a6ee |
|
BLAKE2b-256 | d8bbe590172485fb72f03d579f26966e30d784ebee03e3c49e72b51590771db5 |
File details
Details for the file pybullet_rendering-0.6.5-cp36-cp36m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pybullet_rendering-0.6.5-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d688384c4911b7b5d0d2a704e79eb176e34d032ed05fa29b5764e9a406aef525 |
|
MD5 | 48490345eeba9f42d62c695ec10e4a8b |
|
BLAKE2b-256 | ae47ba4e591b2819b17693ca417b2493c45fded3dbd098511eb2dfe288d2b0ac |
File details
Details for the file pybullet_rendering-0.6.5-cp35-cp35m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pybullet_rendering-0.6.5-cp35-cp35m-manylinux2014_x86_64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e63c2f252622f0935fa6d7bc7ab486bc69182762fba7d2c7d0ef31692e0cff86 |
|
MD5 | ab8e8f3af4404558931c05790dac60c7 |
|
BLAKE2b-256 | 03fe73d9df368ed81585afb8de6b0f99d2bb51a62d587a226de8796b63205e25 |