improve testrender/np to render faster/interactive on Mac with matplotlib
This commit is contained in:
@@ -6,10 +6,19 @@ import matplotlib.pyplot as plt
|
||||
import pybullet
|
||||
import time
|
||||
|
||||
plt.ion()
|
||||
|
||||
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")
|
||||
ax = plt.gca()
|
||||
|
||||
|
||||
pybullet.connect(pybullet.DIRECT)
|
||||
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]
|
||||
@@ -27,7 +36,9 @@ farPlane = 100
|
||||
fov = 60
|
||||
|
||||
main_start = time.time()
|
||||
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;
|
||||
@@ -40,15 +51,18 @@ for yaw in range (0,360,10) :
|
||||
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))
|
||||
|
||||
#note that sending the data to matplotlib is really slow
|
||||
|
||||
plt.imshow(rgb,interpolation='none')
|
||||
plt.show(block=False)
|
||||
plt.pause(0.001)
|
||||
#note that sending the data using imshow to matplotlib is really slow, so we use set_data
|
||||
|
||||
#plt.imshow(rgb,interpolation='none')
|
||||
image.set_data(rgb)
|
||||
ax.plot([0])
|
||||
#plt.draw()
|
||||
#plt.show()
|
||||
plt.pause(0.01)
|
||||
|
||||
main_stop = time.time()
|
||||
|
||||
print ("Total time %f" % (main_stop - main_start))
|
||||
|
||||
Reference in New Issue
Block a user