This commit is contained in:
Erwin Coumans
2018-09-12 08:20:03 -07:00
5 changed files with 203 additions and 221 deletions

View File

@@ -6,6 +6,9 @@ del pybullet.grpc.pb.h
..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc --proto_path=. --cpp_out=. pybullet.proto ..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc --proto_path=. --cpp_out=. pybullet.proto
..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc.exe --plugin=protoc-gen-grpc="..\..\..\ThirdPartyLibs\grpc\lib\win32\grpc_cpp_plugin.exe" --grpc_out=. pybullet.proto ..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc.exe --plugin=protoc-gen-grpc="..\..\..\ThirdPartyLibs\grpc\lib\win32\grpc_cpp_plugin.exe" --grpc_out=. pybullet.proto
rename pybullet.grpc.pb.cc pybullet.grpc.pb.cpp
rename pybullet.pb.cc pybullet.pb.cpp
del pybullet_pb2.py del pybullet_pb2.py
del pybullet_pb2_grpc.py del pybullet_pb2_grpc.py

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

@@ -26,13 +26,20 @@ 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()
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 = [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) 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] 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]) 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) #time.sleep(.1)
#print("img_arr=",img_arr) #print("img_arr=",img_arr)

View File

@@ -9603,7 +9603,7 @@ initpybullet_egl(void)
initpybullet_grpc(void) initpybullet_grpc(void)
#else #else
initpybullet(void) initpybullet(void)
#endif //BT_USE_EGL #endif //BT_USE_EGL2
#endif //BT_PYBULLET_GRPC #endif //BT_PYBULLET_GRPC
#endif #endif
{ {
@@ -9611,14 +9611,14 @@ initpybullet(void)
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef); m = PyModule_Create(&moduledef);
#else #else
#ifdef BT_USE_EGL #ifdef BT_USE_EGL2
m = Py_InitModule3("pybullet_egl", SpamMethods, "Python bindings for Bullet"); m = Py_InitModule3("pybullet_egl", SpamMethods, "Python bindings for Bullet");
#else #else
#ifdef BT_PYBULLET_GRPC #ifdef BT_PYBULLET_GRPC
m = Py_InitModule3("pybullet_grpc", SpamMethods, "Python bindings for Bullet"); m = Py_InitModule3("pybullet_grpc", SpamMethods, "Python bindings for Bullet");
#else #else
m = Py_InitModule3("pybullet", SpamMethods, "Python bindings for Bullet"); m = Py_InitModule3("pybullet", SpamMethods, "Python bindings for Bullet");
#endif //BT_USE_EGL #endif //BT_USE_EGL2
#endif //BT_PYBULLET_GRPC #endif //BT_PYBULLET_GRPC
#endif #endif

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,40 +460,37 @@ 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"]
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"] 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']
else: else:
sources = sources + ["examples/ThirdPartyLibs/glad/glx.c"]\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]
egl_renderer_sources = egl_renderer_sources\ egl_renderer_sources = egl_renderer_sources\
+["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'
@@ -504,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 '
@@ -518,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__))
@@ -546,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',
@@ -566,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',