Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pybullet_rendering-0.6.3-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pybullet_rendering-0.6.3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a850e33f921771650eb61bc6619f8a38096bb8a08d528a8b76bbda81ec14950
MD5 ebdd50c37bccd65a4b02096667304f3f
BLAKE2b-256 4968006309419b0b6cb4931304611ffc5316f1f3f440f73ca07e39ff54eeff8c

See more details on using hashes here.

File details

Details for the file pybullet_rendering-0.6.3-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pybullet_rendering-0.6.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 10b0ea645ade8b4daacb23ba3186a71834f5fe990a226a051d182c28a8e52814
MD5 20a01c1a93347f61a5e9e35b86221983
BLAKE2b-256 4af2b06b317f30cb0dd4c745a9e128ee9195fd4c555156e4b3152b3acb828d83

See more details on using hashes here.

File details

Details for the file pybullet_rendering-0.6.3-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pybullet_rendering-0.6.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 60bf0d04315231ca750172c99bd65db027e4cb8e6171ba5db6fb85639230bf36
MD5 16c673d58a9624e0e989f6e0390ccb03
BLAKE2b-256 4e27836908337c6432640191e1de47bd6502ffe026025ff54e0f2b880d032e45

See more details on using hashes here.

File details

Details for the file pybullet_rendering-0.6.3-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pybullet_rendering-0.6.3-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2436f9d784cb766f11549c85db3ad8ed897b2f2e26af8b166a1c73abafce6536
MD5 8f99ce8c6b5954207f2f3e50ab58c60c
BLAKE2b-256 65e714056e539959abf12ce37fd06074a0fe8fa182a3e0a48a8fc87db5782821

See more details on using hashes here.

File details

Details for the file pybullet_rendering-0.6.3-cp35-cp35m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pybullet_rendering-0.6.3-cp35-cp35m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee1b5ae0cea94f868c08e073d37ac2b889d9577ecac8fcf9598af5ab462875fc
MD5 f49a5a45e79296122751a2c2be533444
BLAKE2b-256 92038145ac8686273641921a07df2dfc180a9a082092c290f3a741eaae161c75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page