GithubHelp home page GithubHelp logo

ikalevatykh / pybullet_rendering Goto Github PK

View Code? Open in Web Editor NEW
85.0 85.0 12.0 213 KB

External rendering for PyBullet

License: GNU General Public License v3.0

Python 42.53% CMake 1.73% C++ 54.56% C 0.61% Shell 0.58%

pybullet_rendering's People

Contributors

ikalevatykh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pybullet_rendering's Issues

support URDF?

hi, i have tried to use loadurdf in pybulliet rendering, but found that

<geometry>
        <cylinder length=".1" radius="0.035"/>
</geometry>

just load the original cylinder without changing the radius like the picture below:
Screenshot_2020-06-22_13-33-02

what i want is:
Screenshot_2020-06-22_13-33-23

The code is like below:

            for j, shape in enumerate(v.shapes):
                if shape.type == ShapeType.Mesh:
                    filename = shape.mesh.filename
                elif shape.type == ShapeType.Cube:
                    filename = 'cube.obj'
                elif shape.type == ShapeType.Cylinder:
                    filename = '/data/hdd1/kb/anaconda2/envs/bullet/lib/python3.6/site-packages/pybullet-2.8.0-py3.6-linux-x86_64.egg/pybullet_data/cylinder.obj'
                #     # filename = shape.mesh.filename
                elif shape.type == ShapeType.Sphere:
                    filename = '/data/hdd1/kb/anaconda2/envs/bullet/lib/python3.6/site-packages/pybullet-2.8.0-py3.6-linux-x86_64.egg/pybullet_data/sphere_smooth.obj'
                #     # filename = shape.mesh.filename
                else:
                    print('Unknown shape type: {}'.format(shape.type))
                    continue

Request About New Version For Python 3.11

I'm glad to write about request about your work.

Your code can be installed in Python3.9(linux) but not in Python 3.11(windows).

Can you update it for Python 3.11?

I want to render scene for realistic simulation and camera view.

Thanks

P.S If my request needs such a time, then can you let me know how to revise the code for Python 3.11?

Crash while rendering

The rendering crashes at the getCameraImage with the following error:

terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

This happens both with the panda3d and pyrender rendering engine.

P3dRenderer doesn't support masks?

Just to confirm, but looking into the code (this line in particular) for P3dRenderer leads me to believe that it doesn't support masks (e.g. for segmentation). Is this correct?
If so, I guess I'll have to use a separate renderer to get the masks?

Crash in Example

[EDIT] In the setup scene, I'm guessing that the loadURDF functions can't find the hardcoded paths in the demo file. Should I be running this script from a certain entry point?

Hi,

I am trying to run the example script with python -m pybullet_rendering.examples.panda3d_gui --multisamples 8 and I get the following error:

Known pipe types:
  glxGraphicsPipe
(1 aux display modules not yet loaded.)
argv[0]=
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
Fatal Python error: Aborted

Current thread 0x00007fa58893f4c0 (most recent call first):
  File "/root/.pyenv/versions/3.9.2/lib/python3.9/site-packages/pybullet_rendering/examples/panda3d_gui.py", line 83 in setupScene
  File "/root/.pyenv/versions/3.9.2/lib/python3.9/site-packages/pybullet_rendering/examples/panda3d_gui.py", line 65 in __init__
  File "/root/.pyenv/versions/3.9.2/lib/python3.9/site-packages/pybullet_rendering/examples/panda3d_gui.py", line 210 in <module>
  File "/root/.pyenv/versions/3.9.2/lib/python3.9/runpy.py", line 87 in _run_code
  File "/root/.pyenv/versions/3.9.2/lib/python3.9/runpy.py", line 197 in _run_module_as_main
[1]    899 abort (core dumped)  python -m pybullet_rendering.examples.panda3d_gui --multisamples 8

For what its worth, my versions are:
python: 3.9.2
pybullet: 3.2.0
panda3d: 1.10.10
pybullet_rendering: 0.6.5

Any ideas?

Compilation error: invalid new-expression of abstract class type ‘RenderingInterface’

Hi,

I am getting a compilation error due to unimplemented pure virtual member functions in RenderingInterface:

/home/manifold/Documents/pybullet_rendering/src/plugin/RenderingPlugin.cpp: In function ‘int initPlugin_RenderingPlugin(b3PluginContext*)’:
/home/manifold/Documents/pybullet_rendering/src/plugin/RenderingPlugin.cpp:35:42: error: invalid new-expression of abstract class type ‘RenderingInterface’
   35 |     auto render = new RenderingInterface();
      |                                          ^
In file included from /home/manifold/Documents/pybullet_rendering/src/plugin/RenderingPlugin.cpp:7:
/home/manifold/Documents/pybullet_rendering/src/plugin/RenderingInterface.h:18:7: note:   because the following virtual functions are pure within ‘RenderingInterface’:
   18 | class RenderingInterface : public UrdfRenderingInterface
      |       ^~~~~~~~~~~~~~~~~~

My system:

  • Ubuntu 20.04.1 (up-to-date)
  • Python 3.7.8 (conda)
  • GCC 9.3.0
  • pybind11 2.4.3
  • Bullet3 latest (from Git, so PyBullet version >=3.0.0)

I've also tested compiling with Clang instead of GCC, but it made no difference.

panda3d cannot load png texture while load obj file in new search path

client.setAdditionalSearchPath(pybullet_data.getDataPath())
client.setAdditionalSearchPath("/data/hdd1/kb/agile/bullet/src/pybullet_rendering/ceshiyixia/models/r2d2")

while using client.setAdditionalSearchPath(pybullet_data.getDataPath()) panda3d can visualize the texture of plane, while using client.setAdditionalSearchPath("/data/hdd1/kb/agile/bullet/src/pybullet_rendering/ceshiyixia/models/r2d2") the texture cannot be visualized.
The files in pybullet_data/ and r2d2 are totally same.
Screenshot_2020-06-22_16-32-04
Screenshot_2020-06-22_16-32-19

pybullet_rendering.examples.performance report error for panda3d

while testing python -m pybullet_rendering.examples.performance got warning :display:x11display(error): BadAccess (attempt to access private resource denied) for panda3d and the output image also seems not normal.

pybullet build time: Jun 16 2020 12:09:08
Test tiny...
Test egl...
Loaded EGL 1.5 after reload.
GL_VENDOR=NVIDIA Corporation
GL_RENDERER=GeForce GTX 1070/PCIe/SSE2
GL_VERSION=4.6.0 NVIDIA 418.40.04
GL_SHADING_LANGUAGE_VERSION=4.60 NVIDIA
Version = 4.6.0 NVIDIA 418.40.04
Vendor = NVIDIA Corporation
Renderer = GeForce GTX 1070/PCIe/SSE2
ven = NVIDIA Corporation
ven = NVIDIA Corporation
Destroy EGL OpenGL window.
Test pyrender...
Test panda3d...
:display:x11display(error): BadAccess (attempt to access private resource denied)
:display:gsg:glgsg(error): Could not load program: created-shader (The profile is not supported.)
:display:x11display(error): BadAccess (attempt to access private resource denied)
:display:gsg:glgsg(error): GL error 0x502 : invalid operation
:display:gsg:glgsg(error): An OpenGL error has occurred.  Set gl-debug #t in your PRC file to display more information.
:display:x11display(error): BadAccess (attempt to access private resource denied)
Results:
tiny: 91.50 fps
egl: 337.91 fps
pyrender: 45.63 fps
panda3d: 503.28 fps

color_egl
color_panda3d
color_pyrender
color_tiny

got "Segmentation fault (core dumped)" while testing.

python -m unittest discover tests -v
got

pybullet build time: Feb  6 2020 17:15:24
test_fill_frame (tests.bingings.test_frame.FrameTest) ... ok
test_skip_frame (tests.bingings.test_frame.FrameTest) ... ok
test_box_primitive (tests.bingings.test_scene_graph.SceneGraphTest) ... terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

python -m pybullet_rendering.examples.panda3d_gui --multisamples 8
got

Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
Segmentation fault (core dumped)

Could you please help me to find where is the problem? Thanks!

pybullet.changeVisualShape broken when applying texture mesh and binding an external renderer

The following code runs fine with egl or tiny renderer

import pybullet as p
import pybullet_data
import numpy as np
from pybullet_rendering import RenderingPlugin
from pybullet_rendering.render.panda3d import Renderer


def create_plane_mesh(resx=3, resy=3):
    verts = np.stack(
        np.meshgrid(np.linspace(-0.5, 0.5, resx),
                    np.linspace(-0.5, 0.5, resy))).reshape(2, -1).T
    verts = np.concatenate([verts, np.zeros((len(verts), 1))], -1)
    tris = []
    for i in range(resx - 1):
        for j in range(resy - 1):
            ii = i + resx * j
            tris += [ii, ii + 1, ii + resx]
            tris += [ii + resx, ii + 1, ii + resx + 1]
    uvs = np.stack(
        np.meshgrid(np.linspace(0, 1, resx),
                    np.linspace(0, 1, resy))).reshape(2, -1).T
    normals = np.repeat([[0, 0, 1.0]], len(verts), 0)
    return verts, tris, uvs, normals


physicsClientId = p.connect(p.GUI)#or p.DIRECT for non-graphical version

# bind renderer to pybullet
# renderer = Renderer(MSAA_samples=4)
# plugin = RenderingPlugin(physicsClientId, renderer)

# create texture image
x, y = np.meshgrid(np.linspace(-1,1, 128), np.linspace(-1,1, 128))
img = (72*(np.stack([np.cos(16*x), np.cos(16*y), np.cos(16*(x+y))])+2)).astype(np.uint8).transpose(1,2,0)
from PIL import Image
img = Image.fromarray(img)
fname = 'panda3d_texture_test.png'
img.save(fname)

# create plane mesh
verts, tris, uvs, normals = create_plane_mesh(128, 128)
verts[:, 0] += 0.05*np.cos(8*x.flatten())
verts[:, 1] += 0.05*np.cos(8*y.flatten())
verts[:, 2] += 0.1*np.cos(8*(x+y).flatten())
planeColl = p.createCollisionShape(shapeType=p.GEOM_MESH,
                                   meshScale=[1, 1, 1],
                                   vertices=verts,
                                   indices=tris,
                                   physicsClientId=physicsClientId)

planeVis = p.createVisualShape(shapeType=p.GEOM_MESH,
                               rgbaColor=[1, 1, 1, 1],
                               specularColor=[0.4, .4, 0],
                               meshScale=[1, 1, 1],
                               vertices=verts,
                               indices=tris,
                               uvs=uvs,
                               normals=normals,
                               physicsClientId=physicsClientId)

planeId = p.createMultiBody(0,
                            baseCollisionShapeIndex=planeColl,
                            baseVisualShapeIndex=planeVis,
                            physicsClientId=physicsClientId)



# apply texture to plane
textureId = p.loadTexture(fname, physicsClientId=physicsClientId)
p.changeVisualShape(planeId,
                    -1,
                    textureUniqueId=textureId,
                    rgbaColor=[1, 1, 1, 1],
                    specularColor=[1, 1, 1, 1],
                    physicsClientId=physicsClientId)

# p.disconnect()

Resulting in the following image
image

Binding a panda3d or pyrender renderer, the code above crashes when calling p.changeVisualShape with the following error message

terminate called after throwing an instance of 'std::out_of_range'
what():  map::at

I also tried populating the link arrays for the p.createMultiBody method and callling p.changeVisualShape with the joint index equal to 0 instead of -1, but i got the same result.

TL; DR changeVisualShape is broken with manually created instances of multiBody objects, when the binding the external renderers from this repo. Do you have nay suggestions on how to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.