Skip to content

Instantly share code, notes, and snippets.

@iory
Created November 27, 2017 03:12
Show Gist options
  • Save iory/116f04731be45344a5ac3a638815283e to your computer and use it in GitHub Desktop.
Save iory/116f04731be45344a5ac3a638815283e to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib # NOQA
import matplotlib.pyplot as plt
import pybullet as p
from pybullet_envs.bullet.kukaCamGymEnv import KukaCamGymEnv
env = KukaCamGymEnv(renders=True)
ob = env.reset()
for i in range(0, 180, 5):
camEyePos = [0.03, 0.236, 0.54]
distance = 1.06
pitch = -56
yaw = i
roll = 0
upAxisIndex = 2
camInfo = p.getDebugVisualizerCamera()
viewMat = camInfo[2]
viewMat = p.computeViewMatrixFromYawPitchRoll(
camEyePos, distance, yaw, pitch, roll, upAxisIndex)
projMatrix = camInfo[3]
img_arr = p.getCameraImage(width=env._width,
height=env._height,
viewMatrix=viewMat,
projectionMatrix=projMatrix)
rgb = img_arr[2]
np_img_arr = np.reshape(rgb,
(env._height, env._width, 4))
plt.imshow(np_img_arr)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment