From b8850f670b86a26f7e7887910ead1ce47b20ee60 Mon Sep 17 00:00:00 2001 From: kngwyu Date: Sun, 16 Aug 2020 14:09:54 +0900 Subject: [PATCH] Use np instead of math --- mujoco_maze/ant.py | 3 +-- mujoco_maze/point.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mujoco_maze/ant.py b/mujoco_maze/ant.py index 942fb4c..cc7c441 100644 --- a/mujoco_maze/ant.py +++ b/mujoco_maze/ant.py @@ -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): diff --git a/mujoco_maze/point.py b/mujoco_maze/point.py index 9b38e2d..4e8c071 100644 --- a/mujoco_maze/point.py +++ b/mujoco_maze/point.py @@ -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):