fix setup.py and pybullet to work better with eglPlugin on Linux
This commit is contained in:
@@ -14,25 +14,10 @@
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#ifdef GLEW_STATIC
|
||||
#include "glad/gl.h"
|
||||
#else
|
||||
#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
|
||||
#endif//__APPLE__
|
||||
|
||||
#ifdef BT_NO_GLAD
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#include "glad/glad.h"
|
||||
#endif
|
||||
|
||||
#endif //NO_GLEW
|
||||
#endif //GLEW_STATIC
|
||||
#endif//(__APPLE__)
|
||||
#endif
|
||||
#endif //B3_USE_GLFW
|
||||
|
||||
#include "FontData.h"
|
||||
|
||||
|
||||
@@ -26,13 +26,20 @@ upAxisIndex = 2
|
||||
|
||||
|
||||
while (p.isConnected()):
|
||||
|
||||
for yaw in range (0,360,10) :
|
||||
start = time.time()
|
||||
p.stepSimulation()
|
||||
stop = time.time()
|
||||
print ("stepSimulation %f" % (stop - start))
|
||||
|
||||
#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]
|
||||
viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex)
|
||||
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)
|
||||
|
||||
|
||||
@@ -9603,7 +9603,7 @@ initpybullet_egl(void)
|
||||
initpybullet_grpc(void)
|
||||
#else
|
||||
initpybullet(void)
|
||||
#endif //BT_USE_EGL
|
||||
#endif //BT_USE_EGL2
|
||||
#endif //BT_PYBULLET_GRPC
|
||||
#endif
|
||||
{
|
||||
@@ -9611,14 +9611,14 @@ initpybullet(void)
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
m = PyModule_Create(&moduledef);
|
||||
#else
|
||||
#ifdef BT_USE_EGL
|
||||
#ifdef BT_USE_EGL2
|
||||
m = Py_InitModule3("pybullet_egl", SpamMethods, "Python bindings for Bullet");
|
||||
#else
|
||||
#ifdef BT_PYBULLET_GRPC
|
||||
m = Py_InitModule3("pybullet_grpc", SpamMethods, "Python bindings for Bullet");
|
||||
#else
|
||||
m = Py_InitModule3("pybullet", SpamMethods, "Python bindings for Bullet");
|
||||
#endif //BT_USE_EGL
|
||||
#endif //BT_USE_EGL2
|
||||
#endif //BT_PYBULLET_GRPC
|
||||
#endif
|
||||
|
||||
|
||||
60
setup.py
60
setup.py
@@ -2,12 +2,12 @@
|
||||
from setuptools import find_packages
|
||||
from sys import platform as _platform
|
||||
import sys
|
||||
from glob import glob
|
||||
import glob
|
||||
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
from distutils.util import get_platform
|
||||
|
||||
from glob import glob
|
||||
|
||||
# monkey-patch for parallel compilation
|
||||
import multiprocessing
|
||||
@@ -42,7 +42,10 @@ CXX_FLAGS += '-DBT_USE_DOUBLE_PRECISION '
|
||||
CXX_FLAGS += '-DBT_ENABLE_ENET '
|
||||
CXX_FLAGS += '-DBT_ENABLE_CLSOCKET '
|
||||
CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION '
|
||||
CXX_FLAGS += '-DEGL_ADD_PYTHON_INIT '
|
||||
CXX_FLAGS += '-DBT_USE_EGL '
|
||||
|
||||
EGL_CXX_FLAGS = ''
|
||||
|
||||
|
||||
|
||||
# libraries += [current_python]
|
||||
@@ -282,13 +285,13 @@ sources = ["examples/pybullet/pybullet.c"]\
|
||||
+["src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBody.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp"]\
|
||||
+["src/BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp"]\
|
||||
+["src/BulletDynamics/Vehicle/btRaycastVehicle.cpp"]\
|
||||
@@ -448,10 +451,8 @@ egl_renderer_sources = \
|
||||
+["examples/OpenGLWindow/LoadShader.cpp"] \
|
||||
+["src/LinearMath/btQuickprof.cpp"]
|
||||
|
||||
|
||||
|
||||
if _platform == "linux" or _platform == "linux2":
|
||||
libraries += ['dl','pthread']
|
||||
libraries = ['dl','pthread']
|
||||
CXX_FLAGS += '-D_LINUX '
|
||||
CXX_FLAGS += '-DGLEW_STATIC '
|
||||
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 += '-DHAS_SOCKLEN_T '
|
||||
CXX_FLAGS += '-fno-inline-functions-called-once '
|
||||
CXX_FLAGS += '-fPIC ' # for plugins
|
||||
CXX_FLAGS += '-DBT_USE_EGL '
|
||||
EGL_CXX_FLAGS += '-DBT_USE_EGL '
|
||||
EGL_CXX_FLAGS += '-fPIC ' # for plugins
|
||||
|
||||
sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]
|
||||
|
||||
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]\
|
||||
+["examples/ThirdPartyLibs/glad/glx.c"]
|
||||
include_dirs += ["examples/ThirdPartyLibs/optionalX11"]
|
||||
sources = sources + ["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
|
||||
+ ["examples/ThirdPartyLibs/glad/glx.c"]
|
||||
|
||||
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/OpenGLWindow/EGLOpenGLWindow.cpp']
|
||||
|
||||
if 'BT_USE_EGL' in EGL_CXX_FLAGS:
|
||||
egl_renderer_sources = egl_renderer_sources\
|
||||
+["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\
|
||||
+['examples/ThirdPartyLibs/glad/egl.c']
|
||||
@@ -481,19 +481,16 @@ if _platform == "linux" or _platform == "linux2":
|
||||
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
|
||||
+["examples/ThirdPartyLibs/glad/glx.c"]
|
||||
|
||||
|
||||
elif _platform == "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 += '-DGLEW_STATIC '
|
||||
sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\
|
||||
+["examples/OpenGLWindow/Win32Window.cpp"]\
|
||||
+["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\
|
||||
+["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":
|
||||
print("darwin!")
|
||||
os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL'
|
||||
@@ -505,12 +502,9 @@ elif _platform == "darwin":
|
||||
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]\
|
||||
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
|
||||
egl_renderer_sources = egl_renderer_sources\
|
||||
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
|
||||
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
|
||||
else:
|
||||
print("bsd!")
|
||||
libraries += ['GL','GLEW','pthread']
|
||||
libraries = ['GL','GLEW','pthread']
|
||||
os.environ['LDFLAGS'] = '-L/usr/X11R6/lib'
|
||||
CXX_FLAGS += '-D_BSD '
|
||||
CXX_FLAGS += '-I/usr/X11R6/include '
|
||||
@@ -519,13 +513,7 @@ else:
|
||||
sources = ["examples/ThirdPartyLibs/enet/unix.c"]\
|
||||
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]\
|
||||
+["examples/ThirdPartyLibs/glad/glx.c"]\
|
||||
+ 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__))
|
||||
|
||||
@@ -547,19 +535,17 @@ print("packages")
|
||||
print(find_packages('examples/pybullet/gym'))
|
||||
print("-----")
|
||||
|
||||
|
||||
|
||||
eglRender = Extension("eglRenderer",
|
||||
sources = egl_renderer_sources,
|
||||
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"]
|
||||
)
|
||||
|
||||
|
||||
setup(
|
||||
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',
|
||||
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',
|
||||
@@ -567,12 +553,12 @@ setup(
|
||||
author_email='erwincoumans@google.com',
|
||||
license='zlib',
|
||||
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",
|
||||
sources = sources,
|
||||
libraries = libraries,
|
||||
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',
|
||||
'License :: OSI Approved :: zlib/libpng License',
|
||||
|
||||
Reference in New Issue
Block a user