first commit: Mujoco Reacher 5 links
This commit is contained in:
commit
246fa16326
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/test.iml" filepath="$PROJECT_DIR$/.idea/test.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/test.iml
Normal file
8
.idea/test.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.7 (trustpo)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
7
.idea/workspace.xml
Normal file
7
.idea/workspace.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectId" id="1f34JcS8cW6etuDYcTUPuS96rln" />
|
||||||
|
<component name="PropertiesComponent">
|
||||||
|
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||||
|
</component>
|
||||||
|
</project>
|
15
MUJOCO_LOG.TXT
Normal file
15
MUJOCO_LOG.TXT
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Fri Aug 28 14:41:56 2020
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
||||||
|
Fri Aug 28 14:59:14 2020
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
||||||
|
Fri Aug 28 15:03:43 2020
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
||||||
|
Fri Aug 28 15:07:03 2020
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
||||||
|
Fri Aug 28 15:15:01 2020
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
10
reacher.egg-info/PKG-INFO
Normal file
10
reacher.egg-info/PKG-INFO
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Metadata-Version: 1.0
|
||||||
|
Name: reacher
|
||||||
|
Version: 0.0.1
|
||||||
|
Summary: UNKNOWN
|
||||||
|
Home-page: UNKNOWN
|
||||||
|
Author: UNKNOWN
|
||||||
|
Author-email: UNKNOWN
|
||||||
|
License: UNKNOWN
|
||||||
|
Description: UNKNOWN
|
||||||
|
Platform: UNKNOWN
|
6
reacher.egg-info/SOURCES.txt
Normal file
6
reacher.egg-info/SOURCES.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
setup.py
|
||||||
|
reacher.egg-info/PKG-INFO
|
||||||
|
reacher.egg-info/SOURCES.txt
|
||||||
|
reacher.egg-info/dependency_links.txt
|
||||||
|
reacher.egg-info/requires.txt
|
||||||
|
reacher.egg-info/top_level.txt
|
1
reacher.egg-info/dependency_links.txt
Normal file
1
reacher.egg-info/dependency_links.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
1
reacher.egg-info/requires.txt
Normal file
1
reacher.egg-info/requires.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
gym
|
1
reacher.egg-info/top_level.txt
Normal file
1
reacher.egg-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
6
reacher/__init__.py
Normal file
6
reacher/__init__.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from gym.envs.registration import register
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='ReacherALREnv-v0',
|
||||||
|
entry_point='reacher.envs:ReacherALREnv',
|
||||||
|
)
|
BIN
reacher/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
reacher/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
1
reacher/envs/__init__.py
Normal file
1
reacher/envs/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from reacher.envs.reacher_env import ReacherALREnv
|
BIN
reacher/envs/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
reacher/envs/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
reacher/envs/__pycache__/reacher_env.cpython-37.pyc
Normal file
BIN
reacher/envs/__pycache__/reacher_env.cpython-37.pyc
Normal file
Binary file not shown.
54
reacher/envs/reacher_5links.xml
Normal file
54
reacher/envs/reacher_5links.xml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<mujoco model="reacher">
|
||||||
|
<compiler angle="radian" inertiafromgeom="true"/>
|
||||||
|
<default>
|
||||||
|
<joint armature="1" damping="1" limited="true"/>
|
||||||
|
<geom contype="0" friction="1 0.1 0.1" rgba="0.7 0.7 0 1"/>
|
||||||
|
</default>
|
||||||
|
<option gravity="0 0 -9.81" integrator="RK4" timestep="0.01"/>
|
||||||
|
<worldbody>
|
||||||
|
<!-- Arena -->
|
||||||
|
<geom conaffinity="0" contype="0" name="ground" pos="0 0 0" rgba="0.9 0.9 0.9 1" size="1 1 10" type="plane"/>
|
||||||
|
<geom conaffinity="0" fromto="-.6 -.6 .01 .6 -.6 .01" name="sideS" rgba="0.9 0.4 0.6 1" size=".02" type="capsule"/>
|
||||||
|
<geom conaffinity="0" fromto=" .6 -.6 .01 .6 .6 .01" name="sideE" rgba="0.9 0.4 0.6 1" size=".02" type="capsule"/>
|
||||||
|
<geom conaffinity="0" fromto="-.6 .6 .01 .6 .6 .01" name="sideN" rgba="0.9 0.4 0.6 1" size=".02" type="capsule"/>
|
||||||
|
<geom conaffinity="0" fromto="-.6 -.6 .01 -.6 .6 .01" name="sideW" rgba="0.9 0.4 0.6 1" size=".02" type="capsule"/>
|
||||||
|
<!-- Arm -->
|
||||||
|
<geom conaffinity="0" contype="0" fromto="0 0 0 0 0 0.02" name="root" rgba="0.9 0.4 0.6 1" size=".011" type="cylinder"/>
|
||||||
|
<body name="body0" pos="0 0 .01">
|
||||||
|
<geom fromto="0 0 0 0.1 0 0" name="link0" rgba="0.0 0.4 0.6 1" size=".01" type="capsule"/>
|
||||||
|
<joint axis="0 0 1" limited="false" name="joint0" pos="0 0 0" type="hinge"/>
|
||||||
|
<body name="body1" pos="0.1 0 0">
|
||||||
|
<joint axis="0 0 1" limited="false" name="joint1" pos="0 0 0" type="hinge"/>
|
||||||
|
<geom fromto="0 0 0 0.1 0 0" name="link1" rgba="0.0 0.4 0.6 1" size=".01" type="capsule"/>
|
||||||
|
<body name="body2" pos="0.1 0 0">
|
||||||
|
<joint axis="0 0 1" limited="false" name="joint2" pos="0 0 0" type="hinge"/>
|
||||||
|
<geom fromto="0 0 0 0.1 0 0" name="link2" rgba="0.0 0.4 0.6 1" size=".01" type="capsule"/>
|
||||||
|
<body name="body3" pos="0.1 0 0">
|
||||||
|
<joint axis="0 0 1" limited="false" name="joint3" pos="0 0 0" type="hinge"/>
|
||||||
|
<geom fromto="0 0 0 0.1 0 0" name="link3" rgba="0.0 0.4 0.6 1" size=".01" type="capsule"/>
|
||||||
|
<body name="body4" pos="0.1 0 0">
|
||||||
|
<joint axis="0 0 1" limited="true" name="joint4" pos="0 0 0" range="-3.0 3.0" type="hinge"/>
|
||||||
|
<geom fromto="0 0 0 0.1 0 0" name="link4" rgba="0.0 0.4 0.6 1" size=".01" type="capsule"/>
|
||||||
|
<body name="fingertip" pos="0.11 0 0">
|
||||||
|
<geom contype="0" name="fingertip" pos="0 0 0" rgba="0.0 0.8 0.6 1" size=".01" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
<!-- Target -->
|
||||||
|
<body name="target" pos=".1 -.1 .01">
|
||||||
|
<joint armature="0" axis="1 0 0" damping="0" limited="true" name="target_x" pos="0 0 0" range="-.27 .27" ref=".1" stiffness="0" type="slide"/>
|
||||||
|
<joint armature="0" axis="0 1 0" damping="0" limited="true" name="target_y" pos="0 0 0" range="-.27 .27" ref="-.1" stiffness="0" type="slide"/>
|
||||||
|
<geom conaffinity="0" contype="0" name="target" pos="0 0 0" rgba="0.9 0.2 0.2 1" size=".009" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<actuator>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="200.0" joint="joint0"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="200.0" joint="joint1"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="200.0" joint="joint2"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="200.0" joint="joint3"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="200.0" joint="joint4"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
44
reacher/envs/reacher_env.py
Normal file
44
reacher/envs/reacher_env.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import numpy as np
|
||||||
|
from gym import utils
|
||||||
|
from gym.envs.mujoco import mujoco_env
|
||||||
|
|
||||||
|
class ReacherALREnv(mujoco_env.MujocoEnv, utils.EzPickle):
|
||||||
|
def __init__(self):
|
||||||
|
utils.EzPickle.__init__(self)
|
||||||
|
mujoco_env.MujocoEnv.__init__(self, '/home/vien/git/reacher_test/reacher/envs/reacher_5links.xml', 2)
|
||||||
|
|
||||||
|
def step(self, a):
|
||||||
|
vec = self.get_body_com("fingertip")-self.get_body_com("target")
|
||||||
|
reward_dist = - np.linalg.norm(vec)
|
||||||
|
reward_ctrl = - np.square(a).sum()
|
||||||
|
reward = reward_dist + reward_ctrl
|
||||||
|
self.do_simulation(a, self.frame_skip)
|
||||||
|
ob = self._get_obs()
|
||||||
|
done = False
|
||||||
|
return ob, reward, done, dict(reward_dist=reward_dist, reward_ctrl=reward_ctrl)
|
||||||
|
|
||||||
|
def viewer_setup(self):
|
||||||
|
self.viewer.cam.trackbodyid = 0
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
qpos = self.np_random.uniform(low=-0.1, high=0.1, size=self.model.nq) + self.init_qpos
|
||||||
|
while True:
|
||||||
|
self.goal = self.np_random.uniform(low=-.2, high=.2, size=2)
|
||||||
|
if np.linalg.norm(self.goal) < 0.2:
|
||||||
|
break
|
||||||
|
qpos[-2:] = self.goal
|
||||||
|
qvel = self.init_qvel + self.np_random.uniform(low=-.005, high=.005, size=self.model.nv)
|
||||||
|
qvel[-2:] = 0
|
||||||
|
self.set_state(qpos, qvel)
|
||||||
|
|
||||||
|
return self._get_obs()
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self.sim.data.qpos.flat[:5]
|
||||||
|
return np.concatenate([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
self.sim.data.qpos.flat[5:], # this is goal position
|
||||||
|
self.sim.data.qvel.flat[:5], # this is angular velocity
|
||||||
|
self.get_body_com("fingertip") - self.get_body_com("target")
|
||||||
|
])
|
6
setup.py
Normal file
6
setup.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(name='reacher',
|
||||||
|
version='0.0.1',
|
||||||
|
install_requires=['gym'] # And any other dependencies foo needs
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user