Use np instead of math
This commit is contained in:
parent
1a8d5eb3bb
commit
b8850f670b
@ -6,7 +6,6 @@ Based on `models`_ and `gym`_ (both ant and ant-v3).
|
|||||||
.. _gym: https://github.com/openai/gym
|
.. _gym: https://github.com/openai/gym
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import math
|
|
||||||
from typing import Callable, Optional, Tuple
|
from typing import Callable, Optional, Tuple
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -98,7 +97,7 @@ class AntEnv(AgentModel):
|
|||||||
ori_ind = self.ORI_IND
|
ori_ind = self.ORI_IND
|
||||||
rot = self.sim.data.qpos[ori_ind : ori_ind + 4] # take the quaternion
|
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 = 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
|
return ori
|
||||||
|
|
||||||
def set_xy(self, xy):
|
def set_xy(self, xy):
|
||||||
|
@ -6,7 +6,6 @@ Based on `models`_ and `rllab`_.
|
|||||||
.. _rllab: https://github.com/rll/rllab
|
.. _rllab: https://github.com/rll/rllab
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import math
|
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
import gym
|
import gym
|
||||||
@ -41,8 +40,8 @@ class PointEnv(AgentModel):
|
|||||||
qpos[2] -= np.pi * 2
|
qpos[2] -= np.pi * 2
|
||||||
ori = qpos[2]
|
ori = qpos[2]
|
||||||
# Compute increment in each direction
|
# Compute increment in each direction
|
||||||
qpos[0] += math.cos(ori) * action[0]
|
qpos[0] += np.cos(ori) * action[0]
|
||||||
qpos[1] += math.sin(ori) * action[0]
|
qpos[1] += np.sin(ori) * action[0]
|
||||||
qvel = np.clip(self.sim.data.qvel, -self.VELOCITY_LIMITS, self.VELOCITY_LIMITS)
|
qvel = np.clip(self.sim.data.qvel, -self.VELOCITY_LIMITS, self.VELOCITY_LIMITS)
|
||||||
self.set_state(qpos, qvel)
|
self.set_state(qpos, qvel)
|
||||||
for _ in range(0, self.frame_skip):
|
for _ in range(0, self.frame_skip):
|
||||||
|
Loading…
Reference in New Issue
Block a user