fix in minitaur.py and add render function in minitaur_gym_env.py
This commit is contained in:
@@ -467,7 +467,7 @@ class Minitaur(object):
|
|||||||
motor_angle = copy.deepcopy(actions)
|
motor_angle = copy.deepcopy(actions)
|
||||||
scale_for_singularity = 1
|
scale_for_singularity = 1
|
||||||
offset_for_singularity = 1.5
|
offset_for_singularity = 1.5
|
||||||
half_num_motors = self.num_motors / 2
|
half_num_motors = int(self.num_motors / 2)
|
||||||
quater_pi = math.pi / 4
|
quater_pi = math.pi / 4
|
||||||
for i in range(self.num_motors):
|
for i in range(self.num_motors):
|
||||||
action_idx = i // 2
|
action_idx = i // 2
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ MOTOR_TORQUE_OBSERVATION_INDEX = MOTOR_VELOCITY_OBSERVATION_INDEX + NUM_MOTORS
|
|||||||
BASE_ORIENTATION_OBSERVATION_INDEX = MOTOR_TORQUE_OBSERVATION_INDEX + NUM_MOTORS
|
BASE_ORIENTATION_OBSERVATION_INDEX = MOTOR_TORQUE_OBSERVATION_INDEX + NUM_MOTORS
|
||||||
ACTION_EPS = 0.01
|
ACTION_EPS = 0.01
|
||||||
OBSERVATION_EPS = 0.01
|
OBSERVATION_EPS = 0.01
|
||||||
|
RENDER_HEIGHT = 720
|
||||||
|
RENDER_WIDTH = 960
|
||||||
|
|
||||||
class MinitaurBulletEnv(gym.Env):
|
class MinitaurBulletEnv(gym.Env):
|
||||||
"""The gym environment for the minitaur.
|
"""The gym environment for the minitaur.
|
||||||
@@ -258,8 +259,26 @@ class MinitaurBulletEnv(gym.Env):
|
|||||||
done = self._termination()
|
done = self._termination()
|
||||||
return np.array(self._noisy_observation()), reward, done, {}
|
return np.array(self._noisy_observation()), reward, done, {}
|
||||||
|
|
||||||
def _render(self, mode="human", close=False):
|
def _render(self, mode="rgb_array", close=False):
|
||||||
return
|
if mode != "rgb_array":
|
||||||
|
return np.array([])
|
||||||
|
base_pos = self.minitaur.GetBasePosition()
|
||||||
|
view_matrix = self._pybullet_client.computeViewMatrixFromYawPitchRoll(
|
||||||
|
cameraTargetPosition=base_pos,
|
||||||
|
distance=self._cam_dist,
|
||||||
|
yaw=self._cam_yaw,
|
||||||
|
pitch=self._cam_pitch,
|
||||||
|
roll=0,
|
||||||
|
upAxisIndex=2)
|
||||||
|
proj_matrix = self._pybullet_client.computeProjectionMatrixFOV(
|
||||||
|
fov=60, aspect=float(RENDER_WIDTH)/RENDER_HEIGHT,
|
||||||
|
nearVal=0.1, farVal=100.0)
|
||||||
|
(_, _, px, _, _) = self._pybullet_client.getCameraImage(
|
||||||
|
width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix,
|
||||||
|
projectionMatrix=proj_matrix)
|
||||||
|
rgb_array = np.array(px)
|
||||||
|
rgb_array = rgb_array[:, :, :3]
|
||||||
|
return rgb_array
|
||||||
|
|
||||||
def get_minitaur_motor_angles(self):
|
def get_minitaur_motor_angles(self):
|
||||||
"""Get the minitaur's motor angles.
|
"""Get the minitaur's motor angles.
|
||||||
|
|||||||
Reference in New Issue
Block a user