add yapf style and apply yapf to format all Python files

This recreates pull request #2192
This commit is contained in:
Erwin Coumans
2019-04-27 07:31:15 -07:00
parent c591735042
commit ef9570c315
347 changed files with 70304 additions and 22752 deletions

View File

@@ -1,34 +1,31 @@
#testrender.py is a bit slower than testrender_np.py: pixels are copied from C to Python one by one
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import pybullet
import time
import numpy as np #to reshape for matplotlib
import numpy as np #to reshape for matplotlib
plt.ion()
img = [[1,2,3]*50]*100#np.random.rand(200, 320)
img = [[1, 2, 3] * 50] * 100 #np.random.rand(200, 320)
#img = [tandard_normal((50,100))
image = plt.imshow(img,interpolation='none',animated=True,label="blah")
image = plt.imshow(img, interpolation='none', animated=True, label="blah")
ax = plt.gca()
pybullet.connect(pybullet.DIRECT)
#pybullet.loadPlugin("eglRendererPlugin")
pybullet.loadURDF("plane.urdf",[0,0,-1])
pybullet.loadURDF("plane.urdf", [0, 0, -1])
pybullet.loadURDF("r2d2.urdf")
pybullet.setGravity(0,0,-10)
camTargetPos = [0,0,0]
cameraUp = [0,0,1]
cameraPos = [1,1,1]
pybullet.setGravity(0, 0, -10)
camTargetPos = [0, 0, 0]
cameraUp = [0, 0, 1]
cameraPos = [1, 1, 1]
pitch = -10.0
roll=0
roll = 0
upAxisIndex = 2
camDistance = 4
pixelWidth = 320
@@ -39,41 +36,47 @@ farPlane = 100
fov = 60
main_start = time.time()
while(1):
for yaw in range (0,360,10) :
while (1):
for yaw in range(0, 360, 10):
pybullet.stepSimulation()
start = time.time()
viewMatrix = pybullet.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex)
aspect = pixelWidth / pixelHeight;
projectionMatrix = pybullet.computeProjectionMatrixFOV(fov, aspect, nearPlane, farPlane);
img_arr = pybullet.getCameraImage(pixelWidth, pixelHeight, viewMatrix,projectionMatrix, shadow=1,lightDirection=[1,1,1],renderer=pybullet.ER_BULLET_HARDWARE_OPENGL)
viewMatrix = pybullet.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch,
roll, upAxisIndex)
aspect = pixelWidth / pixelHeight
projectionMatrix = pybullet.computeProjectionMatrixFOV(fov, aspect, nearPlane, farPlane)
img_arr = pybullet.getCameraImage(pixelWidth,
pixelHeight,
viewMatrix,
projectionMatrix,
shadow=1,
lightDirection=[1, 1, 1],
renderer=pybullet.ER_BULLET_HARDWARE_OPENGL)
stop = time.time()
print ("renderImage %f" % (stop - start))
print("renderImage %f" % (stop - start))
w=img_arr[0] #width of the image, in pixels
h=img_arr[1] #height of the image, in pixels
rgb=img_arr[2] #color data RGB
dep=img_arr[3] #depth data
w = img_arr[0] #width of the image, in pixels
h = img_arr[1] #height of the image, in pixels
rgb = img_arr[2] #color data RGB
dep = img_arr[3] #depth data
#print(rgb)
print ('width = %d height = %d' % (w,h))
print('width = %d height = %d' % (w, h))
#note that sending the data using imshow to matplotlib is really slow, so we use set_data
#plt.imshow(rgb,interpolation='none')
#reshape is needed
np_img_arr = np.reshape(rgb, (h, w, 4))
np_img_arr = np_img_arr*(1./255.)
np_img_arr = np_img_arr * (1. / 255.)
image.set_data(np_img_arr)
ax.plot([0])
#plt.draw()
#plt.show()
plt.pause(0.01)
main_stop = time.time()
print ("Total time %f" % (main_stop - main_start))
print("Total time %f" % (main_stop - main_start))
pybullet.resetSimulation()