fix setup.py and pybullet to work better with eglPlugin on Linux

This commit is contained in:
Erwin Coumans
2018-09-11 13:24:35 -07:00
parent 36c900e384
commit 23ecbab7b3
4 changed files with 201 additions and 223 deletions

View File

@@ -14,25 +14,10 @@
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#else #else
#ifdef GLEW_STATIC
#include "glad/gl.h" #include "glad/gl.h"
#else #endif//__APPLE__
#ifdef NO_GLEW
#define GL_GLEXT_LEGACY
#include "third_party/GL/gl/include/GL/gl.h"
#include "third_party/GL/gl/include/GL/glext.h"
#else
#ifdef BT_NO_GLAD #endif //B3_USE_GLFW
#include <GL/glew.h>
#else
#include "glad/glad.h"
#endif
#endif //NO_GLEW
#endif //GLEW_STATIC
#endif//(__APPLE__)
#endif
#include "FontData.h" #include "FontData.h"

View File

@@ -8,7 +8,7 @@ p.connect(p.DIRECT)
plugin = p.loadPlugin(egl.get_filename(), "_eglRendererPlugin") plugin = p.loadPlugin(egl.get_filename(), "_eglRendererPlugin")
print("plugin=",plugin) print("plugin=",plugin)
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0) p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0) p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
@@ -26,15 +26,22 @@ upAxisIndex = 2
while (p.isConnected()): while (p.isConnected()):
for yaw in range (0,360,10) :
for yaw in range (0,360,10) : start = time.time()
p.stepSimulation() p.stepSimulation()
#viewMatrix = [1.0, 0.0, -0.0, 0.0, -0.0, 0.1736481785774231, -0.9848078489303589, 0.0, 0.0, 0.9848078489303589, 0.1736481785774231, 0.0, -0.0, -5.960464477539063e-08, -4.0, 1.0] stop = time.time()
viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex) print ("stepSimulation %f" % (stop - start))
projectionMatrix = [1.0825318098068237, 0.0, 0.0, 0.0, 0.0, 1.732050895690918, 0.0, 0.0, 0.0, 0.0, -1.0002000331878662, -1.0, 0.0, 0.0, -0.020002000033855438, 0.0]
img_arr = p.getCameraImage(pixelWidth, pixelHeight, viewMatrix=viewMatrix, projectionMatrix=projectionMatrix, shadow=1,lightDirection=[1,1,1]) #viewMatrix = [1.0, 0.0, -0.0, 0.0, -0.0, 0.1736481785774231, -0.9848078489303589, 0.0, 0.0, 0.9848078489303589, 0.1736481785774231, 0.0, -0.0, -5.960464477539063e-08, -4.0, 1.0]
#time.sleep(.1) viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex)
#print("img_arr=",img_arr) projectionMatrix = [1.0825318098068237, 0.0, 0.0, 0.0, 0.0, 1.732050895690918, 0.0, 0.0, 0.0, 0.0, -1.0002000331878662, -1.0, 0.0, 0.0, -0.020002000033855438, 0.0]
start = time.time()
img_arr = p.getCameraImage(pixelWidth, pixelHeight, viewMatrix=viewMatrix, projectionMatrix=projectionMatrix, shadow=1,lightDirection=[1,1,1])
stop = time.time()
print ("renderImage %f" % (stop - start))
#time.sleep(.1)
#print("img_arr=",img_arr)
p.unloadPlugin(plugin) p.unloadPlugin(plugin)

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,12 @@
from setuptools import find_packages from setuptools import find_packages
from sys import platform as _platform from sys import platform as _platform
import sys import sys
from glob import glob import glob
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from distutils.util import get_platform from distutils.util import get_platform
from glob import glob
# monkey-patch for parallel compilation # monkey-patch for parallel compilation
import multiprocessing import multiprocessing
@@ -42,7 +42,10 @@ CXX_FLAGS += '-DBT_USE_DOUBLE_PRECISION '
CXX_FLAGS += '-DBT_ENABLE_ENET ' CXX_FLAGS += '-DBT_ENABLE_ENET '
CXX_FLAGS += '-DBT_ENABLE_CLSOCKET ' CXX_FLAGS += '-DBT_ENABLE_CLSOCKET '
CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION ' CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION '
CXX_FLAGS += '-DEGL_ADD_PYTHON_INIT ' CXX_FLAGS += '-DBT_USE_EGL '
EGL_CXX_FLAGS = ''
# libraries += [current_python] # libraries += [current_python]
@@ -282,13 +285,13 @@ sources = ["examples/pybullet/pybullet.c"]\
+["src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp"]\ +["src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBody.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBody.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp"]\
+["src/BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp"]\ +["src/BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp"]\
+["src/BulletDynamics/Vehicle/btRaycastVehicle.cpp"]\ +["src/BulletDynamics/Vehicle/btRaycastVehicle.cpp"]\
@@ -448,10 +451,8 @@ egl_renderer_sources = \
+["examples/OpenGLWindow/LoadShader.cpp"] \ +["examples/OpenGLWindow/LoadShader.cpp"] \
+["src/LinearMath/btQuickprof.cpp"] +["src/LinearMath/btQuickprof.cpp"]
if _platform == "linux" or _platform == "linux2": if _platform == "linux" or _platform == "linux2":
libraries += ['dl','pthread'] libraries = ['dl','pthread']
CXX_FLAGS += '-D_LINUX ' CXX_FLAGS += '-D_LINUX '
CXX_FLAGS += '-DGLEW_STATIC ' CXX_FLAGS += '-DGLEW_STATIC '
CXX_FLAGS += '-DGLEW_INIT_OPENGL11_FUNCTIONS=1 ' CXX_FLAGS += '-DGLEW_INIT_OPENGL11_FUNCTIONS=1 '
@@ -459,20 +460,19 @@ if _platform == "linux" or _platform == "linux2":
CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS ' CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS '
CXX_FLAGS += '-DHAS_SOCKLEN_T ' CXX_FLAGS += '-DHAS_SOCKLEN_T '
CXX_FLAGS += '-fno-inline-functions-called-once ' CXX_FLAGS += '-fno-inline-functions-called-once '
CXX_FLAGS += '-fPIC ' # for plugins EGL_CXX_FLAGS += '-DBT_USE_EGL '
CXX_FLAGS += '-DBT_USE_EGL ' EGL_CXX_FLAGS += '-fPIC ' # for plugins
sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\
+["examples/ThirdPartyLibs/glad/gl.c"]
include_dirs += ["examples/ThirdPartyLibs/optionalX11"]
sources = sources + ["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+ ["examples/ThirdPartyLibs/glad/glx.c"]
sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/ThirdPartyLibs/glad/glx.c"]
include_dirs += ["examples/ThirdPartyLibs/optionalX11"]
if 'BT_USE_EGL' in CXX_FLAGS: if 'BT_USE_EGL' in CXX_FLAGS:
# linking with bullet's Glew libraries causes segfault
# for some reason.
sources += ['examples/ThirdPartyLibs/glad/egl.c'] sources += ['examples/ThirdPartyLibs/glad/egl.c']
sources += ['examples/OpenGLWindow/EGLOpenGLWindow.cpp'] sources += ['examples/OpenGLWindow/EGLOpenGLWindow.cpp']
if 'BT_USE_EGL' in EGL_CXX_FLAGS:
egl_renderer_sources = egl_renderer_sources\ egl_renderer_sources = egl_renderer_sources\
+["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\ +["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\
+['examples/ThirdPartyLibs/glad/egl.c'] +['examples/ThirdPartyLibs/glad/egl.c']
@@ -481,19 +481,16 @@ if _platform == "linux" or _platform == "linux2":
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/glx.c"] +["examples/ThirdPartyLibs/glad/glx.c"]
elif _platform == "win32": elif _platform == "win32":
print("win32!") print("win32!")
libraries += ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32'] libraries = ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32']
CXX_FLAGS += '-DWIN32 ' CXX_FLAGS += '-DWIN32 '
CXX_FLAGS += '-DGLEW_STATIC ' CXX_FLAGS += '-DGLEW_STATIC '
sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\ sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\
+["examples/OpenGLWindow/Win32Window.cpp"]\ +["examples/OpenGLWindow/Win32Window.cpp"]\
+["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\ +["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"] +["examples/ThirdPartyLibs/glad/gl.c"]
egl_renderer_sources = egl_renderer_sources\
+["examples/ThirdPartyLibs/enet/win32.c"]\
+["examples/OpenGLWindow/Win32Window.cpp"]\
+["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]
elif _platform == "darwin": elif _platform == "darwin":
print("darwin!") print("darwin!")
os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL' os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL'
@@ -505,12 +502,9 @@ elif _platform == "darwin":
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\ +["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"] +["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
egl_renderer_sources = egl_renderer_sources\
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
else: else:
print("bsd!") print("bsd!")
libraries += ['GL','GLEW','pthread'] libraries = ['GL','GLEW','pthread']
os.environ['LDFLAGS'] = '-L/usr/X11R6/lib' os.environ['LDFLAGS'] = '-L/usr/X11R6/lib'
CXX_FLAGS += '-D_BSD ' CXX_FLAGS += '-D_BSD '
CXX_FLAGS += '-I/usr/X11R6/include ' CXX_FLAGS += '-I/usr/X11R6/include '
@@ -519,13 +513,7 @@ else:
sources = ["examples/ThirdPartyLibs/enet/unix.c"]\ sources = ["examples/ThirdPartyLibs/enet/unix.c"]\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/ThirdPartyLibs/glad/glx.c"]\
+ sources + sources
egl_renderer_sources = egl_renderer_sources\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/ThirdPartyLibs/glad/glx.c"]
setup_py_dir = os.path.dirname(os.path.realpath(__file__)) setup_py_dir = os.path.dirname(os.path.realpath(__file__))
@@ -547,19 +535,17 @@ print("packages")
print(find_packages('examples/pybullet/gym')) print(find_packages('examples/pybullet/gym'))
print("-----") print("-----")
eglRender = Extension("eglRenderer", eglRender = Extension("eglRenderer",
sources = egl_renderer_sources, sources = egl_renderer_sources,
libraries = libraries, libraries = libraries,
extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL ').split(), extra_compile_args=(CXX_FLAGS+EGL_CXX_FLAGS ).split(),
include_dirs = include_dirs + ["src","examples", "examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"] include_dirs = include_dirs + ["src","examples", "examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"]
) )
setup( setup(
name = 'pybullet', name = 'pybullet',
version='2.1.4', version='2.1.2',
description='Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning', description='Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning',
long_description='pybullet is an easy to use Python module for physics simulation, robotics and deep reinforcement learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.', long_description='pybullet is an easy to use Python module for physics simulation, robotics and deep reinforcement learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.',
url='https://github.com/bulletphysics/bullet3', url='https://github.com/bulletphysics/bullet3',
@@ -567,12 +553,12 @@ setup(
author_email='erwincoumans@google.com', author_email='erwincoumans@google.com',
license='zlib', license='zlib',
platforms='any', platforms='any',
keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'reinforcement learning', 'collision detection', 'opengl'], keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'collision detection', 'opengl'],
ext_modules = [eglRender, Extension("pybullet", ext_modules = [eglRender, Extension("pybullet",
sources = sources, sources = sources,
libraries = libraries, libraries = libraries,
extra_compile_args=CXX_FLAGS.split(), extra_compile_args=CXX_FLAGS.split(),
include_dirs = include_dirs + ["src","examples", "examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"] include_dirs = include_dirs + ["src","examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"]
) ], ) ],
classifiers=['Development Status :: 5 - Production/Stable', classifiers=['Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: zlib/libpng License', 'License :: OSI Approved :: zlib/libpng License',