Use np instead of math

This commit is contained in:
kngwyu 2020-08-16 14:09:54 +09:00
parent 1a8d5eb3bb
commit b8850f670b
2 changed files with 3 additions and 5 deletions

View File

@ -6,7 +6,6 @@ Based on `models`_ and `gym`_ (both ant and ant-v3).
.. _gym: https://github.com/openai/gym
"""
import math
from typing import Callable, Optional, Tuple
import numpy as np
@ -98,7 +97,7 @@ class AntEnv(AgentModel):
ori_ind = self.ORI_IND
rot = self.sim.data.qpos[ori_ind : ori_ind + 4] # take the quaternion
ori = q_mult(q_mult(rot, ori), q_inv(rot))[1:3] # project onto x-y plane
ori = math.atan2(ori[1], ori[0])
ori = np.arctan2(ori[1], ori[0])
return ori
def set_xy(self, xy):

View File

@ -6,7 +6,6 @@ Based on `models`_ and `rllab`_.
.. _rllab: https://github.com/rll/rllab
"""
import math
from typing import Optional, Tuple
import gym
@ -41,8 +40,8 @@ class PointEnv(AgentModel):
qpos[2] -= np.pi * 2
ori = qpos[2]
# Compute increment in each direction
qpos[0] += math.cos(ori) * action[0]
qpos[1] += math.sin(ori) * action[0]
qpos[0] += np.cos(ori) * action[0]
qpos[1] += np.sin(ori) * action[0]
qvel = np.clip(self.sim.data.qvel, -self.VELOCITY_LIMITS, self.VELOCITY_LIMITS)
self.set_state(qpos, qvel)
for _ in range(0, self.frame_skip):