Merge with stochastic search branch
This commit is contained in:
commit
0097fe4f99
56
README.md
56
README.md
@ -1,34 +1,50 @@
|
|||||||
## ALR Custom Environments
|
## ALR Environments
|
||||||
|
|
||||||
This repository collects custom RL envs not included in Suits like OpenAI gym, rllab, etc.
|
This repository collects custom Robotics environments not included in benchmark suites like OpenAI gym, rllab, etc.
|
||||||
Creating a custom (Mujoco) gym environement can be done according to [this guide](https://github.com/openai/gym/blob/master/docs/creating-environments.md).
|
Creating a custom (Mujoco) gym environment can be done according to [this guide](https://github.com/openai/gym/blob/master/docs/creating-environments.md).
|
||||||
For stochastic search problems with gym interace use the Rosenbrock reference implementation.
|
For stochastic search problems with gym interface use the `Rosenbrock-v0` reference implementation.
|
||||||
|
We also support to solve environments with DMPs. When adding new DMP tasks check the `ViaPointReacherDMP-v0` reference implementation.
|
||||||
|
When simply using the tasks, you can also leverage the wrapper class `DmpWrapper` to turn normal gym environments in to DMP tasks.
|
||||||
|
|
||||||
## Environments
|
## Environments
|
||||||
Currently we have the following environements:
|
Currently we have the following environments:
|
||||||
|
|
||||||
### Mujoco
|
### Mujoco
|
||||||
|
|
||||||
|Name| Description|
|
|Name| Description|Horizon|Action Dimension|Observation Dimension
|
||||||
|---|---|
|
|---|---|---|---|---|
|
||||||
|`ALRReacher-v0`|Modified (5 links) Mujoco gym's `Reacher-v2` (2 links)|
|
|`ALRReacher-v0`|Modified (5 links) Mujoco gym's `Reacher-v2` (2 links)| 200 | 5 | 21
|
||||||
|`ALRReacherSparse-v0`|Same as `ALRReacher-v0`, but the distance penalty is only provided in the last time step.|
|
|`ALRReacherSparse-v0`|Same as `ALRReacher-v0`, but the distance penalty is only provided in the last time step.| 200 | 5 | 21
|
||||||
|`ALRReacherSparseBalanced-v0`|Same as `ALRReacherSparse-v0`, but the the end effector has to stay upright.|
|
|`ALRReacherSparseBalanced-v0`|Same as `ALRReacherSparse-v0`, but the end-effector has to remain upright.| 200 | 5 | 21
|
||||||
|`ALRReacherShort-v0`|Same as `ALRReacher-v0`, but the episode length is reduced to 50.|
|
|`ALRLongReacher-v0`|Modified (7 links) Mujoco gym's `Reacher-v2` (2 links)| 200 | 7 | 27
|
||||||
|`ALRReacherShortSparse-v0`|Combination of `ALRReacherSparse-v0` and `ALRReacherShort-v0`.|
|
|`ALRLongReacherSparse-v0`|Same as `ALRLongReacher-v0`, but the distance penalty is only provided in the last time step.| 200 | 7 | 27
|
||||||
|`ALRReacher7-v0`|Modified (7 links) Mujoco gym's `Reacher-v2` (2 links)|
|
|`ALRLongReacherSparseBalanced-v0`|Same as `ALRLongReacherSparse-v0`, but the end-effector has to remain upright.| 200 | 7 | 27
|
||||||
|`ALRReacher7Sparse-v0`|Same as `ALRReacher7-v0`, but the distance penalty is only provided in the last time step.|
|
|
||||||
|
|
||||||
### Classic Control
|
### Classic Control
|
||||||
|
|
||||||
|Name| Description|
|
|Name| Description|Horizon|Action Dimension|Observation Dimension
|
||||||
|---|---|
|
|---|---|---|---|---|
|
||||||
|`SimpleReacher-v0`| Simple Reaching Task without any physics simulation. Returns no reward until 150 time steps. This allows the agent to explore the space, but requires precise actions towards the end of the trajectory.|
|
|`SimpleReacher-v0`| Simple reaching task (2 links) without any physics simulation. Provides no reward until 150 time steps. This allows the agent to explore the space, but requires precise actions towards the end of the trajectory.| 200 | 2 | 9
|
||||||
|
|`LongSimpleReacher-v0`| Simple reaching task (5 links) without any physics simulation. Provides no reward until 150 time steps. This allows the agent to explore the space, but requires precise actions towards the end of the trajectory.| 200 | 5 | 18
|
||||||
|
|`ViaPointReacher-v0`| Simple reaching task leveraging a via point, which supports self collision detection. Provides a reward only at 100 and 199 for reaching the viapoint and goal point, respectively.| 200 |
|
||||||
|
|`HoleReacher-v0`|
|
||||||
|
|
||||||
|
### DMP Environments
|
||||||
|
These environments are closer to stochastic search. They always execute a full trajectory, which is computed by a DMP and executed by a controller, e.g. a PD controller.
|
||||||
|
The goal is to learn the parameters of this DMP to generate a suitable trajectory.
|
||||||
|
All environments provide the full episode reward and additional information about early terminations, e.g. due to collisions.
|
||||||
|
|
||||||
|
|Name| Description|Horizon|Action Dimension|Observation Dimension
|
||||||
|
|---|---|---|---|---|
|
||||||
|
|`ViaPointReacherDMP-v0`| Simple reaching task leveraging a via point, which supports self collision detection. Provides a reward only at 100 and 199 for reaching the viapoint and goal point, respectively.| 200 |
|
||||||
|
|`HoleReacherDMP-v0`|
|
||||||
|
|`HoleReacherFixedGoalDMP-v0`|
|
||||||
|
|`HoleReacherDetPMP-v0`|
|
||||||
|
|
||||||
### Stochastic Search
|
### Stochastic Search
|
||||||
|Name| Description|
|
|Name| Description|Horizon|Action Dimension|Observation Dimension
|
||||||
|---|---|
|
|---|---|---|---|---|
|
||||||
|`Rosenbrock{dim}-v0`| Gym interface for Rosenbrock function. `{dim}` is one of 5, 10, 25, 50 or 100. |
|
|`Rosenbrock{dim}-v0`| Gym interface for Rosenbrock function. `{dim}` is one of 5, 10, 25, 50 or 100. | 1 | `{dim}` | 0
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from gym.envs.registration import register
|
from gym.envs.registration import register
|
||||||
|
|
||||||
from alr_envs.stochastic_search.functions.f_rosenbrock import Rosenbrock
|
from alr_envs.stochastic_search.functions.f_rosenbrock import Rosenbrock
|
||||||
|
from alr_envs.utils.wrapper.dmp_wrapper import DmpWrapper
|
||||||
|
|
||||||
|
# Mujoco
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='ALRReacher-v0',
|
id='ALRReacher-v0',
|
||||||
@ -9,6 +12,7 @@ register(
|
|||||||
kwargs={
|
kwargs={
|
||||||
"steps_before_reward": 0,
|
"steps_before_reward": 0,
|
||||||
"n_links": 5,
|
"n_links": 5,
|
||||||
|
"balance": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,6 +23,7 @@ register(
|
|||||||
kwargs={
|
kwargs={
|
||||||
"steps_before_reward": 200,
|
"steps_before_reward": 200,
|
||||||
"n_links": 5,
|
"n_links": 5,
|
||||||
|
"balance": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,64 +39,39 @@ register(
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='ALRReacherShort-v0',
|
id='ALRLongReacher-v0',
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
|
||||||
max_episode_steps=50,
|
|
||||||
kwargs={
|
|
||||||
"steps_before_reward": 0,
|
|
||||||
"n_links": 5,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
register(
|
|
||||||
id='ALRReacherShortSparse-v0',
|
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
|
||||||
max_episode_steps=50,
|
|
||||||
kwargs={
|
|
||||||
"steps_before_reward": 50,
|
|
||||||
"n_links": 5,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
register(
|
|
||||||
id='ALRReacher7-v0',
|
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
||||||
max_episode_steps=200,
|
max_episode_steps=200,
|
||||||
kwargs={
|
kwargs={
|
||||||
"steps_before_reward": 0,
|
"steps_before_reward": 0,
|
||||||
"n_links": 7,
|
"n_links": 7,
|
||||||
|
"balance": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='ALRReacher7Sparse-v0',
|
id='ALRLongReacherSparse-v0',
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
||||||
max_episode_steps=200,
|
max_episode_steps=200,
|
||||||
kwargs={
|
kwargs={
|
||||||
"steps_before_reward": 200,
|
"steps_before_reward": 200,
|
||||||
"n_links": 7,
|
"n_links": 7,
|
||||||
|
"balance": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='ALRReacher7Short-v0',
|
id='ALRLongReacherSparseBalanced-v0',
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
||||||
max_episode_steps=50,
|
max_episode_steps=200,
|
||||||
kwargs={
|
kwargs={
|
||||||
"steps_before_reward": 0,
|
"steps_before_reward": 200,
|
||||||
"n_links": 7,
|
"n_links": 7,
|
||||||
|
"balance": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
register(
|
# Classic control
|
||||||
id='ALRReacher7ShortSparse-v0',
|
|
||||||
entry_point='alr_envs.mujoco:ALRReacherEnv',
|
|
||||||
max_episode_steps=50,
|
|
||||||
kwargs={
|
|
||||||
"steps_before_reward": 50,
|
|
||||||
"n_links": 7,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='Balancing-v0',
|
id='Balancing-v0',
|
||||||
@ -112,7 +92,7 @@ register(
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(
|
register(
|
||||||
id='SimpleReacher5-v0',
|
id='LongSimpleReacher-v0',
|
||||||
entry_point='alr_envs.classic_control:SimpleReacherEnv',
|
entry_point='alr_envs.classic_control:SimpleReacherEnv',
|
||||||
max_episode_steps=200,
|
max_episode_steps=200,
|
||||||
kwargs={
|
kwargs={
|
||||||
@ -120,12 +100,66 @@ register(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='ViaPointReacher-v0',
|
||||||
|
entry_point='alr_envs.classic_control.viapoint_reacher:ViaPointReacher',
|
||||||
|
max_episode_steps=200,
|
||||||
|
kwargs={
|
||||||
|
"n_links": 5,
|
||||||
|
"allow_self_collision": False,
|
||||||
|
"collision_penalty": 1000
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='HoleReacher-v0',
|
||||||
|
entry_point='alr_envs.classic_control.hole_reacher:HoleReacher',
|
||||||
|
max_episode_steps=200,
|
||||||
|
kwargs={
|
||||||
|
"n_links": 5,
|
||||||
|
"allow_self_collision": False,
|
||||||
|
"allow_wall_collision": False,
|
||||||
|
"hole_width": 0.15,
|
||||||
|
"hole_depth": 1,
|
||||||
|
"hole_x": 1,
|
||||||
|
"collision_penalty": 100,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
# DMP environments
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='ViaPointReacherDMP-v0',
|
||||||
|
entry_point='alr_envs.classic_control.viapoint_reacher:viapoint_dmp',
|
||||||
|
# max_episode_steps=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='HoleReacherDMP-v0',
|
||||||
|
entry_point='alr_envs.classic_control.hole_reacher:holereacher_dmp',
|
||||||
|
# max_episode_steps=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='HoleReacherFixedGoalDMP-v0',
|
||||||
|
entry_point='alr_envs.classic_control.hole_reacher:holereacher_fix_goal_dmp',
|
||||||
|
# max_episode_steps=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
register(
|
||||||
|
id='HoleReacherDetPMP-v0',
|
||||||
|
entry_point='alr_envs.classic_control.hole_reacher:holereacher_detpmp',
|
||||||
|
# max_episode_steps=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# BBO functions
|
||||||
|
|
||||||
for dim in [5, 10, 25, 50, 100]:
|
for dim in [5, 10, 25, 50, 100]:
|
||||||
register(
|
register(
|
||||||
id=f'Rosenbrock{dim}-v0',
|
id=f'Rosenbrock{dim}-v0',
|
||||||
entry_point='alr_envs.stochastic_search:StochasticSearchEnv',
|
entry_point='alr_envs.stochastic_search:StochasticSearchEnv',
|
||||||
max_episode_steps=1,
|
max_episode_steps=1,
|
||||||
kwargs={
|
kwargs={
|
||||||
"cost_f": Rosenbrock,
|
"cost_f": Rosenbrock(dim),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1 +1,3 @@
|
|||||||
from alr_envs.classic_control.simple_reacher import SimpleReacherEnv
|
from alr_envs.classic_control.simple_reacher import SimpleReacherEnv
|
||||||
|
from alr_envs.classic_control.viapoint_reacher import ViaPointReacher
|
||||||
|
from alr_envs.classic_control.hole_reacher import HoleReacher
|
325
alr_envs/classic_control/hole_reacher.py
Normal file
325
alr_envs/classic_control/hole_reacher.py
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
import gym
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib import patches
|
||||||
|
|
||||||
|
from alr_envs import DmpWrapper
|
||||||
|
from alr_envs.utils.wrapper.detpmp_wrapper import DetPMPWrapper
|
||||||
|
|
||||||
|
|
||||||
|
def ccw(A, B, C):
|
||||||
|
return (C[1] - A[1]) * (B[0] - A[0]) - (B[1] - A[1]) * (C[0] - A[0]) > 1e-12
|
||||||
|
|
||||||
|
|
||||||
|
# Return true if line segments AB and CD intersect
|
||||||
|
def intersect(A, B, C, D):
|
||||||
|
return ccw(A, C, D) != ccw(B, C, D) and ccw(A, B, C) != ccw(A, B, D)
|
||||||
|
|
||||||
|
|
||||||
|
def holereacher_dmp(**kwargs):
|
||||||
|
_env = gym.make("alr_envs:HoleReacher-v0")
|
||||||
|
# _env = HoleReacher(**kwargs)
|
||||||
|
return DmpWrapper(_env, num_dof=5, num_basis=5, duration=2, dt=_env.dt, learn_goal=True, alpha_phase=3.5,
|
||||||
|
start_pos=_env.start_pos, policy_type="velocity", weights_scale=100, goal_scale=0.1)
|
||||||
|
|
||||||
|
|
||||||
|
def holereacher_fix_goal_dmp(**kwargs):
|
||||||
|
_env = gym.make("alr_envs:HoleReacher-v0")
|
||||||
|
# _env = HoleReacher(**kwargs)
|
||||||
|
return DmpWrapper(_env, num_dof=5, num_basis=5, duration=2, dt=_env.dt, learn_goal=False, alpha_phase=3.5,
|
||||||
|
start_pos=_env.start_pos, policy_type="velocity", weights_scale=50, goal_scale=1,
|
||||||
|
final_pos=np.array([2.02669572, -1.25966385, -1.51618198, -0.80946476, 0.02012344]))
|
||||||
|
|
||||||
|
|
||||||
|
def holereacher_detpmp(**kwargs):
|
||||||
|
_env = gym.make("alr_envs:HoleReacher-v0")
|
||||||
|
# _env = HoleReacher(**kwargs)
|
||||||
|
return DetPMPWrapper(_env, num_dof=5, num_basis=5, width=0.005, policy_type="velocity", start_pos=_env.start_pos,
|
||||||
|
duration=2, post_traj_time=0, dt=_env.dt, weights_scale=0.25, zero_start=True, zero_goal=False)
|
||||||
|
|
||||||
|
|
||||||
|
class HoleReacher(gym.Env):
|
||||||
|
|
||||||
|
def __init__(self, n_links, hole_x, hole_width, hole_depth, allow_self_collision=False,
|
||||||
|
allow_wall_collision=False, collision_penalty=1000):
|
||||||
|
|
||||||
|
self.n_links = n_links
|
||||||
|
self.link_lengths = np.ones((n_links, 1))
|
||||||
|
|
||||||
|
# task
|
||||||
|
self.hole_x = hole_x # x-position of center of hole
|
||||||
|
self.hole_width = hole_width # width of hole
|
||||||
|
self.hole_depth = hole_depth # depth of hole
|
||||||
|
|
||||||
|
self.bottom_center_of_hole = np.hstack([hole_x, -hole_depth])
|
||||||
|
self.top_center_of_hole = np.hstack([hole_x, 0])
|
||||||
|
self.left_wall_edge = np.hstack([hole_x - self.hole_width / 2, 0])
|
||||||
|
self.right_wall_edge = np.hstack([hole_x + self.hole_width / 2, 0])
|
||||||
|
|
||||||
|
# collision
|
||||||
|
self.allow_self_collision = allow_self_collision
|
||||||
|
self.allow_wall_collision = allow_wall_collision
|
||||||
|
self.collision_penalty = collision_penalty
|
||||||
|
|
||||||
|
# state
|
||||||
|
self._joints = None
|
||||||
|
self._joint_angles = None
|
||||||
|
self._angle_velocity = None
|
||||||
|
self.start_pos = np.hstack([[np.pi / 2], np.zeros(self.n_links - 1)])
|
||||||
|
self.start_vel = np.zeros(self.n_links)
|
||||||
|
|
||||||
|
self.dt = 0.01
|
||||||
|
# self.time_limit = 2
|
||||||
|
|
||||||
|
action_bound = np.pi * np.ones((self.n_links,))
|
||||||
|
state_bound = np.hstack([
|
||||||
|
[np.pi] * self.n_links, # cos
|
||||||
|
[np.pi] * self.n_links, # sin
|
||||||
|
[np.inf] * self.n_links, # velocity
|
||||||
|
[np.inf] * 2, # x-y coordinates of target distance
|
||||||
|
[np.inf] # env steps, because reward start after n steps TODO: Maybe
|
||||||
|
])
|
||||||
|
self.action_space = gym.spaces.Box(low=-action_bound, high=action_bound, shape=action_bound.shape)
|
||||||
|
self.observation_space = gym.spaces.Box(low=-state_bound, high=state_bound, shape=state_bound.shape)
|
||||||
|
|
||||||
|
self.fig = None
|
||||||
|
rect_1 = patches.Rectangle((-self.n_links, -1),
|
||||||
|
self.n_links + self.hole_x - self.hole_width / 2, 1,
|
||||||
|
fill=True, edgecolor='k', facecolor='k')
|
||||||
|
rect_2 = patches.Rectangle((self.hole_x + self.hole_width / 2, -1),
|
||||||
|
self.n_links - self.hole_x + self.hole_width / 2, 1,
|
||||||
|
fill=True, edgecolor='k', facecolor='k')
|
||||||
|
rect_3 = patches.Rectangle((self.hole_x - self.hole_width / 2, -1), self.hole_width,
|
||||||
|
1 - self.hole_depth,
|
||||||
|
fill=True, edgecolor='k', facecolor='k')
|
||||||
|
|
||||||
|
self.patches = [rect_1, rect_2, rect_3]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_effector(self):
|
||||||
|
return self._joints[self.n_links].T
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self._joint_angles = self.start_pos
|
||||||
|
self._angle_velocity = self.start_vel
|
||||||
|
self._joints = np.zeros((self.n_links + 1, 2))
|
||||||
|
self._update_joints()
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
return self._get_obs().copy()
|
||||||
|
|
||||||
|
def step(self, action: np.ndarray):
|
||||||
|
"""
|
||||||
|
a single step with an action in joint velocity space
|
||||||
|
"""
|
||||||
|
vel = action # + 0.01 * np.random.randn(self.num_links)
|
||||||
|
acc = (vel - self._angle_velocity) / self.dt
|
||||||
|
self._angle_velocity = vel
|
||||||
|
self._joint_angles = self._joint_angles + self.dt * self._angle_velocity
|
||||||
|
|
||||||
|
self._update_joints()
|
||||||
|
|
||||||
|
reward = 0
|
||||||
|
if self._is_collided:
|
||||||
|
reward = -self.collision_penalty
|
||||||
|
else:
|
||||||
|
if self._steps == 199:
|
||||||
|
reward = - np.linalg.norm(self.end_effector - self.bottom_center_of_hole) ** 2
|
||||||
|
|
||||||
|
reward -= 5e-8 * np.sum(acc ** 2)
|
||||||
|
|
||||||
|
info = {"is_collided": self._is_collided}
|
||||||
|
|
||||||
|
self._steps += 1
|
||||||
|
|
||||||
|
# done = self._steps * self.dt > self.time_limit or self._is_collided
|
||||||
|
done = self._is_collided
|
||||||
|
|
||||||
|
return self._get_obs().copy(), reward, done, info
|
||||||
|
|
||||||
|
def _update_joints(self):
|
||||||
|
"""
|
||||||
|
update _joints to get new end effector position. The other links are only required for rendering.
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
line_points_in_taskspace = self.get_forward_kinematics(num_points_per_link=20)
|
||||||
|
|
||||||
|
self._joints[1:, 0] = self._joints[0, 0] + line_points_in_taskspace[:, -1, 0]
|
||||||
|
self._joints[1:, 1] = self._joints[0, 1] + line_points_in_taskspace[:, -1, 1]
|
||||||
|
|
||||||
|
self_collision = False
|
||||||
|
wall_collision = False
|
||||||
|
|
||||||
|
if not self.allow_self_collision:
|
||||||
|
self_collision = self.check_self_collision(line_points_in_taskspace)
|
||||||
|
if np.any(np.abs(self._joint_angles) > np.pi) and not self.allow_self_collision:
|
||||||
|
self_collision = True
|
||||||
|
|
||||||
|
if not self.allow_wall_collision:
|
||||||
|
wall_collision = self.check_wall_collision(line_points_in_taskspace)
|
||||||
|
|
||||||
|
self._is_collided = self_collision or wall_collision
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self._joint_angles
|
||||||
|
return np.hstack([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
self._angle_velocity,
|
||||||
|
self.end_effector - self.bottom_center_of_hole,
|
||||||
|
self._steps
|
||||||
|
])
|
||||||
|
|
||||||
|
def get_forward_kinematics(self, num_points_per_link=1):
|
||||||
|
theta = self._joint_angles[:, None]
|
||||||
|
|
||||||
|
if num_points_per_link > 1:
|
||||||
|
intermediate_points = np.linspace(0, 1, num_points_per_link)
|
||||||
|
else:
|
||||||
|
intermediate_points = 1
|
||||||
|
|
||||||
|
accumulated_theta = np.cumsum(theta, axis=0)
|
||||||
|
|
||||||
|
endeffector = np.zeros(shape=(self.n_links, num_points_per_link, 2))
|
||||||
|
|
||||||
|
x = np.cos(accumulated_theta) * self.link_lengths * intermediate_points
|
||||||
|
y = np.sin(accumulated_theta) * self.link_lengths * intermediate_points
|
||||||
|
|
||||||
|
endeffector[0, :, 0] = x[0, :]
|
||||||
|
endeffector[0, :, 1] = y[0, :]
|
||||||
|
|
||||||
|
for i in range(1, self.n_links):
|
||||||
|
endeffector[i, :, 0] = x[i, :] + endeffector[i - 1, -1, 0]
|
||||||
|
endeffector[i, :, 1] = y[i, :] + endeffector[i - 1, -1, 1]
|
||||||
|
|
||||||
|
return np.squeeze(endeffector + self._joints[0, :])
|
||||||
|
|
||||||
|
def check_self_collision(self, line_points):
|
||||||
|
for i, line1 in enumerate(line_points):
|
||||||
|
for line2 in line_points[i + 2:, :, :]:
|
||||||
|
# if line1 != line2:
|
||||||
|
if intersect(line1[0], line1[-1], line2[0], line2[-1]):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_wall_collision(self, line_points):
|
||||||
|
|
||||||
|
# all points that are before the hole in x
|
||||||
|
r, c = np.where(line_points[:, :, 0] < (self.hole_x - self.hole_width / 2))
|
||||||
|
|
||||||
|
# check if any of those points are below surface
|
||||||
|
nr_line_points_below_surface_before_hole = np.sum(line_points[r, c, 1] < 0)
|
||||||
|
|
||||||
|
if nr_line_points_below_surface_before_hole > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# all points that are after the hole in x
|
||||||
|
r, c = np.where(line_points[:, :, 0] > (self.hole_x + self.hole_width / 2))
|
||||||
|
|
||||||
|
# check if any of those points are below surface
|
||||||
|
nr_line_points_below_surface_after_hole = np.sum(line_points[r, c, 1] < 0)
|
||||||
|
|
||||||
|
if nr_line_points_below_surface_after_hole > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# all points that are above the hole
|
||||||
|
r, c = np.where((line_points[:, :, 0] > (self.hole_x - self.hole_width / 2)) & (
|
||||||
|
line_points[:, :, 0] < (self.hole_x + self.hole_width / 2)))
|
||||||
|
|
||||||
|
# check if any of those points are below surface
|
||||||
|
nr_line_points_below_surface_in_hole = np.sum(line_points[r, c, 1] < -self.hole_depth)
|
||||||
|
|
||||||
|
if nr_line_points_below_surface_in_hole > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def render(self, mode='human'):
|
||||||
|
if self.fig is None:
|
||||||
|
self.fig = plt.figure()
|
||||||
|
# plt.ion()
|
||||||
|
# plt.pause(0.01)
|
||||||
|
else:
|
||||||
|
plt.figure(self.fig.number)
|
||||||
|
|
||||||
|
if mode == "human":
|
||||||
|
plt.cla()
|
||||||
|
plt.title(f"Iteration: {self._steps}, distance: {self.end_effector - self.bottom_center_of_hole}")
|
||||||
|
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k')
|
||||||
|
|
||||||
|
# Add the patch to the Axes
|
||||||
|
[plt.gca().add_patch(rect) for rect in self.patches]
|
||||||
|
|
||||||
|
lim = np.sum(self.link_lengths) + 0.5
|
||||||
|
plt.xlim([-lim, lim])
|
||||||
|
plt.ylim([-1.1, lim])
|
||||||
|
# plt.draw()
|
||||||
|
plt.pause(1e-4) # pushes window to foreground, which is annoying.
|
||||||
|
# self.fig.canvas.flush_events()
|
||||||
|
|
||||||
|
elif mode == "partial":
|
||||||
|
if self._steps == 1:
|
||||||
|
# fig, ax = plt.subplots()
|
||||||
|
# Add the patch to the Axes
|
||||||
|
[plt.gca().add_patch(rect) for rect in self.patches]
|
||||||
|
# plt.pause(0.01)
|
||||||
|
|
||||||
|
if self._steps % 20 == 0 or self._steps in [1, 199] or self._is_collided:
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k', alpha=self._steps / 200)
|
||||||
|
# ax.plot(line_points_in_taskspace[:, 0, 0],
|
||||||
|
# line_points_in_taskspace[:, 0, 1],
|
||||||
|
# line_points_in_taskspace[:, -1, 0],
|
||||||
|
# line_points_in_taskspace[:, -1, 1], marker='o', color='k', alpha=t / 200)
|
||||||
|
|
||||||
|
lim = np.sum(self.link_lengths) + 0.5
|
||||||
|
plt.xlim([-lim, lim])
|
||||||
|
plt.ylim([-1.1, lim])
|
||||||
|
plt.pause(0.01)
|
||||||
|
|
||||||
|
elif mode == "final":
|
||||||
|
if self._steps == 199 or self._is_collided:
|
||||||
|
# fig, ax = plt.subplots()
|
||||||
|
|
||||||
|
# Add the patch to the Axes
|
||||||
|
[plt.gca().add_patch(rect) for rect in self.patches]
|
||||||
|
|
||||||
|
plt.xlim(-self.n_links, self.n_links), plt.ylim(-1, self.n_links)
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k')
|
||||||
|
|
||||||
|
plt.pause(0.01)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.fig is not None:
|
||||||
|
plt.close(self.fig)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
nl = 5
|
||||||
|
render_mode = "human" # "human" or "partial" or "final"
|
||||||
|
env = HoleReacher(n_links=nl, allow_self_collision=False, allow_wall_collision=False, hole_width=0.15,
|
||||||
|
hole_depth=1, hole_x=1)
|
||||||
|
env.reset()
|
||||||
|
# env.render(mode=render_mode)
|
||||||
|
|
||||||
|
for i in range(200):
|
||||||
|
# objective.load_result("/tmp/cma")
|
||||||
|
# test with random actions
|
||||||
|
ac = 2 * env.action_space.sample()
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render(mode=render_mode)
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
@ -1,14 +1,14 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
import gym
|
import gym
|
||||||
import matplotlib as mpl
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from gym import spaces
|
from gym import spaces
|
||||||
from gym.utils import seeding
|
from gym.utils import seeding
|
||||||
|
|
||||||
if os.environ.get("DISPLAY", None):
|
from alr_envs.utils.utils import angle_normalize
|
||||||
mpl.use('Qt5Agg')
|
|
||||||
|
|
||||||
|
# if os.environ.get("DISPLAY", None):
|
||||||
|
# mpl.use('Qt5Agg')
|
||||||
|
|
||||||
|
|
||||||
class SimpleReacherEnv(gym.Env):
|
class SimpleReacherEnv(gym.Env):
|
||||||
@ -31,7 +31,7 @@ class SimpleReacherEnv(gym.Env):
|
|||||||
self._angle_velocity = None
|
self._angle_velocity = None
|
||||||
|
|
||||||
self.max_torque = 1 # 10
|
self.max_torque = 1 # 10
|
||||||
self.steps_before_reward = 180
|
self.steps_before_reward = 199
|
||||||
|
|
||||||
action_bound = np.ones((self.n_links,))
|
action_bound = np.ones((self.n_links,))
|
||||||
state_bound = np.hstack([
|
state_bound = np.hstack([
|
||||||
@ -90,7 +90,7 @@ class SimpleReacherEnv(gym.Env):
|
|||||||
|
|
||||||
def _update_joints(self):
|
def _update_joints(self):
|
||||||
"""
|
"""
|
||||||
update _joints to get new end effector position. The other links are only required for rendering.
|
update joints to get new end-effector position. The other links are only required for rendering.
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -104,7 +104,7 @@ class SimpleReacherEnv(gym.Env):
|
|||||||
|
|
||||||
# TODO: Is this the best option
|
# TODO: Is this the best option
|
||||||
if self._steps >= self.steps_before_reward:
|
if self._steps >= self.steps_before_reward:
|
||||||
reward_dist = - np.linalg.norm(diff)
|
reward_dist -= np.linalg.norm(diff)
|
||||||
# reward_dist = np.exp(-0.1 * diff ** 2).mean()
|
# reward_dist = np.exp(-0.1 * diff ** 2).mean()
|
||||||
# reward_dist = - (diff ** 2).mean()
|
# reward_dist = - (diff ** 2).mean()
|
||||||
|
|
||||||
|
155
alr_envs/classic_control/utils.py
Normal file
155
alr_envs/classic_control/utils.py
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
from alr_envs.classic_control.hole_reacher import HoleReacher
|
||||||
|
from alr_envs.classic_control.viapoint_reacher import ViaPointReacher
|
||||||
|
from alr_envs.utils.wrapper.dmp_wrapper import DmpWrapper
|
||||||
|
from alr_envs.utils.wrapper.detpmp_wrapper import DetPMPWrapper
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def make_viapointreacher_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
_env = ViaPointReacher(n_links=5,
|
||||||
|
allow_self_collision=False,
|
||||||
|
collision_penalty=1000)
|
||||||
|
|
||||||
|
_env = DmpWrapper(_env,
|
||||||
|
num_dof=5,
|
||||||
|
num_basis=5,
|
||||||
|
duration=2,
|
||||||
|
alpha_phase=2.5,
|
||||||
|
dt=_env.dt,
|
||||||
|
start_pos=_env.start_pos,
|
||||||
|
learn_goal=False,
|
||||||
|
policy_type="velocity",
|
||||||
|
weights_scale=50)
|
||||||
|
_env.seed(seed + rank)
|
||||||
|
return _env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_holereacher_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
_env = HoleReacher(n_links=5,
|
||||||
|
allow_self_collision=False,
|
||||||
|
allow_wall_collision=False,
|
||||||
|
hole_width=0.15,
|
||||||
|
hole_depth=1,
|
||||||
|
hole_x=1,
|
||||||
|
collision_penalty=100)
|
||||||
|
|
||||||
|
_env = DmpWrapper(_env,
|
||||||
|
num_dof=5,
|
||||||
|
num_basis=5,
|
||||||
|
duration=2,
|
||||||
|
dt=_env.dt,
|
||||||
|
learn_goal=True,
|
||||||
|
alpha_phase=3.5,
|
||||||
|
start_pos=_env.start_pos,
|
||||||
|
policy_type="velocity",
|
||||||
|
weights_scale=100,
|
||||||
|
goal_scale=0.1
|
||||||
|
)
|
||||||
|
|
||||||
|
_env.seed(seed + rank)
|
||||||
|
return _env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_holereacher_fix_goal_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
_env = HoleReacher(n_links=5,
|
||||||
|
allow_self_collision=False,
|
||||||
|
allow_wall_collision=False,
|
||||||
|
hole_width=0.15,
|
||||||
|
hole_depth=1,
|
||||||
|
hole_x=1,
|
||||||
|
collision_penalty=100)
|
||||||
|
|
||||||
|
_env = DmpWrapper(_env,
|
||||||
|
num_dof=5,
|
||||||
|
num_basis=5,
|
||||||
|
duration=2,
|
||||||
|
dt=_env.dt,
|
||||||
|
learn_goal=False,
|
||||||
|
final_pos=np.array([2.02669572, -1.25966385, -1.51618198, -0.80946476, 0.02012344]),
|
||||||
|
alpha_phase=3.5,
|
||||||
|
start_pos=_env.start_pos,
|
||||||
|
policy_type="velocity",
|
||||||
|
weights_scale=50,
|
||||||
|
goal_scale=1
|
||||||
|
)
|
||||||
|
|
||||||
|
_env.seed(seed + rank)
|
||||||
|
return _env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_holereacher_env_pmp(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
_env = HoleReacher(n_links=5,
|
||||||
|
allow_self_collision=False,
|
||||||
|
allow_wall_collision=False,
|
||||||
|
hole_width=0.15,
|
||||||
|
hole_depth=1,
|
||||||
|
hole_x=1,
|
||||||
|
collision_penalty=1000)
|
||||||
|
|
||||||
|
_env = DetPMPWrapper(_env,
|
||||||
|
num_dof=5,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="velocity",
|
||||||
|
start_pos=_env.start_pos,
|
||||||
|
duration=2,
|
||||||
|
post_traj_time=0,
|
||||||
|
dt=_env.dt,
|
||||||
|
weights_scale=0.25,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=False
|
||||||
|
)
|
||||||
|
_env.seed(seed + rank)
|
||||||
|
return _env
|
||||||
|
|
||||||
|
return _init
|
241
alr_envs/classic_control/viapoint_reacher.py
Normal file
241
alr_envs/classic_control/viapoint_reacher.py
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
import gym
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from alr_envs import DmpWrapper
|
||||||
|
from alr_envs.utils.utils import check_self_collision
|
||||||
|
|
||||||
|
|
||||||
|
def viapoint_dmp(**kwargs):
|
||||||
|
_env = gym.make("alr_envs:ViaPointReacher-v0")
|
||||||
|
# _env = ViaPointReacher(**kwargs)
|
||||||
|
return DmpWrapper(_env, num_dof=5, num_basis=5, duration=2, alpha_phase=2.5, dt=_env.dt,
|
||||||
|
start_pos=_env.start_pos, learn_goal=False, policy_type="velocity", weights_scale=50)
|
||||||
|
|
||||||
|
|
||||||
|
class ViaPointReacher(gym.Env):
|
||||||
|
|
||||||
|
def __init__(self, n_links, allow_self_collision=False, collision_penalty=1000):
|
||||||
|
self.num_links = n_links
|
||||||
|
self.link_lengths = np.ones((n_links, 1))
|
||||||
|
|
||||||
|
# task
|
||||||
|
self.via_point = np.ones(2)
|
||||||
|
self.goal_point = np.array((n_links, 0))
|
||||||
|
|
||||||
|
# collision
|
||||||
|
self.allow_self_collision = allow_self_collision
|
||||||
|
self.collision_penalty = collision_penalty
|
||||||
|
|
||||||
|
# state
|
||||||
|
self._joints = None
|
||||||
|
self._joint_angles = None
|
||||||
|
self._angle_velocity = None
|
||||||
|
self.start_pos = np.hstack([[np.pi / 2], np.zeros(self.num_links - 1)])
|
||||||
|
self.start_vel = np.zeros(self.num_links)
|
||||||
|
self.weight_matrix_scale = 1
|
||||||
|
|
||||||
|
self._steps = 0
|
||||||
|
self.dt = 0.01
|
||||||
|
# self.time_limit = 2
|
||||||
|
|
||||||
|
action_bound = np.pi * np.ones((self.num_links,))
|
||||||
|
state_bound = np.hstack([
|
||||||
|
[np.pi] * self.num_links, # cos
|
||||||
|
[np.pi] * self.num_links, # sin
|
||||||
|
[np.inf] * self.num_links, # velocity
|
||||||
|
[np.inf] * 2, # x-y coordinates of target distance
|
||||||
|
[np.inf] # env steps, because reward start after n steps TODO: Maybe
|
||||||
|
])
|
||||||
|
self.action_space = gym.spaces.Box(low=-action_bound, high=action_bound, shape=action_bound.shape)
|
||||||
|
self.observation_space = gym.spaces.Box(low=-state_bound, high=state_bound, shape=state_bound.shape)
|
||||||
|
|
||||||
|
self.fig = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def end_effector(self):
|
||||||
|
return self._joints[self.num_links].T
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self._joint_angles = self.start_pos
|
||||||
|
self._angle_velocity = self.start_vel
|
||||||
|
self._joints = np.zeros((self.num_links + 1, 2))
|
||||||
|
self._update_joints()
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
return self._get_obs().copy()
|
||||||
|
|
||||||
|
def step(self, action: np.ndarray):
|
||||||
|
"""
|
||||||
|
a single step with an action in joint velocity space
|
||||||
|
"""
|
||||||
|
vel = action
|
||||||
|
acc = (vel - self._angle_velocity) / self.dt
|
||||||
|
self._angle_velocity = vel
|
||||||
|
self._joint_angles = self._joint_angles + self.dt * self._angle_velocity
|
||||||
|
|
||||||
|
self._update_joints()
|
||||||
|
|
||||||
|
dist_reward = 0
|
||||||
|
if not self._is_collided:
|
||||||
|
if self._steps == 100:
|
||||||
|
dist_reward = np.linalg.norm(self.end_effector - self.via_point)
|
||||||
|
elif self._steps == 199:
|
||||||
|
dist_reward = np.linalg.norm(self.end_effector - self.goal_point)
|
||||||
|
|
||||||
|
# TODO: Do we need that?
|
||||||
|
reward = - dist_reward ** 2
|
||||||
|
|
||||||
|
reward -= 1e-6 * np.sum(acc ** 2)
|
||||||
|
|
||||||
|
if self._steps == 200:
|
||||||
|
reward -= 0.1 * np.sum(vel ** 2) ** 2
|
||||||
|
|
||||||
|
if self._is_collided:
|
||||||
|
reward -= self.collision_penalty
|
||||||
|
|
||||||
|
info = {"is_collided": self._is_collided}
|
||||||
|
|
||||||
|
self._steps += 1
|
||||||
|
|
||||||
|
# done = self._steps * self.dt > self.time_limit or self._is_collided
|
||||||
|
done = self._is_collided
|
||||||
|
|
||||||
|
return self._get_obs().copy(), reward, done, info
|
||||||
|
|
||||||
|
def _update_joints(self):
|
||||||
|
"""
|
||||||
|
update _joints to get new end effector position. The other links are only required for rendering.
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
line_points_in_taskspace = self.get_forward_kinematics(num_points_per_link=20)
|
||||||
|
|
||||||
|
self._joints[1:, 0] = self._joints[0, 0] + line_points_in_taskspace[:, -1, 0]
|
||||||
|
self._joints[1:, 1] = self._joints[0, 1] + line_points_in_taskspace[:, -1, 1]
|
||||||
|
|
||||||
|
self_collision = False
|
||||||
|
|
||||||
|
if not self.allow_self_collision:
|
||||||
|
self_collision = check_self_collision(line_points_in_taskspace)
|
||||||
|
if np.any(np.abs(self._joint_angles) > np.pi):
|
||||||
|
self_collision = True
|
||||||
|
|
||||||
|
self._is_collided = self_collision
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self._joint_angles
|
||||||
|
return np.hstack([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
self._angle_velocity,
|
||||||
|
self.end_effector - self.via_point,
|
||||||
|
self.end_effector - self.goal_point,
|
||||||
|
self._steps
|
||||||
|
])
|
||||||
|
|
||||||
|
def get_forward_kinematics(self, num_points_per_link=1):
|
||||||
|
theta = self._joint_angles[:, None]
|
||||||
|
|
||||||
|
intermediate_points = np.linspace(0, 1, num_points_per_link) if num_points_per_link > 1 else 1
|
||||||
|
|
||||||
|
accumulated_theta = np.cumsum(theta, axis=0)
|
||||||
|
|
||||||
|
endeffector = np.zeros(shape=(self.num_links, num_points_per_link, 2))
|
||||||
|
|
||||||
|
x = np.cos(accumulated_theta) * self.link_lengths * intermediate_points
|
||||||
|
y = np.sin(accumulated_theta) * self.link_lengths * intermediate_points
|
||||||
|
|
||||||
|
endeffector[0, :, 0] = x[0, :]
|
||||||
|
endeffector[0, :, 1] = y[0, :]
|
||||||
|
|
||||||
|
for i in range(1, self.num_links):
|
||||||
|
endeffector[i, :, 0] = x[i, :] + endeffector[i - 1, -1, 0]
|
||||||
|
endeffector[i, :, 1] = y[i, :] + endeffector[i - 1, -1, 1]
|
||||||
|
|
||||||
|
return np.squeeze(endeffector + self._joints[0, :])
|
||||||
|
|
||||||
|
def render(self, mode='human'):
|
||||||
|
if self.fig is None:
|
||||||
|
self.fig = plt.figure()
|
||||||
|
# plt.ion()
|
||||||
|
# plt.pause(0.01)
|
||||||
|
else:
|
||||||
|
plt.figure(self.fig.number)
|
||||||
|
|
||||||
|
if mode == "human":
|
||||||
|
plt.cla()
|
||||||
|
plt.title(f"Iteration: {self._steps}")
|
||||||
|
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k')
|
||||||
|
|
||||||
|
lim = np.sum(self.link_lengths) + 0.5
|
||||||
|
plt.xlim([-lim, lim])
|
||||||
|
plt.ylim([-lim, lim])
|
||||||
|
# plt.draw()
|
||||||
|
plt.pause(1e-4) # pushes window to foreground, which is annoying.
|
||||||
|
# self.fig.canvas.flush_events()
|
||||||
|
|
||||||
|
elif mode == "partial":
|
||||||
|
if self._steps == 1:
|
||||||
|
# fig, ax = plt.subplots()
|
||||||
|
# Add the patch to the Axes
|
||||||
|
[plt.gca().add_patch(rect) for rect in self.patches]
|
||||||
|
# plt.pause(0.01)
|
||||||
|
|
||||||
|
if self._steps % 20 == 0 or self._steps in [1, 199] or self._is_collided:
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k', alpha=self._steps / 200)
|
||||||
|
# ax.plot(line_points_in_taskspace[:, 0, 0],
|
||||||
|
# line_points_in_taskspace[:, 0, 1],
|
||||||
|
# line_points_in_taskspace[:, -1, 0],
|
||||||
|
# line_points_in_taskspace[:, -1, 1], marker='o', color='k', alpha=t / 200)
|
||||||
|
|
||||||
|
lim = np.sum(self.link_lengths) + 0.5
|
||||||
|
plt.xlim([-lim, lim])
|
||||||
|
plt.ylim([-1.1, lim])
|
||||||
|
plt.pause(0.01)
|
||||||
|
|
||||||
|
elif mode == "final":
|
||||||
|
if self._steps == 199 or self._is_collided:
|
||||||
|
# fig, ax = plt.subplots()
|
||||||
|
|
||||||
|
# Add the patch to the Axes
|
||||||
|
[plt.gca().add_patch(rect) for rect in self.patches]
|
||||||
|
|
||||||
|
plt.xlim(-self.num_links, self.num_links), plt.ylim(-1, self.num_links)
|
||||||
|
# Arm
|
||||||
|
plt.plot(self._joints[:, 0], self._joints[:, 1], 'ro-', markerfacecolor='k')
|
||||||
|
|
||||||
|
plt.pause(0.01)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.fig is not None:
|
||||||
|
plt.close(self.fig)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
nl = 5
|
||||||
|
render_mode = "human" # "human" or "partial" or "final"
|
||||||
|
env = ViaPointReacher(n_links=nl, allow_self_collision=False)
|
||||||
|
env.reset()
|
||||||
|
env.render(mode=render_mode)
|
||||||
|
|
||||||
|
for i in range(300):
|
||||||
|
# objective.load_result("/tmp/cma")
|
||||||
|
# test with random actions
|
||||||
|
ac = env.action_space.sample()
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render(mode=render_mode)
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
@ -1,2 +1,2 @@
|
|||||||
from alr_envs.mujoco.alr_reacher import ALRReacherEnv
|
from alr_envs.mujoco.reacher.alr_reacher import ALRReacherEnv
|
||||||
from alr_envs.mujoco.balancing import BalancingEnv
|
from alr_envs.mujoco.balancing import BalancingEnv
|
||||||
|
252
alr_envs/mujoco/alr_mujoco_env.py
Normal file
252
alr_envs/mujoco/alr_mujoco_env.py
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
from gym import error, spaces
|
||||||
|
from gym.utils import seeding
|
||||||
|
import numpy as np
|
||||||
|
from os import path
|
||||||
|
import gym
|
||||||
|
|
||||||
|
try:
|
||||||
|
import mujoco_py
|
||||||
|
except ImportError as e:
|
||||||
|
raise error.DependencyNotInstalled("{}. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)".format(e))
|
||||||
|
|
||||||
|
DEFAULT_SIZE = 500
|
||||||
|
|
||||||
|
|
||||||
|
def convert_observation_to_space(observation):
|
||||||
|
if isinstance(observation, dict):
|
||||||
|
space = spaces.Dict(OrderedDict([
|
||||||
|
(key, convert_observation_to_space(value))
|
||||||
|
for key, value in observation.items()
|
||||||
|
]))
|
||||||
|
elif isinstance(observation, np.ndarray):
|
||||||
|
low = np.full(observation.shape, -float('inf'), dtype=np.float32)
|
||||||
|
high = np.full(observation.shape, float('inf'), dtype=np.float32)
|
||||||
|
space = spaces.Box(low, high, dtype=observation.dtype)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError(type(observation), observation)
|
||||||
|
|
||||||
|
return space
|
||||||
|
|
||||||
|
|
||||||
|
class AlrMujocoEnv(gym.Env):
|
||||||
|
"""
|
||||||
|
Superclass for all MuJoCo environments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, model_path, n_substeps, apply_gravity_comp=True):
|
||||||
|
"""
|
||||||
|
|
||||||
|
Args:
|
||||||
|
model_path: path to xml file
|
||||||
|
n_substeps: how many steps mujoco does per call to env.step
|
||||||
|
use_servo: use actuator defined in xml, use False for direct torque control
|
||||||
|
"""
|
||||||
|
if model_path.startswith("/"):
|
||||||
|
fullpath = model_path
|
||||||
|
else:
|
||||||
|
fullpath = os.path.join(os.path.dirname(__file__), "assets", model_path)
|
||||||
|
if not path.exists(fullpath):
|
||||||
|
raise IOError("File %s does not exist" % fullpath)
|
||||||
|
self.n_substeps = n_substeps
|
||||||
|
self.apply_gravity_comp = apply_gravity_comp
|
||||||
|
self.model = mujoco_py.load_model_from_path(fullpath)
|
||||||
|
self.sim = mujoco_py.MjSim(self.model, nsubsteps=n_substeps)
|
||||||
|
self.data = self.sim.data
|
||||||
|
self.viewer = None
|
||||||
|
self._viewers = {}
|
||||||
|
|
||||||
|
self.metadata = {
|
||||||
|
'render.modes': ['human', 'rgb_array', 'depth_array'],
|
||||||
|
'video.frames_per_second': int(np.round(1.0 / self.dt))
|
||||||
|
}
|
||||||
|
|
||||||
|
self.init_qpos = self.sim.data.qpos.ravel().copy()
|
||||||
|
self.init_qvel = self.sim.data.qvel.ravel().copy()
|
||||||
|
|
||||||
|
self._set_action_space()
|
||||||
|
|
||||||
|
# action = self.action_space.sample()
|
||||||
|
# observation, _reward, done, _info = self.step(action)
|
||||||
|
# assert not done
|
||||||
|
|
||||||
|
observation = self._get_obs() # TODO: is calling get_obs enough? should we call reset, or even step?
|
||||||
|
|
||||||
|
self._set_observation_space(observation)
|
||||||
|
|
||||||
|
self.seed()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_pos(self):
|
||||||
|
"""
|
||||||
|
By default returns the joint positions of all simulated objects. May be overridden in subclass.
|
||||||
|
"""
|
||||||
|
return self.sim.data.qpos
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_vel(self):
|
||||||
|
"""
|
||||||
|
By default returns the joint velocities of all simulated objects. May be overridden in subclass.
|
||||||
|
"""
|
||||||
|
return self.sim.data.qvel
|
||||||
|
|
||||||
|
def extend_des_pos(self, des_pos):
|
||||||
|
"""
|
||||||
|
In a simplified environment, the actions may only control a subset of all the joints.
|
||||||
|
Extend the trajectory to match the environments full action space
|
||||||
|
Args:
|
||||||
|
des_pos:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def extend_des_vel(self, des_vel):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _set_action_space(self):
|
||||||
|
bounds = self.model.actuator_ctrlrange.copy().astype(np.float32)
|
||||||
|
low, high = bounds.T
|
||||||
|
self.action_space = spaces.Box(low=low, high=high, dtype=np.float32)
|
||||||
|
return self.action_space
|
||||||
|
|
||||||
|
def _set_observation_space(self, observation):
|
||||||
|
self.observation_space = convert_observation_to_space(observation)
|
||||||
|
return self.observation_space
|
||||||
|
|
||||||
|
def seed(self, seed=None):
|
||||||
|
self.np_random, seed = seeding.np_random(seed)
|
||||||
|
return [seed]
|
||||||
|
|
||||||
|
# methods to override:
|
||||||
|
# ----------------------------
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
"""Returns the observation.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def configure(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Helper method to set certain environment properties such as contexts in contextual environments since reset()
|
||||||
|
doesn't take arguments. Should be called before reset().
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
"""
|
||||||
|
Reset the robot degrees of freedom (qpos and qvel).
|
||||||
|
Implement this in each subclass.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def viewer_setup(self):
|
||||||
|
"""
|
||||||
|
This method is called when the viewer is initialized.
|
||||||
|
Optionally implement this method, if you need to tinker with camera position
|
||||||
|
and so forth.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.sim.reset()
|
||||||
|
ob = self.reset_model()
|
||||||
|
return ob
|
||||||
|
|
||||||
|
def set_state(self, qpos, qvel):
|
||||||
|
assert qpos.shape == (self.model.nq,) and qvel.shape == (self.model.nv,)
|
||||||
|
old_state = self.sim.get_state()
|
||||||
|
new_state = mujoco_py.MjSimState(old_state.time, qpos, qvel,
|
||||||
|
old_state.act, old_state.udd_state)
|
||||||
|
self.sim.set_state(new_state)
|
||||||
|
self.sim.forward()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dt(self):
|
||||||
|
return self.model.opt.timestep * self.n_substeps
|
||||||
|
|
||||||
|
def do_simulation(self, ctrl):
|
||||||
|
"""
|
||||||
|
Additionally returns whether there was an error while stepping the simulation
|
||||||
|
"""
|
||||||
|
error_in_sim = False
|
||||||
|
num_actuations = len(ctrl)
|
||||||
|
if self.apply_gravity_comp:
|
||||||
|
self.sim.data.ctrl[:num_actuations] = ctrl + self.sim.data.qfrc_bias[:num_actuations].copy() / self.model.actuator_gear[:, 0]
|
||||||
|
else:
|
||||||
|
self.sim.data.ctrl[:num_actuations] = ctrl
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.sim.step()
|
||||||
|
except mujoco_py.builder.MujocoException as e:
|
||||||
|
error_in_sim = True
|
||||||
|
|
||||||
|
return error_in_sim
|
||||||
|
|
||||||
|
def render(self,
|
||||||
|
mode='human',
|
||||||
|
width=DEFAULT_SIZE,
|
||||||
|
height=DEFAULT_SIZE,
|
||||||
|
camera_id=None,
|
||||||
|
camera_name=None):
|
||||||
|
if mode == 'rgb_array' or mode == 'depth_array':
|
||||||
|
if camera_id is not None and camera_name is not None:
|
||||||
|
raise ValueError("Both `camera_id` and `camera_name` cannot be"
|
||||||
|
" specified at the same time.")
|
||||||
|
|
||||||
|
no_camera_specified = camera_name is None and camera_id is None
|
||||||
|
if no_camera_specified:
|
||||||
|
camera_name = 'track'
|
||||||
|
|
||||||
|
if camera_id is None and camera_name in self.model._camera_name2id:
|
||||||
|
camera_id = self.model.camera_name2id(camera_name)
|
||||||
|
|
||||||
|
self._get_viewer(mode).render(width, height, camera_id=camera_id)
|
||||||
|
|
||||||
|
if mode == 'rgb_array':
|
||||||
|
# window size used for old mujoco-py:
|
||||||
|
data = self._get_viewer(mode).read_pixels(width, height, depth=False)
|
||||||
|
# original image is upside-down, so flip it
|
||||||
|
return data[::-1, :, :]
|
||||||
|
elif mode == 'depth_array':
|
||||||
|
self._get_viewer(mode).render(width, height)
|
||||||
|
# window size used for old mujoco-py:
|
||||||
|
# Extract depth part of the read_pixels() tuple
|
||||||
|
data = self._get_viewer(mode).read_pixels(width, height, depth=True)[1]
|
||||||
|
# original image is upside-down, so flip it
|
||||||
|
return data[::-1, :]
|
||||||
|
elif mode == 'human':
|
||||||
|
self._get_viewer(mode).render()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.viewer is not None:
|
||||||
|
# self.viewer.finish()
|
||||||
|
self.viewer = None
|
||||||
|
self._viewers = {}
|
||||||
|
|
||||||
|
def _get_viewer(self, mode):
|
||||||
|
self.viewer = self._viewers.get(mode)
|
||||||
|
if self.viewer is None:
|
||||||
|
if mode == 'human':
|
||||||
|
self.viewer = mujoco_py.MjViewer(self.sim)
|
||||||
|
elif mode == 'rgb_array' or mode == 'depth_array':
|
||||||
|
self.viewer = mujoco_py.MjRenderContextOffscreen(self.sim, -1)
|
||||||
|
|
||||||
|
self.viewer_setup()
|
||||||
|
self._viewers[mode] = self.viewer
|
||||||
|
return self.viewer
|
||||||
|
|
||||||
|
def get_body_com(self, body_name):
|
||||||
|
return self.data.get_body_xpos(body_name)
|
||||||
|
|
||||||
|
def state_vector(self):
|
||||||
|
return np.concatenate([
|
||||||
|
self.sim.data.qpos.flat,
|
||||||
|
self.sim.data.qvel.flat
|
||||||
|
])
|
21
alr_envs/mujoco/alr_reward_fct.py
Normal file
21
alr_envs/mujoco/alr_reward_fct.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class AlrReward:
|
||||||
|
"""
|
||||||
|
A base class for non-Markovian reward functions which may need trajectory information to calculate an episodic
|
||||||
|
reward. Call the methods in reset() and step() of the environment.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# methods to override:
|
||||||
|
# ----------------------------
|
||||||
|
def reset(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Reset the reward function, empty state buffers before an episode, set contexts that influence reward, etc.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def compute_reward(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
|
||||||
|
Returns: Useful things to return are reward values, success flags or crash flags
|
||||||
|
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
0
alr_envs/mujoco/ball_in_a_cup/__init__.py
Normal file
0
alr_envs/mujoco/ball_in_a_cup/__init__.py
Normal file
366
alr_envs/mujoco/ball_in_a_cup/assets/ball-in-a-cup_base.xml
Normal file
366
alr_envs/mujoco/ball_in_a_cup/assets/ball-in-a-cup_base.xml
Normal file
@ -0,0 +1,366 @@
|
|||||||
|
<mujoco model="wam(v1.31)">
|
||||||
|
<compiler angle="radian" meshdir="meshes/" />
|
||||||
|
<option timestep="0.0005" integrator="Euler" />
|
||||||
|
<size njmax="500" nconmax="100" />
|
||||||
|
<default class="main">
|
||||||
|
<joint limited="true" frictionloss="0.001" />
|
||||||
|
<default class="viz">
|
||||||
|
<geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.7 0.7 0.7 1" />
|
||||||
|
</default>
|
||||||
|
<default class="col">
|
||||||
|
<geom type="mesh" contype="0" rgba="0.5 0.6 0.7 1" />
|
||||||
|
</default>
|
||||||
|
</default>
|
||||||
|
<asset>
|
||||||
|
<texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.25 0.26 0.25" rgb2="0.22 0.22 0.22" markrgb="0.3 0.3 0.3" width="100" height="100" />
|
||||||
|
<material name="MatGnd" texture="groundplane" texrepeat="5 5" specular="1" shininess="0.3" reflectance="1e-05" />
|
||||||
|
<mesh name="base_link_fine" file="base_link_fine.stl" />
|
||||||
|
<mesh name="base_link_convex" file="base_link_convex.stl" />
|
||||||
|
<mesh name="shoulder_link_fine" file="shoulder_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p1" file="shoulder_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p2" file="shoulder_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p3" file="shoulder_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_fine" file="shoulder_pitch_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_convex" file="shoulder_pitch_link_convex.stl" />
|
||||||
|
<mesh name="upper_arm_link_fine" file="upper_arm_link_fine.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p1" file="upper_arm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p2" file="upper_arm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="elbow_link_fine" file="elbow_link_fine.stl" />
|
||||||
|
<mesh name="elbow_link_convex" file="elbow_link_convex.stl" />
|
||||||
|
<mesh name="forearm_link_fine" file="forearm_link_fine.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p1" file="forearm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p2" file="forearm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_fine" file="wrist_yaw_link_fine.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p1" file="wrist_yaw_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p2" file="wrist_yaw_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_fine" file="wrist_pitch_link_fine.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p1" file="wrist_pitch_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p2" file="wrist_pitch_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p3" file="wrist_pitch_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="wrist_palm_link_fine" file="wrist_palm_link_fine.stl" />
|
||||||
|
<mesh name="wrist_palm_link_convex" file="wrist_palm_link_convex.stl" />
|
||||||
|
<mesh name="cup1" file="cup_split1.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup2" file="cup_split2.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup3" file="cup_split3.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup4" file="cup_split4.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup5" file="cup_split5.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup6" file="cup_split6.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup7" file="cup_split7.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup8" file="cup_split8.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup9" file="cup_split9.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup10" file="cup_split10.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup11" file="cup_split11.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup12" file="cup_split12.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup13" file="cup_split13.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup14" file="cup_split14.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup15" file="cup_split15.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup16" file="cup_split16.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup17" file="cup_split17.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup18" file="cup_split18.stl" scale="0.001 0.001 0.001" />
|
||||||
|
</asset>
|
||||||
|
|
||||||
|
<worldbody>
|
||||||
|
<geom name="ground" size="1.5 2 1" type="plane" material="MatGnd" />
|
||||||
|
<light pos="0.1 0.2 1.3" dir="-0.0758098 -0.32162 -0.985527" directional="true" cutoff="60" exponent="1" diffuse="1 1 1" specular="0.1 0.1 0.1" />
|
||||||
|
|
||||||
|
<body name="wam/base_link" pos="0 0 0.6">
|
||||||
|
<inertial pos="6.93764e-06 0.0542887 0.076438" quat="0.496481 0.503509 -0.503703 0.496255" mass="27.5544" diaginertia="0.432537 0.318732 0.219528" />
|
||||||
|
<geom class="viz" quat="0.707107 0 0 -0.707107" mesh="base_link_fine" />
|
||||||
|
<geom class="col" quat="0.707107 0 0 -0.707107" mesh="base_link_convex" />
|
||||||
|
<body name="wam/shoulder_yaw_link" pos="0 0 0.16" quat="0.707107 0 0 -0.707107">
|
||||||
|
<inertial pos="-0.00443422 -0.00066489 -0.12189" quat="0.999995 0.000984795 0.00270132 0.00136071" mass="10.7677" diaginertia="0.507411 0.462983 0.113271" />
|
||||||
|
<joint name="wam/base_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.6 2.6" />
|
||||||
|
<geom class="viz" pos="0 0 0.186" mesh="shoulder_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p1" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p2" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p3" />
|
||||||
|
<body name="wam/shoulder_pitch_link" pos="0 0 0.184" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00236983 -0.0154211 0.0310561" quat="0.961781 -0.272983 0.0167269 0.0133385" mass="3.87494" diaginertia="0.0214207 0.0167101 0.0126465" />
|
||||||
|
<joint name="wam/shoulder_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.985 1.985" />
|
||||||
|
<geom class="viz" mesh="shoulder_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="shoulder_pitch_link_convex" />
|
||||||
|
<body name="wam/upper_arm_link" pos="0 -0.505 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-0.0382586 3.309e-05 -0.207508" quat="0.705455 0.0381914 0.0383402 0.706686" mass="1.80228" diaginertia="0.0665697 0.0634285 0.00622701" />
|
||||||
|
<joint name="wam/shoulder_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.8 2.8" />
|
||||||
|
<geom class="viz" pos="0 0 -0.505" mesh="upper_arm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p1" />
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p2" />
|
||||||
|
<body name="wam/forearm_link" pos="0.045 0 0.045" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="0.00498512 -0.132717 -0.00022942" quat="0.546303 0.447151 -0.548676 0.447842" mass="2.40017" diaginertia="0.0196896 0.0152225 0.00749914" />
|
||||||
|
<joint name="wam/elbow_pitch_joint" pos="0 0 0" axis="0 0 1" range="-0.9 3.14159" />
|
||||||
|
<geom class="viz" mesh="elbow_link_fine" />
|
||||||
|
<geom class="col" mesh="elbow_link_convex" />
|
||||||
|
<geom class="viz" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_fine" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p1" name="forearm_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p2" name="forearm_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_yaw_link" pos="-0.045 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="8.921e-05 0.00435824 -0.00511217" quat="0.708528 -0.000120667 0.000107481 0.705683" mass="0.12376" diaginertia="0.0112011 0.0111887 7.58188e-05" />
|
||||||
|
<joint name="wam/wrist_yaw_joint" pos="0 0 0" axis="0 0 1" range="-4.55 1.25" />
|
||||||
|
<geom class="viz" pos="0 0 0.3" mesh="wrist_yaw_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p1" name="wrist_yaw_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p2" name="wrist_yaw_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_pitch_link" pos="0 0 0.3" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00012262 -0.0246834 -0.0170319" quat="0.994687 -0.102891 0.000824211 -0.00336105" mass="0.417974" diaginertia="0.000555166 0.000463174 0.00023407" />
|
||||||
|
<joint name="wam/wrist_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.5707 1.5707" />
|
||||||
|
<geom class="viz" mesh="wrist_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p1" name="wrist_pitch_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p2" name="wrist_pitch_link_convex_decomposition_p2_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p3" name="wrist_pitch_link_convex_decomposition_p3_geom" />
|
||||||
|
<body name="wam/wrist_palm_link" pos="0 -0.06 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-7.974e-05 -0.00323552 -0.00016313" quat="0.594752 0.382453 0.382453 0.594752" mass="0.0686475" diaginertia="7.408e-05 3.81466e-05 3.76434e-05" />
|
||||||
|
<joint name="wam/palm_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.7 2.7" />
|
||||||
|
<geom class="viz" pos="0 0 -0.06" mesh="wrist_palm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.06" mesh="wrist_palm_link_convex" name="wrist_palm_link_convex_geom" />
|
||||||
|
<body name="cup" pos="0 0 0" quat="-0.000203673 0 0 1">
|
||||||
|
<inertial pos="-3.75236e-10 8.27811e-05 0.0947015" quat="0.999945 -0.0104888 0 0" mass="0.132" diaginertia="0.000285643 0.000270485 9.65696e-05" />
|
||||||
|
<geom name="cup_geom1" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup1" />
|
||||||
|
<geom name="cup_geom2" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup2" />
|
||||||
|
<geom name="cup_geom3" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup3" />
|
||||||
|
<geom name="cup_geom4" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup4" />
|
||||||
|
<geom name="cup_geom5" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup5" />
|
||||||
|
<geom name="cup_geom6" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup6" />
|
||||||
|
<geom name="cup_geom7" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup7" />
|
||||||
|
<geom name="cup_geom8" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup8" />
|
||||||
|
<geom name="cup_geom9" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup9" />
|
||||||
|
<geom name="cup_geom10" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup10" />
|
||||||
|
<geom name="cup_base" pos="0 -0.035 0.1165" euler="-1.57 0 0" type="cylinder" size="0.038 0.0045" solref="-10000 -100"/>
|
||||||
|
<geom name="cup_base_contact" pos="0 -0.025 0.1165" euler="-1.57 0 0" type="cylinder" size="0.03 0.0005" solref="-10000 -100" rgba="0 0 255 1"/>
|
||||||
|
<!-- <geom name="cup_geom11" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup11" />-->
|
||||||
|
<!-- <geom name="cup_geom12" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup12" />-->
|
||||||
|
<!-- <geom name="cup_geom13" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup13" />-->
|
||||||
|
<!-- <geom name="cup_geom14" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup14" />-->
|
||||||
|
|
||||||
|
<geom name="cup_geom15" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup15" />
|
||||||
|
<geom name="cup_geom16" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup16" />
|
||||||
|
<geom name="cup_geom17" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup17" />
|
||||||
|
<geom name="cup_geom18" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup18" />
|
||||||
|
<site name="cup_goal" pos="0 0.05 0.1165" rgba="255 0 0 1"/>
|
||||||
|
<site name="cup_goal_final" pos="0 -0.025 0.1165" rgba="0 255 0 1"/>
|
||||||
|
<body name="B0" pos="0 -0.045 0.1165" quat="0.707388 0 0 -0.706825">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<geom name="G0" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B1" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_1" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_1" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G1" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B2" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_2" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_2" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G2" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B3" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_3" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_3" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G3" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B4" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_4" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_4" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G4" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B5" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_5" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_5" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G5" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B6" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_6" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_6" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G6" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B7" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_7" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_7" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G7" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B8" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_8" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_8" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G8" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B9" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_9" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_9" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G9" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B10" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_10" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_10" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G10" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B11" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_11" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_11" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G11" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B12" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_12" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_12" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G12" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B13" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_13" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_13" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G13" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B14" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_14" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_14" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G14" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B15" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_15" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_15" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G15" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B16" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_16" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_16" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G16" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B17" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_17" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_17" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G17" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B18" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_18" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_18" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G18" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B19" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_19" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_19" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G19" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B20" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_20" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_20" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G20" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B21" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_21" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_21" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G21" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B22" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_22" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_22" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G22" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B23" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_23" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_23" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G23" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B24" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_24" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_24" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G24" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B25" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_25" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_25" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G25" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B26" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_26" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_26" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G26" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B27" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_27" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_27" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G27" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B28" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_28" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_28" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G28" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B29" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_29" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_29" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G29" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="ball">
|
||||||
|
<geom name="ball_geom" type="sphere" size="0.02" mass="0.021" rgba="0.8 0.2 0.1 1"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
<site name="context_point" pos="0 0.05 0.1165" euler="-1.57 0 0" size="0.015" rgba="1 0 0 0.6" type="sphere"/>
|
||||||
|
<site name="context_point1" pos="-0.5 -0.85 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point2" pos="-0.5 -0.85 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point3" pos="-0.5 -0.35 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point4" pos="-0.5 -0.35 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point5" pos="0.5 -0.85 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point6" pos="0.5 -0.85 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point7" pos="0.5 -0.35 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point8" pos="0.5 -0.35 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_space" pos="0 -0.6 1.1165" euler="0 0 0" size="0.5 0.25 0.3" rgba="0 0 1 0.15" type="box"/>
|
||||||
|
<camera name="visualization" mode="targetbody" target="wam/wrist_yaw_link" pos="1.5 -0.4 2.2"/>
|
||||||
|
<camera name="experiment" mode="fixed" quat="0.44418059 0.41778323 0.54301123 0.57732103" pos="1.5 -0.3 1.33" />
|
||||||
|
</worldbody>
|
||||||
|
|
||||||
|
<actuator>
|
||||||
|
<motor ctrlrange="-150 150" joint="wam/base_yaw_joint"/>
|
||||||
|
<motor ctrlrange="-125 125" joint="wam/shoulder_pitch_joint"/>
|
||||||
|
<motor ctrlrange="-40 40" joint="wam/shoulder_yaw_joint"/>
|
||||||
|
<motor ctrlrange="-60 60" joint="wam/elbow_pitch_joint"/>
|
||||||
|
<motor ctrlrange="-5 5" joint="wam/wrist_yaw_joint"/>
|
||||||
|
<motor ctrlrange="-5 5" joint="wam/wrist_pitch_joint"/>
|
||||||
|
<motor ctrlrange="-2 2" joint="wam/palm_yaw_joint"/>
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-2.6 2.6" joint="wam/base_yaw_joint" kp="151.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-1.985 1.985" joint="wam/shoulder_pitch_joint" kp="125.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-2.8 2.8" joint="wam/shoulder_yaw_joint" kp="122.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-0.9 3.14159" joint="wam/elbow_pitch_joint" kp="121.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-4.55 1.25" joint="wam/wrist_yaw_joint" kp="99.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-1.5707 1.5707" joint="wam/wrist_pitch_joint" kp="103.0"/>-->
|
||||||
|
<!-- <position ctrllimited="true" ctrlrange="-3 3" joint="wam/palm_yaw_joint" kp="99.0"/>-->
|
||||||
|
<!-- <velocity joint="wam/base_yaw_joint" kv="7.0"/>-->
|
||||||
|
<!-- <velocity joint="wam/shoulder_pitch_joint" kv="15.0"/>-->
|
||||||
|
<!-- <velocity joint="wam/shoulder_yaw_joint" kv="5.0"/>-->
|
||||||
|
<!-- <velocity joint="wam/elbow_pitch_joint" kv="2.5"/>-->
|
||||||
|
<!-- <velocity joint="wam/wrist_yaw_joint" kv="0.3"/>-->
|
||||||
|
<!-- <velocity joint="wam/wrist_pitch_joint" kv="0.3"/>-->
|
||||||
|
<!-- <velocity joint="wam/palm_yaw_joint" kv="0.05"/>-->
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
360
alr_envs/mujoco/ball_in_a_cup/assets/biac_base.xml
Normal file
360
alr_envs/mujoco/ball_in_a_cup/assets/biac_base.xml
Normal file
@ -0,0 +1,360 @@
|
|||||||
|
<mujoco model="wam(v1.31)">
|
||||||
|
<compiler angle="radian" meshdir="../../meshes/wam/" />
|
||||||
|
<option timestep="0.0005" integrator="Euler" />
|
||||||
|
<size njmax="500" nconmax="100" />
|
||||||
|
<default class="main">
|
||||||
|
<joint limited="true" frictionloss="0.001" />
|
||||||
|
<default class="viz">
|
||||||
|
<geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.7 0.7 0.7 1" />
|
||||||
|
</default>
|
||||||
|
<default class="col">
|
||||||
|
<geom type="mesh" contype="0" rgba="0.5 0.6 0.7 1" />
|
||||||
|
</default>
|
||||||
|
</default>
|
||||||
|
<asset>
|
||||||
|
<texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.25 0.26 0.25" rgb2="0.22 0.22 0.22" markrgb="0.3 0.3 0.3" width="100" height="100" />
|
||||||
|
<material name="MatGnd" texture="groundplane" texrepeat="5 5" specular="1" shininess="0.3" reflectance="1e-05" />
|
||||||
|
<mesh name="base_link_fine" file="base_link_fine.stl" />
|
||||||
|
<mesh name="base_link_convex" file="base_link_convex.stl" />
|
||||||
|
<mesh name="shoulder_link_fine" file="shoulder_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p1" file="shoulder_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p2" file="shoulder_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p3" file="shoulder_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_fine" file="shoulder_pitch_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_convex" file="shoulder_pitch_link_convex.stl" />
|
||||||
|
<mesh name="upper_arm_link_fine" file="upper_arm_link_fine.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p1" file="upper_arm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p2" file="upper_arm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="elbow_link_fine" file="elbow_link_fine.stl" />
|
||||||
|
<mesh name="elbow_link_convex" file="elbow_link_convex.stl" />
|
||||||
|
<mesh name="forearm_link_fine" file="forearm_link_fine.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p1" file="forearm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p2" file="forearm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_fine" file="wrist_yaw_link_fine.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p1" file="wrist_yaw_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p2" file="wrist_yaw_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_fine" file="wrist_pitch_link_fine.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p1" file="wrist_pitch_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p2" file="wrist_pitch_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p3" file="wrist_pitch_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="wrist_palm_link_fine" file="wrist_palm_link_fine.stl" />
|
||||||
|
<mesh name="wrist_palm_link_convex" file="wrist_palm_link_convex.stl" />
|
||||||
|
<mesh name="cup1" file="cup_split1.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup2" file="cup_split2.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup3" file="cup_split3.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup4" file="cup_split4.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup5" file="cup_split5.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup6" file="cup_split6.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup7" file="cup_split7.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup8" file="cup_split8.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup9" file="cup_split9.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup10" file="cup_split10.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup11" file="cup_split11.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup12" file="cup_split12.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup13" file="cup_split13.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup14" file="cup_split14.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup15" file="cup_split15.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup16" file="cup_split16.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup17" file="cup_split17.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup18" file="cup_split18.stl" scale="0.001 0.001 0.001" />
|
||||||
|
</asset>
|
||||||
|
|
||||||
|
<worldbody>
|
||||||
|
<geom name="ground" size="1.5 2 1" type="plane" material="MatGnd" />
|
||||||
|
<light pos="0.1 0.2 1.3" dir="-0.0758098 -0.32162 -0.985527" directional="true" cutoff="60" exponent="1" diffuse="1 1 1" specular="0.1 0.1 0.1" />
|
||||||
|
|
||||||
|
<body name="wam/base_link" pos="0 0 0.6">
|
||||||
|
<inertial pos="6.93764e-06 0.0542887 0.076438" quat="0.496481 0.503509 -0.503703 0.496255" mass="27.5544" diaginertia="0.432537 0.318732 0.219528" />
|
||||||
|
<geom class="viz" quat="0.707107 0 0 -0.707107" mesh="base_link_fine" />
|
||||||
|
<geom class="col" quat="0.707107 0 0 -0.707107" mesh="base_link_convex" />
|
||||||
|
<body name="wam/shoulder_yaw_link" pos="0 0 0.16" quat="0.707107 0 0 -0.707107">
|
||||||
|
<inertial pos="-0.00443422 -0.00066489 -0.12189" quat="0.999995 0.000984795 0.00270132 0.00136071" mass="10.7677" diaginertia="0.507411 0.462983 0.113271" />
|
||||||
|
<joint name="wam/base_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.6 2.6" />
|
||||||
|
<geom class="viz" pos="0 0 0.186" mesh="shoulder_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p1" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p2" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p3" />
|
||||||
|
<body name="wam/shoulder_pitch_link" pos="0 0 0.184" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00236983 -0.0154211 0.0310561" quat="0.961781 -0.272983 0.0167269 0.0133385" mass="3.87494" diaginertia="0.0214207 0.0167101 0.0126465" />
|
||||||
|
<joint name="wam/shoulder_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.985 1.985" />
|
||||||
|
<geom class="viz" mesh="shoulder_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="shoulder_pitch_link_convex" />
|
||||||
|
<body name="wam/upper_arm_link" pos="0 -0.505 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-0.0382586 3.309e-05 -0.207508" quat="0.705455 0.0381914 0.0383402 0.706686" mass="1.80228" diaginertia="0.0665697 0.0634285 0.00622701" />
|
||||||
|
<joint name="wam/shoulder_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.8 2.8" />
|
||||||
|
<geom class="viz" pos="0 0 -0.505" mesh="upper_arm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p1" />
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p2" />
|
||||||
|
<body name="wam/forearm_link" pos="0.045 0 0.045" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="0.00498512 -0.132717 -0.00022942" quat="0.546303 0.447151 -0.548676 0.447842" mass="2.40017" diaginertia="0.0196896 0.0152225 0.00749914" />
|
||||||
|
<joint name="wam/elbow_pitch_joint" pos="0 0 0" axis="0 0 1" range="-0.9 3.14159" />
|
||||||
|
<geom class="viz" mesh="elbow_link_fine" />
|
||||||
|
<geom class="col" mesh="elbow_link_convex" />
|
||||||
|
<geom class="viz" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_fine" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p1" name="forearm_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p2" name="forearm_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_yaw_link" pos="-0.045 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="8.921e-05 0.00435824 -0.00511217" quat="0.708528 -0.000120667 0.000107481 0.705683" mass="0.12376" diaginertia="0.0112011 0.0111887 7.58188e-05" />
|
||||||
|
<joint name="wam/wrist_yaw_joint" pos="0 0 0" axis="0 0 1" range="-4.55 1.25" />
|
||||||
|
<geom class="viz" pos="0 0 0.3" mesh="wrist_yaw_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p1" name="wrist_yaw_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p2" name="wrist_yaw_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_pitch_link" pos="0 0 0.3" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00012262 -0.0246834 -0.0170319" quat="0.994687 -0.102891 0.000824211 -0.00336105" mass="0.417974" diaginertia="0.000555166 0.000463174 0.00023407" />
|
||||||
|
<joint name="wam/wrist_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.5707 1.5707" />
|
||||||
|
<geom class="viz" mesh="wrist_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p1" name="wrist_pitch_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p2" name="wrist_pitch_link_convex_decomposition_p2_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p3" name="wrist_pitch_link_convex_decomposition_p3_geom" />
|
||||||
|
<body name="wam/wrist_palm_link" pos="0 -0.06 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-7.974e-05 -0.00323552 -0.00016313" quat="0.594752 0.382453 0.382453 0.594752" mass="0.0686475" diaginertia="7.408e-05 3.81466e-05 3.76434e-05" />
|
||||||
|
<joint name="wam/palm_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.7 2.7" />
|
||||||
|
<geom class="viz" pos="0 0 -0.06" mesh="wrist_palm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.06" mesh="wrist_palm_link_convex" name="wrist_palm_link_convex_geom" />
|
||||||
|
<body name="cup" pos="0 0 0" quat="-0.000203673 0 0 1">
|
||||||
|
<inertial pos="-3.75236e-10 8.27811e-05 0.0947015" quat="0.999945 -0.0104888 0 0" mass="0.132" diaginertia="0.000285643 0.000270485 9.65696e-05" />
|
||||||
|
<geom name="cup_geom1" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup1" />
|
||||||
|
<geom name="cup_geom2" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup2" />
|
||||||
|
<geom name="cup_geom3" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup3" />
|
||||||
|
<geom name="cup_geom4" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup4" />
|
||||||
|
<geom name="cup_geom5" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup5" />
|
||||||
|
<geom name="cup_geom6" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup6" />
|
||||||
|
<geom name="cup_geom7" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup7" />
|
||||||
|
<geom name="cup_geom8" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup8" />
|
||||||
|
<geom name="cup_geom9" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup9" />
|
||||||
|
<geom name="cup_geom10" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup10" />
|
||||||
|
<geom name="cup_base" pos="0 -0.035 0.1165" euler="-1.57 0 0" type="cylinder" size="0.038 0.0045" solref="-10000 -100"/>
|
||||||
|
<!-- <geom name="cup_base_contact" pos="0 -0.025 0.1165" euler="-1.57 0 0" type="cylinder" size="0.03 0.0005" solref="-10000 -100" rgba="0 0 255 1"/>-->
|
||||||
|
<geom name="cup_base_contact" pos="0 -0.005 0.1165" euler="-1.57 0 0" type="cylinder" size="0.02 0.0005" solref="-10000 -100" rgba="0 0 255 1"/>
|
||||||
|
<!-- <geom name="cup_geom11" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup11" />-->
|
||||||
|
<!-- <geom name="cup_geom12" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup12" />-->
|
||||||
|
<!-- <geom name="cup_geom13" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup13" />-->
|
||||||
|
<!-- <geom name="cup_geom14" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup14" />-->
|
||||||
|
|
||||||
|
<geom name="cup_geom15" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup15" />
|
||||||
|
<geom name="cup_geom16" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup16" />
|
||||||
|
<geom name="cup_geom17" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup17" />
|
||||||
|
<geom name="cup_geom18" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup18" />
|
||||||
|
<site name="cup_goal" pos="0 0.05 0.1165" rgba="255 0 0 1"/>
|
||||||
|
<site name="cup_goal_final" pos="0 -0.025 0.1165" rgba="0 255 0 1"/>
|
||||||
|
<body name="B0" pos="0 -0.045 0.1165" quat="0.707388 0 0 -0.706825">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<geom name="G0" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B1" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_1" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_1" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G1" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B2" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_2" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_2" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G2" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B3" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_3" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_3" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G3" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B4" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_4" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_4" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G4" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B5" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_5" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_5" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G5" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B6" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_6" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_6" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G6" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B7" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_7" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_7" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G7" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B8" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_8" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_8" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G8" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B9" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_9" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_9" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G9" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B10" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_10" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_10" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G10" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B11" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_11" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_11" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G11" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B12" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_12" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_12" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G12" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B13" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_13" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_13" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G13" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B14" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_14" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_14" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G14" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B15" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_15" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_15" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G15" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B16" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_16" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_16" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G16" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B17" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_17" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_17" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G17" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B18" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_18" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_18" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G18" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B19" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_19" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_19" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G19" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B20" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_20" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_20" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G20" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B21" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_21" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_21" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G21" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B22" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_22" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_22" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G22" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B23" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_23" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_23" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G23" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B24" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_24" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_24" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G24" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B25" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_25" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_25" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G25" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B26" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_26" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_26" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G26" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B27" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_27" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_27" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G27" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B28" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_28" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_28" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G28" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="B29" pos="0.0107 0 0">
|
||||||
|
<inertial pos="0 0 0" quat="0.707107 0 0.707107 0" mass="7.4927e-05" diaginertia="5.87e-10 5.87e-10 3.74635e-11" />
|
||||||
|
<joint name="J0_29" pos="-0.00535 0 0" axis="0 1 0" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<joint name="J1_29" pos="-0.00535 0 0" axis="0 0 1" group="3" limited="false" damping="0.0001" frictionloss="0" />
|
||||||
|
<geom name="G29" size="0.001 0.00427" quat="0.707107 0 0.707107 0" type="capsule" rgba="0.8 0.2 0.1 1" />
|
||||||
|
<body name="ball">
|
||||||
|
<geom name="ball_geom" type="sphere" size="0.02" mass="0.015" rgba="0.8 0.2 0.1 1"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
<site name="context_point" pos="-0.20869846 -0.66376693 1.18088501" euler="-1.57 0 0" size="0.015" rgba="1 0 0 0.6" type="sphere"/>
|
||||||
|
<site name="context_point1" pos="-0.5 -0.85 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point2" pos="-0.5 -0.85 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point3" pos="-0.5 -0.35 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point4" pos="-0.5 -0.35 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point5" pos="0.5 -0.85 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point6" pos="0.5 -0.85 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point7" pos="0.5 -0.35 0.8165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_point8" pos="0.5 -0.35 1.4165" euler="-1.57 0 0" size="0.015" rgba="0 1 0 0.3" type="sphere"/>
|
||||||
|
<site name="context_space" pos="0 -0.6 1.1165" euler="0 0 0" size="0.5 0.25 0.3" rgba="0 0 1 0.15" type="box"/>
|
||||||
|
<camera name="visualization" mode="targetbody" target="wam/wrist_yaw_link" pos="1.5 -0.4 2.2"/>
|
||||||
|
<camera name="experiment" mode="fixed" quat="0.44418059 0.41778323 0.54301123 0.57732103" pos="1.5 -0.3 1.33" />
|
||||||
|
</worldbody>
|
||||||
|
|
||||||
|
<actuator>
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-150 150" joint="wam/base_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-125 125" joint="wam/shoulder_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-40 40" joint="wam/shoulder_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-60 60" joint="wam/elbow_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-5 5" joint="wam/wrist_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-5 5" joint="wam/wrist_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrllimited="true" ctrlrange="-2 2" joint="wam/palm_yaw_joint"/>-->
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="150.0" joint="wam/base_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="125.0" joint="wam/shoulder_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="40.0" joint="wam/shoulder_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="60.0" joint="wam/elbow_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="5.0" joint="wam/wrist_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="5.0" joint="wam/wrist_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="2.0" joint="wam/palm_yaw_joint"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
132
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup.py
Normal file
132
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
from gym import utils
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_mujoco_env
|
||||||
|
|
||||||
|
|
||||||
|
class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||||
|
def __init__(self, n_substeps=4, apply_gravity_comp=True, reward_function=None):
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets",
|
||||||
|
"biac_base" + ".xml")
|
||||||
|
|
||||||
|
self.start_pos = np.array([0.0, 0.58760536, 0.0, 1.36004913, 0.0, -0.32072943, -1.57])
|
||||||
|
self.start_vel = np.zeros(7)
|
||||||
|
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
# self.weight_matrix_scale = 50
|
||||||
|
self.max_ctrl = np.array([150., 125., 40., 60., 5., 5., 2.])
|
||||||
|
self.p_gains = 1 / self.max_ctrl * np.array([200, 300, 100, 100, 10, 10, 2.5])
|
||||||
|
self.d_gains = 1 / self.max_ctrl * np.array([7, 15, 5, 2.5, 0.3, 0.3, 0.05])
|
||||||
|
|
||||||
|
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||||
|
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||||
|
|
||||||
|
self.context = None
|
||||||
|
|
||||||
|
utils.EzPickle.__init__(self)
|
||||||
|
alr_mujoco_env.AlrMujocoEnv.__init__(self,
|
||||||
|
self.xml_path,
|
||||||
|
apply_gravity_comp=apply_gravity_comp,
|
||||||
|
n_substeps=n_substeps)
|
||||||
|
|
||||||
|
self.sim_time = 8 # seconds
|
||||||
|
self.sim_steps = int(self.sim_time / self.dt)
|
||||||
|
if reward_function is None:
|
||||||
|
from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward import BallInACupReward
|
||||||
|
reward_function = BallInACupReward
|
||||||
|
self.reward_function = reward_function(self.sim_steps)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_pos(self):
|
||||||
|
return self.sim.data.qpos[0:7].copy()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_vel(self):
|
||||||
|
return self.sim.data.qvel[0:7].copy()
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
self.context = context
|
||||||
|
self.reward_function.reset(context)
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
init_pos_all = self.init_qpos.copy()
|
||||||
|
init_pos_robot = self.start_pos
|
||||||
|
init_vel = np.zeros_like(init_pos_all)
|
||||||
|
|
||||||
|
self._steps = 0
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
|
||||||
|
start_pos = init_pos_all
|
||||||
|
start_pos[0:7] = init_pos_robot
|
||||||
|
|
||||||
|
self.set_state(start_pos, init_vel)
|
||||||
|
|
||||||
|
return self._get_obs()
|
||||||
|
|
||||||
|
def step(self, a):
|
||||||
|
reward_dist = 0.0
|
||||||
|
angular_vel = 0.0
|
||||||
|
reward_ctrl = - np.square(a).sum()
|
||||||
|
|
||||||
|
crash = self.do_simulation(a)
|
||||||
|
joint_cons_viol = self.check_traj_in_joint_limits()
|
||||||
|
|
||||||
|
self._q_pos.append(self.sim.data.qpos[0:7].ravel().copy())
|
||||||
|
self._q_vel.append(self.sim.data.qvel[0:7].ravel().copy())
|
||||||
|
|
||||||
|
ob = self._get_obs()
|
||||||
|
|
||||||
|
if not crash and not joint_cons_viol:
|
||||||
|
reward, success, stop_sim = self.reward_function.compute_reward(a, self.sim, self._steps)
|
||||||
|
done = success or self._steps == self.sim_steps - 1 or stop_sim
|
||||||
|
self._steps += 1
|
||||||
|
else:
|
||||||
|
reward = -1000
|
||||||
|
success = False
|
||||||
|
done = True
|
||||||
|
return ob, reward, done, dict(reward_dist=reward_dist,
|
||||||
|
reward_ctrl=reward_ctrl,
|
||||||
|
velocity=angular_vel,
|
||||||
|
traj=self._q_pos, is_success=success,
|
||||||
|
is_collided=crash or joint_cons_viol)
|
||||||
|
|
||||||
|
def check_traj_in_joint_limits(self):
|
||||||
|
return any(self.current_pos > self.j_max) or any(self.current_pos < self.j_min)
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self.sim.data.qpos.flat[:7]
|
||||||
|
return np.concatenate([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
# self.get_body_com("target"), # only return target to make problem harder
|
||||||
|
[self._steps],
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
env = ALRBallInACupEnv()
|
||||||
|
ctxt = np.array([-0.20869846, -0.66376693, 1.18088501])
|
||||||
|
|
||||||
|
env.configure(ctxt)
|
||||||
|
env.reset()
|
||||||
|
# env.render()
|
||||||
|
for i in range(16000):
|
||||||
|
# test with random actions
|
||||||
|
ac = 0.001 * env.action_space.sample()[0:7]
|
||||||
|
# ac = env.start_pos
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
# env.render()
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
||||||
|
|
132
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py
Normal file
132
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_reward_fct
|
||||||
|
|
||||||
|
|
||||||
|
class BallInACupReward(alr_reward_fct.AlrReward):
|
||||||
|
def __init__(self, sim_time):
|
||||||
|
self.sim_time = sim_time
|
||||||
|
|
||||||
|
self.collision_objects = ["cup_geom1", "cup_geom2", "wrist_palm_link_convex_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p2_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p3_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p2_geom",
|
||||||
|
"forearm_link_convex_decomposition_p1_geom",
|
||||||
|
"forearm_link_convex_decomposition_p2_geom"]
|
||||||
|
|
||||||
|
self.ball_id = None
|
||||||
|
self.ball_collision_id = None
|
||||||
|
self.goal_id = None
|
||||||
|
self.goal_final_id = None
|
||||||
|
self.collision_ids = None
|
||||||
|
|
||||||
|
self.ball_traj = None
|
||||||
|
self.dists = None
|
||||||
|
self.dists_ctxt = None
|
||||||
|
self.dists_final = None
|
||||||
|
self.costs = None
|
||||||
|
|
||||||
|
self.reset(None)
|
||||||
|
|
||||||
|
def reset(self, context):
|
||||||
|
self.ball_traj = np.zeros(shape=(self.sim_time, 3))
|
||||||
|
self.cup_traj = np.zeros(shape=(self.sim_time, 3))
|
||||||
|
self.dists = []
|
||||||
|
self.dists_ctxt = []
|
||||||
|
self.dists_final = []
|
||||||
|
self.costs = []
|
||||||
|
self.context = context
|
||||||
|
self.ball_in_cup = False
|
||||||
|
self.ball_above_threshold = False
|
||||||
|
self.dist_ctxt = 3
|
||||||
|
|
||||||
|
def compute_reward(self, action, sim, step):
|
||||||
|
action_cost = np.sum(np.square(action))
|
||||||
|
|
||||||
|
stop_sim = False
|
||||||
|
success = False
|
||||||
|
|
||||||
|
self.ball_id = sim.model._body_name2id["ball"]
|
||||||
|
self.ball_collision_id = sim.model._geom_name2id["ball_geom"]
|
||||||
|
self.goal_id = sim.model._site_name2id["cup_goal"]
|
||||||
|
self.goal_final_id = sim.model._site_name2id["cup_goal_final"]
|
||||||
|
self.collision_ids = [sim.model._geom_name2id[name] for name in self.collision_objects]
|
||||||
|
|
||||||
|
if self.check_collision(sim):
|
||||||
|
reward = - 1e-4 * action_cost - 1000
|
||||||
|
stop_sim = True
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
# Compute the current distance from the ball to the inner part of the cup
|
||||||
|
goal_pos = sim.data.site_xpos[self.goal_id]
|
||||||
|
ball_pos = sim.data.body_xpos[self.ball_id]
|
||||||
|
goal_final_pos = sim.data.site_xpos[self.goal_final_id]
|
||||||
|
self.dists.append(np.linalg.norm(goal_pos - ball_pos))
|
||||||
|
self.dists_final.append(np.linalg.norm(goal_final_pos - ball_pos))
|
||||||
|
self.dists_ctxt.append(np.linalg.norm(ball_pos - self.context))
|
||||||
|
self.ball_traj[step, :] = ball_pos
|
||||||
|
self.cup_traj[step, :] = goal_pos
|
||||||
|
|
||||||
|
# Determine the first time when ball is in cup
|
||||||
|
if not self.ball_in_cup:
|
||||||
|
ball_in_cup = self.check_ball_in_cup(sim, self.ball_collision_id)
|
||||||
|
self.ball_in_cup = ball_in_cup
|
||||||
|
if ball_in_cup:
|
||||||
|
dist_to_ctxt = np.linalg.norm(ball_pos - self.context)
|
||||||
|
self.dist_ctxt = dist_to_ctxt
|
||||||
|
|
||||||
|
if step == self.sim_time - 1:
|
||||||
|
min_dist = np.min(self.dists)
|
||||||
|
dist_final = self.dists_final[-1]
|
||||||
|
# dist_ctxt = self.dists_ctxt[-1]
|
||||||
|
|
||||||
|
# max distance between ball and cup and cup height at that time
|
||||||
|
ball_to_cup_diff = self.ball_traj[:, 2] - self.cup_traj[:, 2]
|
||||||
|
t_max_diff = np.argmax(ball_to_cup_diff)
|
||||||
|
t_max_ball_height = np.argmax(self.ball_traj[:, 2])
|
||||||
|
max_ball_height = np.max(self.ball_traj[:, 2])
|
||||||
|
|
||||||
|
# cost = self._get_stage_wise_cost(ball_in_cup, min_dist, dist_final, dist_ctxt)
|
||||||
|
cost = 0.3 * min_dist + 0.3 * dist_final + 0.3 * np.minimum(self.dist_ctxt, 3)
|
||||||
|
reward = np.exp(-1 * cost) - 1e-4 * action_cost
|
||||||
|
if max_ball_height < self.context[2] or ball_to_cup_diff[t_max_ball_height] < 0:
|
||||||
|
reward -= 1
|
||||||
|
|
||||||
|
success = dist_final < 0.05 and self.dist_ctxt < 0.05
|
||||||
|
else:
|
||||||
|
reward = - 1e-4 * action_cost
|
||||||
|
success = False
|
||||||
|
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
def _get_stage_wise_cost(self, ball_in_cup, min_dist, dist_final, dist_to_ctxt):
|
||||||
|
if not ball_in_cup:
|
||||||
|
cost = 3 + 2*(0.5 * min_dist**2 + 0.5 * dist_final**2)
|
||||||
|
else:
|
||||||
|
cost = 2 * dist_to_ctxt ** 2
|
||||||
|
print('Context Distance:', dist_to_ctxt)
|
||||||
|
return cost
|
||||||
|
|
||||||
|
def check_ball_in_cup(self, sim, ball_collision_id):
|
||||||
|
cup_base_collision_id = sim.model._geom_name2id["cup_base_contact"]
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 == cup_base_collision_id and con.geom2 == ball_collision_id
|
||||||
|
collision_trans = con.geom1 == ball_collision_id and con.geom2 == cup_base_collision_id
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_collision(self, sim):
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 in self.collision_ids and con.geom2 == self.ball_collision_id
|
||||||
|
collision_trans = con.geom1 == self.ball_collision_id and con.geom2 in self.collision_ids
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
94
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py
Normal file
94
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_reward_simple.py
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_reward_fct
|
||||||
|
|
||||||
|
|
||||||
|
class BallInACupReward(alr_reward_fct.AlrReward):
|
||||||
|
def __init__(self, sim_time):
|
||||||
|
self.sim_time = sim_time
|
||||||
|
|
||||||
|
self.collision_objects = ["cup_geom1", "cup_geom2", "wrist_palm_link_convex_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p2_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p3_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p2_geom",
|
||||||
|
"forearm_link_convex_decomposition_p1_geom",
|
||||||
|
"forearm_link_convex_decomposition_p2_geom"]
|
||||||
|
|
||||||
|
self.ball_id = None
|
||||||
|
self.ball_collision_id = None
|
||||||
|
self.goal_id = None
|
||||||
|
self.goal_final_id = None
|
||||||
|
self.collision_ids = None
|
||||||
|
|
||||||
|
self.ball_traj = None
|
||||||
|
self.dists = None
|
||||||
|
self.dists_final = None
|
||||||
|
self.costs = None
|
||||||
|
|
||||||
|
self.reset(None)
|
||||||
|
|
||||||
|
def reset(self, context):
|
||||||
|
self.ball_traj = np.zeros(shape=(self.sim_time, 3))
|
||||||
|
self.dists = []
|
||||||
|
self.dists_final = []
|
||||||
|
self.costs = []
|
||||||
|
|
||||||
|
def compute_reward(self, action, sim, step, context=None):
|
||||||
|
self.ball_id = sim.model._body_name2id["ball"]
|
||||||
|
self.ball_collision_id = sim.model._geom_name2id["ball_geom"]
|
||||||
|
self.goal_id = sim.model._site_name2id["cup_goal"]
|
||||||
|
self.goal_final_id = sim.model._site_name2id["cup_goal_final"]
|
||||||
|
self.collision_ids = [sim.model._geom_name2id[name] for name in self.collision_objects]
|
||||||
|
|
||||||
|
ball_in_cup = self.check_ball_in_cup(sim, self.ball_collision_id)
|
||||||
|
|
||||||
|
# Compute the current distance from the ball to the inner part of the cup
|
||||||
|
goal_pos = sim.data.site_xpos[self.goal_id]
|
||||||
|
ball_pos = sim.data.body_xpos[self.ball_id]
|
||||||
|
goal_final_pos = sim.data.site_xpos[self.goal_final_id]
|
||||||
|
self.dists.append(np.linalg.norm(goal_pos - ball_pos))
|
||||||
|
self.dists_final.append(np.linalg.norm(goal_final_pos - ball_pos))
|
||||||
|
self.ball_traj[step, :] = ball_pos
|
||||||
|
|
||||||
|
action_cost = np.sum(np.square(action))
|
||||||
|
|
||||||
|
if self.check_collision(sim):
|
||||||
|
reward = - 1e-4 * action_cost - 1000
|
||||||
|
return reward, False, True
|
||||||
|
|
||||||
|
if step == self.sim_time - 1:
|
||||||
|
min_dist = np.min(self.dists)
|
||||||
|
dist_final = self.dists_final[-1]
|
||||||
|
|
||||||
|
cost = 0.5 * min_dist + 0.5 * dist_final
|
||||||
|
reward = np.exp(-2 * cost) - 1e-4 * action_cost
|
||||||
|
success = dist_final < 0.05 and ball_in_cup
|
||||||
|
else:
|
||||||
|
reward = - 1e-4 * action_cost
|
||||||
|
success = False
|
||||||
|
|
||||||
|
return reward, success, False
|
||||||
|
|
||||||
|
def check_ball_in_cup(self, sim, ball_collision_id):
|
||||||
|
cup_base_collision_id = sim.model._geom_name2id["cup_base_contact"]
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 == cup_base_collision_id and con.geom2 == ball_collision_id
|
||||||
|
collision_trans = con.geom1 == ball_collision_id and con.geom2 == cup_base_collision_id
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_collision(self, sim):
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 in self.collision_ids and con.geom2 == self.ball_collision_id
|
||||||
|
collision_trans = con.geom1 == self.ball_collision_id and con.geom2 in self.collision_ids
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
151
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_simple.py
Normal file
151
alr_envs/mujoco/ball_in_a_cup/ball_in_a_cup_simple.py
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
from alr_envs.mujoco import alr_mujoco_env
|
||||||
|
from gym import utils
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||||
|
def __init__(self, n_substeps=4, apply_gravity_comp=True, reward_function=None):
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets",
|
||||||
|
"biac_base" + ".xml")
|
||||||
|
|
||||||
|
self.start_pos = np.array([0.0, 0.58760536, 0.0, 1.36004913, 0.0, -0.32072943, -1.57])
|
||||||
|
self.start_vel = np.zeros(7)
|
||||||
|
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
# self.weight_matrix_scale = 50
|
||||||
|
self.max_ctrl = np.array([150., 125., 40., 60., 5., 5., 2.])
|
||||||
|
self.p_gains = 1 / self.max_ctrl * np.array([200, 300, 100, 100, 10, 10, 2.5])
|
||||||
|
self.d_gains = 1 / self.max_ctrl * np.array([7, 15, 5, 2.5, 0.3, 0.3, 0.05])
|
||||||
|
|
||||||
|
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||||
|
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||||
|
|
||||||
|
self.context = None
|
||||||
|
|
||||||
|
utils.EzPickle.__init__(self)
|
||||||
|
alr_mujoco_env.AlrMujocoEnv.__init__(self,
|
||||||
|
self.xml_path,
|
||||||
|
apply_gravity_comp=apply_gravity_comp,
|
||||||
|
n_substeps=n_substeps)
|
||||||
|
|
||||||
|
self.sim_time = 8 # seconds
|
||||||
|
self.sim_steps = int(self.sim_time / self.dt)
|
||||||
|
if reward_function is None:
|
||||||
|
from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward
|
||||||
|
reward_function = BallInACupReward
|
||||||
|
self.reward_function = reward_function(self.sim_steps)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_pos(self):
|
||||||
|
return self.sim.data.qpos[0:7].copy()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_vel(self):
|
||||||
|
return self.sim.data.qvel[0:7].copy()
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
self.context = context
|
||||||
|
self.reward_function.reset(context)
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
init_pos_all = self.init_qpos.copy()
|
||||||
|
init_pos_robot = self.start_pos
|
||||||
|
init_vel = np.zeros_like(init_pos_all)
|
||||||
|
ball_id = self.sim.model._body_name2id["ball"]
|
||||||
|
goal_final_id = self.sim.model._site_name2id["cup_goal_final"]
|
||||||
|
|
||||||
|
self._steps = 0
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
|
||||||
|
start_pos = init_pos_all
|
||||||
|
start_pos[0:7] = init_pos_robot
|
||||||
|
|
||||||
|
self.set_state(start_pos, init_vel)
|
||||||
|
|
||||||
|
return self._get_obs()
|
||||||
|
|
||||||
|
def step(self, a):
|
||||||
|
reward_dist = 0.0
|
||||||
|
angular_vel = 0.0
|
||||||
|
reward_ctrl = - np.square(a).sum()
|
||||||
|
|
||||||
|
crash = self.do_simulation(a)
|
||||||
|
joint_cons_viol = self.check_traj_in_joint_limits()
|
||||||
|
|
||||||
|
self._q_pos.append(self.sim.data.qpos[0:7].ravel().copy())
|
||||||
|
self._q_vel.append(self.sim.data.qvel[0:7].ravel().copy())
|
||||||
|
|
||||||
|
ob = self._get_obs()
|
||||||
|
|
||||||
|
if not crash and not joint_cons_viol:
|
||||||
|
reward, success, collision = self.reward_function.compute_reward(a, self.sim, self._steps)
|
||||||
|
done = success or self._steps == self.sim_steps - 1 or collision
|
||||||
|
self._steps += 1
|
||||||
|
else:
|
||||||
|
reward = -1000
|
||||||
|
success = False
|
||||||
|
done = True
|
||||||
|
return ob, reward, done, dict(reward_dist=reward_dist,
|
||||||
|
reward_ctrl=reward_ctrl,
|
||||||
|
velocity=angular_vel,
|
||||||
|
traj=self._q_pos, is_success=success,
|
||||||
|
is_collided=crash or joint_cons_viol)
|
||||||
|
|
||||||
|
def check_traj_in_joint_limits(self):
|
||||||
|
return any(self.current_pos > self.j_max) or any(self.current_pos < self.j_min)
|
||||||
|
|
||||||
|
# TODO: extend observation space
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self.sim.data.qpos.flat[:7]
|
||||||
|
return np.concatenate([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
# self.get_body_com("target"), # only return target to make problem harder
|
||||||
|
[self._steps],
|
||||||
|
])
|
||||||
|
|
||||||
|
def extend_des_pos(self, des_pos):
|
||||||
|
des_pos_full = self.start_pos.copy()
|
||||||
|
des_pos_full[1] = des_pos[0]
|
||||||
|
des_pos_full[3] = des_pos[1]
|
||||||
|
des_pos_full[5] = des_pos[2]
|
||||||
|
return des_pos_full
|
||||||
|
|
||||||
|
def extend_des_vel(self, des_vel):
|
||||||
|
des_vel_full = self.start_vel.copy()
|
||||||
|
des_vel_full[1] = des_vel[0]
|
||||||
|
des_vel_full[3] = des_vel[1]
|
||||||
|
des_vel_full[5] = des_vel[2]
|
||||||
|
return des_vel_full
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_reward_simple import BallInACupReward
|
||||||
|
|
||||||
|
env = ALRBallInACupEnv(reward_function=BallInACupReward)
|
||||||
|
env.configure(None)
|
||||||
|
env.reset()
|
||||||
|
env.render()
|
||||||
|
for i in range(4000):
|
||||||
|
# objective.load_result("/tmp/cma")
|
||||||
|
# test with random actions
|
||||||
|
# ac = 0.1 * env.action_space.sample()
|
||||||
|
# ac = -np.array([i, i, i]) / 10000 + np.array([env.start_pos[1], env.start_pos[3], env.start_pos[5]])
|
||||||
|
# ac = np.array([0., -10, 0, -1, 0, 1, 0])
|
||||||
|
ac = np.array([0.,0., 0, 0, 0, 0, 0])
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render()
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
||||||
|
|
105
alr_envs/mujoco/ball_in_a_cup/utils.py
Normal file
105
alr_envs/mujoco/ball_in_a_cup/utils.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
from alr_envs.utils.wrapper.detpmp_wrapper import DetPMPWrapper
|
||||||
|
from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup import ALRBallInACupEnv
|
||||||
|
from alr_envs.mujoco.ball_in_a_cup.ball_in_a_cup_simple import ALRBallInACupEnv as ALRBallInACupEnvSimple
|
||||||
|
|
||||||
|
|
||||||
|
def make_contextual_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBallInACupEnv()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=7,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos,
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.5,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBallInACupEnvSimple()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=7,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos,
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.25,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_simple_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBallInACupEnvSimple()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=3,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos[1::2],
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.5,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
0
alr_envs/mujoco/beerpong/__init__.py
Normal file
0
alr_envs/mujoco/beerpong/__init__.py
Normal file
238
alr_envs/mujoco/beerpong/assets/beerpong.xml
Normal file
238
alr_envs/mujoco/beerpong/assets/beerpong.xml
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
<mujoco model="wam(v1.31)">
|
||||||
|
<compiler angle="radian" meshdir="../../meshes/wam/" />
|
||||||
|
<option timestep="0.0005" integrator="Euler" />
|
||||||
|
<size njmax="500" nconmax="100" />
|
||||||
|
<default class="main">
|
||||||
|
<joint limited="true" frictionloss="0.001" damping="0.07"/>
|
||||||
|
<default class="viz">
|
||||||
|
<geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.7 0.7 0.7 1" />
|
||||||
|
</default>
|
||||||
|
<default class="col">
|
||||||
|
<geom type="mesh" contype="0" rgba="0.5 0.6 0.7 1" />
|
||||||
|
</default>
|
||||||
|
</default>
|
||||||
|
<asset>
|
||||||
|
<texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.25 0.26 0.25" rgb2="0.22 0.22 0.22" markrgb="0.3 0.3 0.3" width="100" height="100" />
|
||||||
|
<material name="MatGnd" texture="groundplane" texrepeat="5 5" specular="1" shininess="0.3" reflectance="1e-05" />
|
||||||
|
<mesh name="base_link_fine" file="base_link_fine.stl" />
|
||||||
|
<mesh name="base_link_convex" file="base_link_convex.stl" />
|
||||||
|
<mesh name="shoulder_link_fine" file="shoulder_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p1" file="shoulder_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p2" file="shoulder_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="shoulder_link_convex_decomposition_p3" file="shoulder_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_fine" file="shoulder_pitch_link_fine.stl" />
|
||||||
|
<mesh name="shoulder_pitch_link_convex" file="shoulder_pitch_link_convex.stl" />
|
||||||
|
<mesh name="upper_arm_link_fine" file="upper_arm_link_fine.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p1" file="upper_arm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="upper_arm_link_convex_decomposition_p2" file="upper_arm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="elbow_link_fine" file="elbow_link_fine.stl" />
|
||||||
|
<mesh name="elbow_link_convex" file="elbow_link_convex.stl" />
|
||||||
|
<mesh name="forearm_link_fine" file="forearm_link_fine.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p1" file="forearm_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="forearm_link_convex_decomposition_p2" file="forearm_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_fine" file="wrist_yaw_link_fine.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p1" file="wrist_yaw_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_yaw_link_convex_decomposition_p2" file="wrist_yaw_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_fine" file="wrist_pitch_link_fine.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p1" file="wrist_pitch_link_convex_decomposition_p1.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p2" file="wrist_pitch_link_convex_decomposition_p2.stl" />
|
||||||
|
<mesh name="wrist_pitch_link_convex_decomposition_p3" file="wrist_pitch_link_convex_decomposition_p3.stl" />
|
||||||
|
<mesh name="wrist_palm_link_fine" file="wrist_palm_link_fine.stl" />
|
||||||
|
<mesh name="wrist_palm_link_convex" file="wrist_palm_link_convex.stl" />
|
||||||
|
<mesh name="cup1" file="cup_split1.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup2" file="cup_split2.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup3" file="cup_split3.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup4" file="cup_split4.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup5" file="cup_split5.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup6" file="cup_split6.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup7" file="cup_split7.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup8" file="cup_split8.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup9" file="cup_split9.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup10" file="cup_split10.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup11" file="cup_split11.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup12" file="cup_split12.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup13" file="cup_split13.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup14" file="cup_split14.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup15" file="cup_split15.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup16" file="cup_split16.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup17" file="cup_split17.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup18" file="cup_split18.stl" scale="0.001 0.001 0.001" />
|
||||||
|
<mesh name="cup3_table" file="cup_split3.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup4_table" file="cup_split4.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup5_table" file="cup_split5.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup6_table" file="cup_split6.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup7_table" file="cup_split7.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup8_table" file="cup_split8.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup9_table" file="cup_split9.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup10_table" file="cup_split10.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup15_table" file="cup_split15.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup16_table" file="cup_split16.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup17_table" file="cup_split17.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
<mesh name="cup18_table" file="cup_split18.stl" scale="0.00211 0.00211 0.01" />
|
||||||
|
</asset>
|
||||||
|
|
||||||
|
<worldbody>
|
||||||
|
<geom name="ground" size="5 5 1" type="plane" material="MatGnd" />
|
||||||
|
<light pos="0.1 0.2 1.3" dir="-0.0758098 -0.32162 -0.985527" directional="true" cutoff="60" exponent="1" diffuse="1 1 1" specular="0.1 0.1 0.1" />
|
||||||
|
|
||||||
|
<body name="wam/base_link" pos="0 0 0.6">
|
||||||
|
<inertial pos="6.93764e-06 0.0542887 0.076438" quat="0.496481 0.503509 -0.503703 0.496255" mass="27.5544" diaginertia="0.432537 0.318732 0.219528" />
|
||||||
|
<geom class="viz" quat="0.707107 0 0 -0.707107" mesh="base_link_fine" />
|
||||||
|
<geom class="col" quat="0.707107 0 0 -0.707107" mesh="base_link_convex" name="base_link_convex_geom"/>
|
||||||
|
<body name="wam/shoulder_yaw_link" pos="0 0 0.16" quat="0.707107 0 0 -0.707107">
|
||||||
|
<inertial pos="-0.00443422 -0.00066489 -0.12189" quat="0.999995 0.000984795 0.00270132 0.00136071" mass="10.7677" diaginertia="0.507411 0.462983 0.113271" />
|
||||||
|
<joint name="wam/base_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.6 2.6" />
|
||||||
|
<geom class="viz" pos="0 0 0.186" mesh="shoulder_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p1" name="shoulder_link_convex_decomposition_p1_geom"/>
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p2" name="shoulder_link_convex_decomposition_p2_geom"/>
|
||||||
|
<geom class="col" pos="0 0 0.186" mesh="shoulder_link_convex_decomposition_p3" name="shoulder_link_convex_decomposition_p3_geom"/>
|
||||||
|
<body name="wam/shoulder_pitch_link" pos="0 0 0.184" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00236983 -0.0154211 0.0310561" quat="0.961781 -0.272983 0.0167269 0.0133385" mass="3.87494" diaginertia="0.0214207 0.0167101 0.0126465" />
|
||||||
|
<joint name="wam/shoulder_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.985 1.985" />
|
||||||
|
<geom class="viz" mesh="shoulder_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="shoulder_pitch_link_convex" />
|
||||||
|
<body name="wam/upper_arm_link" pos="0 -0.505 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-0.0382586 3.309e-05 -0.207508" quat="0.705455 0.0381914 0.0383402 0.706686" mass="1.80228" diaginertia="0.0665697 0.0634285 0.00622701" />
|
||||||
|
<joint name="wam/shoulder_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.8 2.8" />
|
||||||
|
<geom class="viz" pos="0 0 -0.505" mesh="upper_arm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p1" name="upper_arm_link_convex_decomposition_p1_geom"/>
|
||||||
|
<geom class="col" pos="0 0 -0.505" mesh="upper_arm_link_convex_decomposition_p2" name="upper_arm_link_convex_decomposition_p2_geom"/>
|
||||||
|
<body name="wam/forearm_link" pos="0.045 0 0.045" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="0.00498512 -0.132717 -0.00022942" quat="0.546303 0.447151 -0.548676 0.447842" mass="2.40017" diaginertia="0.0196896 0.0152225 0.00749914" />
|
||||||
|
<joint name="wam/elbow_pitch_joint" pos="0 0 0" axis="0 0 1" range="-0.9 3.14159" />
|
||||||
|
<geom class="viz" mesh="elbow_link_fine" />
|
||||||
|
<geom class="col" mesh="elbow_link_convex" />
|
||||||
|
<geom class="viz" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_fine" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p1" name="forearm_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="-0.045 -0.073 0" quat="0.707388 0.706825 0 0" mesh="forearm_link_convex_decomposition_p2" name="forearm_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_yaw_link" pos="-0.045 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="8.921e-05 0.00435824 -0.00511217" quat="0.708528 -0.000120667 0.000107481 0.705683" mass="0.12376" diaginertia="0.0112011 0.0111887 7.58188e-05" />
|
||||||
|
<joint name="wam/wrist_yaw_joint" pos="0 0 0" axis="0 0 1" range="-4.55 1.25" />
|
||||||
|
<geom class="viz" pos="0 0 0.3" mesh="wrist_yaw_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p1" name="wrist_yaw_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" pos="0 0 0.3" mesh="wrist_yaw_link_convex_decomposition_p2" name="wrist_yaw_link_convex_decomposition_p2_geom" />
|
||||||
|
<body name="wam/wrist_pitch_link" pos="0 0 0.3" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00012262 -0.0246834 -0.0170319" quat="0.994687 -0.102891 0.000824211 -0.00336105" mass="0.417974" diaginertia="0.000555166 0.000463174 0.00023407" />
|
||||||
|
<joint name="wam/wrist_pitch_joint" pos="0 0 0" axis="0 0 1" range="-1.5707 1.5707" />
|
||||||
|
<geom class="viz" mesh="wrist_pitch_link_fine" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p1" name="wrist_pitch_link_convex_decomposition_p1_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p2" name="wrist_pitch_link_convex_decomposition_p2_geom" />
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p3" name="wrist_pitch_link_convex_decomposition_p3_geom" />
|
||||||
|
<body name="wam/wrist_palm_link" pos="0 -0.06 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="-7.974e-05 -0.00323552 -0.00016313" quat="0.594752 0.382453 0.382453 0.594752" mass="0.0686475" diaginertia="7.408e-05 3.81466e-05 3.76434e-05" />
|
||||||
|
<joint name="wam/palm_yaw_joint" pos="0 0 0" axis="0 0 1" range="-2.7 2.7" />
|
||||||
|
<geom class="viz" pos="0 0 -0.06" mesh="wrist_palm_link_fine" />
|
||||||
|
<geom class="col" pos="0 0 -0.06" mesh="wrist_palm_link_convex" name="wrist_palm_link_convex_geom" />
|
||||||
|
<body name="cup" pos="0 0 0" quat="-0.000203673 0 0 1">
|
||||||
|
<inertial pos="-3.75236e-10 8.27811e-05 0.0947015" quat="0.999945 -0.0104888 0 0" mass="0.132" diaginertia="0.000285643 0.000270485 9.65696e-05" />
|
||||||
|
<geom priority="1" name="cup_geom1" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup1" />
|
||||||
|
<geom priority="1" name="cup_geom2" pos="0 0.05 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup2" />
|
||||||
|
<geom priority="1" name="cup_geom3" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup3" />
|
||||||
|
<geom priority="1" name="cup_geom4" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup4" />
|
||||||
|
<geom priority="1" name="cup_geom5" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup5" />
|
||||||
|
<geom priority="1" name="cup_geom6" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup6" />
|
||||||
|
<geom priority="1" name="cup_geom7" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup7" />
|
||||||
|
<geom priority="1" name="cup_geom8" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup8" />
|
||||||
|
<geom priority="1" name="cup_geom9" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup9" />
|
||||||
|
<geom priority="1" name="cup_geom10" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup10" />
|
||||||
|
<geom name="cup_base" pos="0 -0.05 0.1165" euler="-1.57 0 0" type="cylinder" size="0.038 0.025" solref="-10000 -100"/>
|
||||||
|
<geom name="cup_base_contact" pos="0 -0.005 0.1165" euler="-1.57 0 0" type="cylinder" size="0.03 0.0005" solref="-10000 -100" rgba="0 0 255 1"/>
|
||||||
|
|
||||||
|
<geom priority="1" name="cup_geom15" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup15" />
|
||||||
|
<geom priority="1" name="cup_geom16" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup16" />
|
||||||
|
<geom priority="1" name="cup_geom17" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup17" />
|
||||||
|
<geom priority="1" name="cup_geom18" pos="0 0.015 0.055" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup18" />
|
||||||
|
<site name="cup_robot" pos="0 0.05 0.1165" rgba="255 0 0 1"/>
|
||||||
|
<site name="cup_robot_final" pos="0 -0.025 0.1165" rgba="0 255 0 1"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
<body name="table_body" pos="0 -1.85 0.4025">
|
||||||
|
<geom name="table" type="box" size="0.4 0.6 0.4" rgba="0.8 0.655 0.45 1" solimp="0.999 0.999 0.001"
|
||||||
|
solref="-10000 -100"/>
|
||||||
|
<geom name="table_contact_geom" type="box" size="0.4 0.6 0.01" pos="0 0 0.41" rgba="1.4 0.8 0.45 1" solimp="0.999 0.999 0.001"
|
||||||
|
solref="-10000 -100"/>
|
||||||
|
</body>
|
||||||
|
<geom name="table_robot" type="box" size="0.1 0.1 0.3" pos="0 0.00 0.3025" rgba="0.8 0.655 0.45 1" solimp="0.999 0.999 0.001"
|
||||||
|
solref="-10000 -100"/>
|
||||||
|
<geom name="wall" type="box" quat="1 0 0 0" size="0.4 0.04 1.1" pos="0. -2.45 1.1" rgba="0.8 0.655 0.45 1" solimp="0.999 0.999 0.001"
|
||||||
|
solref="-10000 -100"/>
|
||||||
|
<!-- <geom name="side_wall_left" type="box" quat="1 0 0 0" size="0.04 0.4 0.5" pos="0.45 -2.05 1.1" rgba="0.8 0.655 0.45 1" solimp="0.999 0.999 0.001"-->
|
||||||
|
<!-- solref="-10000 -100"/>-->
|
||||||
|
<!-- <geom name="side_wall_right" type="box" quat="1 0 0 0" size="0.04 0.4 0.5" pos="-0.45 -2.05 1.1" rgba="0.8 0.655 0.45 1" solimp="0.999 0.999 0.001"-->
|
||||||
|
<!-- solref="-10000 -100"/>-->
|
||||||
|
|
||||||
|
<!-- <body name="cup_table" pos="0.32 -1.55 0.84" quat="0.7071068 0.7071068 0 0">-->
|
||||||
|
<!-- <geom priority= "1" type="box" size ="0.1 0.1 0.1" name="cup_base_table" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -10" mass="10"/>-->
|
||||||
|
<!-- </body>-->
|
||||||
|
|
||||||
|
<body name="cup_table" pos="0.32 -1.55 0.84" quat="0.7071068 0.7071068 0 0">
|
||||||
|
<inertial pos="-3.75236e-10 8.27811e-05 0.0947015" quat="0.999945 -0.0104888 0 0" mass="10.132" diaginertia="0.000285643 0.000270485 9.65696e-05" />
|
||||||
|
<geom priority= "1" name="cup_geom_table3" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup3_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table4" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup4_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table5" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup5_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table6" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup6_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table7" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup7_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table8" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup8_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table9" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup9_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table10" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -010" type="mesh" mesh="cup10_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_base_table" pos="0 -0.035 0.1337249" euler="-1.57 0 0" type="cylinder" size="0.08 0.045" solref="-10000 -100" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_base_table_contact" pos="0 0.015 0.1337249" euler="-1.57 0 0" type="cylinder" size="0.06 0.0005" solref="-10000 -100" rgba="0 0 255 1" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table15" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup15_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table16" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup16_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom_table17" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup17_table" mass="10"/>
|
||||||
|
<geom priority= "1" name="cup_geom1_table8" pos="0 0.1 0.001" euler="-1.57 0 0" solref="-10000 -100" type="mesh" mesh="cup18_table" mass="10"/>
|
||||||
|
<site name="cup_goal_table" pos="0 0.11 0.1337249" rgba="255 0 0 1"/>
|
||||||
|
<site name="cup_goal_final_table" pos="0.0 0.025 0.1337249" rgba="0 255 0 1"/>
|
||||||
|
<site name="bounce_table" pos="0.0 -0.015 -0.2 " rgba="255 255 0 1"/>
|
||||||
|
|
||||||
|
<!-- <site name="cup_goal_final_table" pos="0.0 -0.025 0.1337249" rgba="0 255 0 1"/>-->
|
||||||
|
</body>
|
||||||
|
<!-- <body name="ball" pos="0.0 -0.813 2.382">-->
|
||||||
|
<body name="ball" pos="0.0 -0.813 2.382">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x" pos="0 0 0" stiffness="0" type="slide" frictionloss="0" limited="false"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y" pos="0 0 0" stiffness="0" type="slide" frictionloss="0" limited="false"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z" pos="0 0 0" stiffness="0" type="slide" frictionloss="0" limited="false"/>
|
||||||
|
<geom priority= "1" size="0.025 0.025 0.025" type="sphere" condim="4" name="ball_geom" rgba="0.8 0.2 0.1 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="0.9 0.95 0.001 0.5 2" solref="-10000 -10"/>
|
||||||
|
<!-- friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>-->
|
||||||
|
<site name="target_ball" pos="0 0 0" size="0.02 0.02 0.02" rgba="1 0 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<camera name="visualization" mode="targetbody" target="wam/wrist_yaw_link" pos="1.5 -0.4 2.2"/>
|
||||||
|
<camera name="experiment" mode="fixed" quat="0.44418059 0.41778323 0.54301123 0.57732103" pos="1.5 -0.3 1.33" />
|
||||||
|
<site name="test" pos="0.1 0.1 0.1" rgba="0 0 1 1" type="sphere"/>
|
||||||
|
</worldbody>
|
||||||
|
<!-- <actuator>-->
|
||||||
|
<!-- <position ctrlrange="-2.6 2.6" joint="wam/base_yaw_joint" kp="800"/>-->
|
||||||
|
<!-- <position ctrlrange="-1.985 1.985" joint="wam/shoulder_pitch_joint" kp="800"/>-->
|
||||||
|
<!-- <position ctrlrange="-2.8 2.8" joint="wam/shoulder_yaw_joint" kp="800"/>-->
|
||||||
|
<!-- <position ctrlrange="-0.9 3.14159" joint="wam/elbow_pitch_joint" kp="800"/>-->
|
||||||
|
<!-- <position ctrlrange="-4.55 1.25" joint="wam/wrist_yaw_joint" kp="100"/>-->
|
||||||
|
<!-- <position ctrlrange="-1.5707 1.5707" joint="wam/wrist_pitch_joint" kp="2000"/>-->
|
||||||
|
<!-- <position ctrlrange="-2.7 2.7" joint="wam/palm_yaw_joint" kp="100"/>-->
|
||||||
|
<!-- </actuator>-->
|
||||||
|
<!-- <actuator>-->
|
||||||
|
<!-- <motor ctrlrange="-150 150" joint="wam/base_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-125 125" joint="wam/shoulder_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-40 40" joint="wam/shoulder_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-60 60" joint="wam/elbow_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-5 5" joint="wam/wrist_yaw_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-5 5" joint="wam/wrist_pitch_joint"/>-->
|
||||||
|
<!-- <motor ctrlrange="-2 2" joint="wam/palm_yaw_joint"/>-->
|
||||||
|
<!-- </actuator>-->
|
||||||
|
<actuator>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="150.0" joint="wam/base_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="125.0" joint="wam/shoulder_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="40.0" joint="wam/shoulder_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="60.0" joint="wam/elbow_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="5.0" joint="wam/wrist_yaw_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="5.0" joint="wam/wrist_pitch_joint"/>
|
||||||
|
<motor ctrllimited="true" ctrlrange="-1.0 1.0" gear="2.0" joint="wam/palm_yaw_joint"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
143
alr_envs/mujoco/beerpong/beerpong.py
Normal file
143
alr_envs/mujoco/beerpong/beerpong.py
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
from gym import utils
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_mujoco_env
|
||||||
|
|
||||||
|
|
||||||
|
class ALRBeerpongEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||||
|
def __init__(self, n_substeps=4, apply_gravity_comp=True, reward_function=None):
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets",
|
||||||
|
"beerpong" + ".xml")
|
||||||
|
|
||||||
|
self.start_pos = np.array([0.0, 1.35, 0.0, 1.18, 0.0, -0.786, -1.59])
|
||||||
|
self.start_vel = np.zeros(7)
|
||||||
|
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
# self.weight_matrix_scale = 50
|
||||||
|
self.max_ctrl = np.array([150., 125., 40., 60., 5., 5., 2.])
|
||||||
|
self.p_gains = 1 / self.max_ctrl * np.array([200, 300, 100, 100, 10, 10, 2.5])
|
||||||
|
self.d_gains = 1 / self.max_ctrl * np.array([7, 15, 5, 2.5, 0.3, 0.3, 0.05])
|
||||||
|
|
||||||
|
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||||
|
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||||
|
|
||||||
|
self.context = None
|
||||||
|
|
||||||
|
utils.EzPickle.__init__(self)
|
||||||
|
alr_mujoco_env.AlrMujocoEnv.__init__(self,
|
||||||
|
self.xml_path,
|
||||||
|
apply_gravity_comp=apply_gravity_comp,
|
||||||
|
n_substeps=n_substeps)
|
||||||
|
|
||||||
|
self.sim_time = 8 # seconds
|
||||||
|
self.sim_steps = int(self.sim_time / self.dt)
|
||||||
|
if reward_function is None:
|
||||||
|
from alr_envs.mujoco.beerpong.beerpong_reward import BeerpongReward
|
||||||
|
reward_function = BeerpongReward
|
||||||
|
self.reward_function = reward_function(self.sim, self.sim_steps)
|
||||||
|
self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"]
|
||||||
|
self.ball_id = self.sim.model._body_name2id["ball"]
|
||||||
|
self.cup_table_id = self.sim.model._body_name2id["cup_table"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_pos(self):
|
||||||
|
return self.sim.data.qpos[0:7].copy()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_vel(self):
|
||||||
|
return self.sim.data.qvel[0:7].copy()
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
self.context = context
|
||||||
|
self.reward_function.reset(context)
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
init_pos_all = self.init_qpos.copy()
|
||||||
|
init_pos_robot = self.start_pos
|
||||||
|
init_vel = np.zeros_like(init_pos_all)
|
||||||
|
|
||||||
|
self._steps = 0
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
|
||||||
|
start_pos = init_pos_all
|
||||||
|
start_pos[0:7] = init_pos_robot
|
||||||
|
# start_pos[7:] = np.copy(self.sim.data.site_xpos[self.cup_robot_id, :]) + np.array([0., 0.0, 0.05])
|
||||||
|
|
||||||
|
self.set_state(start_pos, init_vel)
|
||||||
|
|
||||||
|
ball_pos = np.copy(self.sim.data.site_xpos[self.cup_robot_id, :]) + np.array([0., 0.0, 0.05])
|
||||||
|
self.sim.model.body_pos[self.ball_id] = ball_pos.copy()
|
||||||
|
self.sim.model.body_pos[self.cup_table_id] = self.context.copy()
|
||||||
|
|
||||||
|
return self._get_obs()
|
||||||
|
|
||||||
|
def step(self, a):
|
||||||
|
reward_dist = 0.0
|
||||||
|
angular_vel = 0.0
|
||||||
|
reward_ctrl = - np.square(a).sum()
|
||||||
|
|
||||||
|
crash = self.do_simulation(a)
|
||||||
|
joint_cons_viol = self.check_traj_in_joint_limits()
|
||||||
|
|
||||||
|
self._q_pos.append(self.sim.data.qpos[0:7].ravel().copy())
|
||||||
|
self._q_vel.append(self.sim.data.qvel[0:7].ravel().copy())
|
||||||
|
|
||||||
|
ob = self._get_obs()
|
||||||
|
|
||||||
|
if not crash and not joint_cons_viol:
|
||||||
|
reward, success, stop_sim = self.reward_function.compute_reward(a, self.sim, self._steps)
|
||||||
|
done = success or self._steps == self.sim_steps - 1 or stop_sim
|
||||||
|
self._steps += 1
|
||||||
|
else:
|
||||||
|
reward = -1000
|
||||||
|
success = False
|
||||||
|
done = True
|
||||||
|
return ob, reward, done, dict(reward_dist=reward_dist,
|
||||||
|
reward_ctrl=reward_ctrl,
|
||||||
|
velocity=angular_vel,
|
||||||
|
traj=self._q_pos, is_success=success,
|
||||||
|
is_collided=crash or joint_cons_viol)
|
||||||
|
|
||||||
|
def check_traj_in_joint_limits(self):
|
||||||
|
return any(self.current_pos > self.j_max) or any(self.current_pos < self.j_min)
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self.sim.data.qpos.flat[:7]
|
||||||
|
return np.concatenate([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
# self.get_body_com("target"), # only return target to make problem harder
|
||||||
|
[self._steps],
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
env = ALRBeerpongEnv()
|
||||||
|
ctxt = np.array([0, -2, 0.840]) # initial
|
||||||
|
|
||||||
|
env.configure(ctxt)
|
||||||
|
env.reset()
|
||||||
|
env.render()
|
||||||
|
for i in range(16000):
|
||||||
|
# test with random actions
|
||||||
|
ac = 0.0 * env.action_space.sample()[0:7]
|
||||||
|
ac[1] = -0.8
|
||||||
|
ac[3] = - 0.3
|
||||||
|
ac[5] = -0.2
|
||||||
|
# ac = env.start_pos
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render()
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
||||||
|
|
124
alr_envs/mujoco/beerpong/beerpong_reward.py
Normal file
124
alr_envs/mujoco/beerpong/beerpong_reward.py
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_reward_fct
|
||||||
|
|
||||||
|
|
||||||
|
class BeerpongReward(alr_reward_fct.AlrReward):
|
||||||
|
def __init__(self, sim, sim_time):
|
||||||
|
|
||||||
|
self.sim = sim
|
||||||
|
self.sim_time = sim_time
|
||||||
|
|
||||||
|
self.collision_objects = ["cup_geom1", "cup_geom2", "wrist_palm_link_convex_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p2_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p3_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p2_geom",
|
||||||
|
"forearm_link_convex_decomposition_p1_geom",
|
||||||
|
"forearm_link_convex_decomposition_p2_geom"]
|
||||||
|
|
||||||
|
self.ball_id = None
|
||||||
|
self.ball_collision_id = None
|
||||||
|
self.goal_id = None
|
||||||
|
self.goal_final_id = None
|
||||||
|
self.collision_ids = None
|
||||||
|
|
||||||
|
self.ball_traj = None
|
||||||
|
self.dists = None
|
||||||
|
self.dists_ctxt = None
|
||||||
|
self.dists_final = None
|
||||||
|
self.costs = None
|
||||||
|
|
||||||
|
self.reset(None)
|
||||||
|
|
||||||
|
def reset(self, context):
|
||||||
|
self.ball_traj = np.zeros(shape=(self.sim_time, 3))
|
||||||
|
self.dists = []
|
||||||
|
self.dists_ctxt = []
|
||||||
|
self.dists_final = []
|
||||||
|
self.costs = []
|
||||||
|
self.context = context
|
||||||
|
self.ball_in_cup = False
|
||||||
|
self.dist_ctxt = 5
|
||||||
|
|
||||||
|
self.ball_id = self.sim.model._body_name2id["ball"]
|
||||||
|
self.ball_collision_id = self.sim.model._geom_name2id["ball_geom"]
|
||||||
|
self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"]
|
||||||
|
self.goal_id = self.sim.model._site_name2id["cup_goal_table"]
|
||||||
|
self.goal_final_id = self.sim.model._site_name2id["cup_goal_final_table"]
|
||||||
|
self.collision_ids = [self.sim.model._geom_name2id[name] for name in self.collision_objects]
|
||||||
|
self.cup_table_id = self.sim.model._body_name2id["cup_table"]
|
||||||
|
|
||||||
|
def compute_reward(self, action, sim, step):
|
||||||
|
action_cost = np.sum(np.square(action))
|
||||||
|
|
||||||
|
stop_sim = False
|
||||||
|
success = False
|
||||||
|
|
||||||
|
if self.check_collision(sim):
|
||||||
|
reward = - 1e-4 * action_cost - 1000
|
||||||
|
stop_sim = True
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
# Compute the current distance from the ball to the inner part of the cup
|
||||||
|
goal_pos = sim.data.site_xpos[self.goal_id]
|
||||||
|
ball_pos = sim.data.body_xpos[self.ball_id]
|
||||||
|
goal_final_pos = sim.data.site_xpos[self.goal_final_id]
|
||||||
|
self.dists.append(np.linalg.norm(goal_pos - ball_pos))
|
||||||
|
self.dists_final.append(np.linalg.norm(goal_final_pos - ball_pos))
|
||||||
|
self.dists_ctxt.append(np.linalg.norm(ball_pos - self.context))
|
||||||
|
self.ball_traj[step, :] = ball_pos
|
||||||
|
|
||||||
|
# Determine the first time when ball is in cup
|
||||||
|
if not self.ball_in_cup:
|
||||||
|
ball_in_cup = self.check_ball_in_cup(sim, self.ball_collision_id)
|
||||||
|
self.ball_in_cup = ball_in_cup
|
||||||
|
if ball_in_cup:
|
||||||
|
dist_to_ctxt = np.linalg.norm(ball_pos - self.context)
|
||||||
|
self.dist_ctxt = dist_to_ctxt
|
||||||
|
|
||||||
|
if step == self.sim_time - 1:
|
||||||
|
min_dist = np.min(self.dists)
|
||||||
|
dist_final = self.dists_final[-1]
|
||||||
|
# dist_ctxt = self.dists_ctxt[-1]
|
||||||
|
|
||||||
|
# cost = self._get_stage_wise_cost(ball_in_cup, min_dist, dist_final, dist_ctxt)
|
||||||
|
cost = 2 * (0.5 * min_dist + 0.5 * dist_final + 0.1 * self.dist_ctxt)
|
||||||
|
reward = np.exp(-1 * cost) - 1e-4 * action_cost
|
||||||
|
success = dist_final < 0.05 and self.dist_ctxt < 0.05
|
||||||
|
else:
|
||||||
|
reward = - 1e-4 * action_cost
|
||||||
|
success = False
|
||||||
|
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
def _get_stage_wise_cost(self, ball_in_cup, min_dist, dist_final, dist_to_ctxt):
|
||||||
|
if not ball_in_cup:
|
||||||
|
cost = 3 + 2*(0.5 * min_dist**2 + 0.5 * dist_final**2)
|
||||||
|
else:
|
||||||
|
cost = 2 * dist_to_ctxt ** 2
|
||||||
|
print('Context Distance:', dist_to_ctxt)
|
||||||
|
return cost
|
||||||
|
|
||||||
|
def check_ball_in_cup(self, sim, ball_collision_id):
|
||||||
|
cup_base_collision_id = sim.model._geom_name2id["cup_base_contact"]
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 == cup_base_collision_id and con.geom2 == ball_collision_id
|
||||||
|
collision_trans = con.geom1 == ball_collision_id and con.geom2 == cup_base_collision_id
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_collision(self, sim):
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 in self.collision_ids and con.geom2 == self.ball_collision_id
|
||||||
|
collision_trans = con.geom1 == self.ball_collision_id and con.geom2 in self.collision_ids
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
141
alr_envs/mujoco/beerpong/beerpong_reward_simple.py
Normal file
141
alr_envs/mujoco/beerpong/beerpong_reward_simple.py
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_reward_fct
|
||||||
|
|
||||||
|
|
||||||
|
class BeerpongReward(alr_reward_fct.AlrReward):
|
||||||
|
def __init__(self, sim, sim_time):
|
||||||
|
|
||||||
|
self.sim = sim
|
||||||
|
self.sim_time = sim_time
|
||||||
|
|
||||||
|
self.collision_objects = ["cup_geom1", "cup_geom2", "wrist_palm_link_convex_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p2_geom",
|
||||||
|
"wrist_pitch_link_convex_decomposition_p3_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p1_geom",
|
||||||
|
"wrist_yaw_link_convex_decomposition_p2_geom",
|
||||||
|
"forearm_link_convex_decomposition_p1_geom",
|
||||||
|
"forearm_link_convex_decomposition_p2_geom"]
|
||||||
|
|
||||||
|
self.ball_id = None
|
||||||
|
self.ball_collision_id = None
|
||||||
|
self.goal_id = None
|
||||||
|
self.goal_final_id = None
|
||||||
|
self.collision_ids = None
|
||||||
|
|
||||||
|
self.ball_traj = None
|
||||||
|
self.dists = None
|
||||||
|
self.dists_ctxt = None
|
||||||
|
self.dists_final = None
|
||||||
|
self.costs = None
|
||||||
|
|
||||||
|
self.reset(None)
|
||||||
|
|
||||||
|
def reset(self, context):
|
||||||
|
self.ball_traj = np.zeros(shape=(self.sim_time, 3))
|
||||||
|
self.dists = []
|
||||||
|
self.dists_ctxt = []
|
||||||
|
self.dists_final = []
|
||||||
|
self.costs = []
|
||||||
|
self.action_costs = []
|
||||||
|
self.context = context
|
||||||
|
self.ball_in_cup = False
|
||||||
|
self.dist_ctxt = 5
|
||||||
|
self.bounce_dist = 2
|
||||||
|
self.min_dist = 2
|
||||||
|
self.dist_final = 2
|
||||||
|
self.table_contact = False
|
||||||
|
|
||||||
|
self.ball_id = self.sim.model._body_name2id["ball"]
|
||||||
|
self.ball_collision_id = self.sim.model._geom_name2id["ball_geom"]
|
||||||
|
self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"]
|
||||||
|
self.goal_id = self.sim.model._site_name2id["cup_goal_table"]
|
||||||
|
self.goal_final_id = self.sim.model._site_name2id["cup_goal_final_table"]
|
||||||
|
self.collision_ids = [self.sim.model._geom_name2id[name] for name in self.collision_objects]
|
||||||
|
self.cup_table_id = self.sim.model._body_name2id["cup_table"]
|
||||||
|
self.bounce_table_id = self.sim.model._site_name2id["bounce_table"]
|
||||||
|
|
||||||
|
def compute_reward(self, action, sim, step):
|
||||||
|
action_cost = np.sum(np.square(action))
|
||||||
|
self.action_costs.append(action_cost)
|
||||||
|
|
||||||
|
stop_sim = False
|
||||||
|
success = False
|
||||||
|
|
||||||
|
if self.check_collision(sim):
|
||||||
|
reward = - 1e-2 * action_cost - 10
|
||||||
|
stop_sim = True
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
# Compute the current distance from the ball to the inner part of the cup
|
||||||
|
goal_pos = sim.data.site_xpos[self.goal_id]
|
||||||
|
ball_pos = sim.data.body_xpos[self.ball_id]
|
||||||
|
bounce_pos = sim.data.site_xpos[self.bounce_table_id]
|
||||||
|
goal_final_pos = sim.data.site_xpos[self.goal_final_id]
|
||||||
|
self.dists.append(np.linalg.norm(goal_pos - ball_pos))
|
||||||
|
self.dists_final.append(np.linalg.norm(goal_final_pos - ball_pos))
|
||||||
|
self.ball_traj[step, :] = ball_pos
|
||||||
|
|
||||||
|
ball_in_cup = self.check_ball_in_cup(sim, self.ball_collision_id)
|
||||||
|
table_contact = self.check_ball_table_contact(sim, self.ball_collision_id)
|
||||||
|
|
||||||
|
if table_contact and not self.table_contact:
|
||||||
|
self.bounce_dist = np.minimum((np.linalg.norm(bounce_pos - ball_pos)), 2)
|
||||||
|
self.table_contact = True
|
||||||
|
|
||||||
|
if step == self.sim_time - 1:
|
||||||
|
min_dist = np.min(self.dists)
|
||||||
|
self.min_dist = min_dist
|
||||||
|
dist_final = self.dists_final[-1]
|
||||||
|
self.dist_final = dist_final
|
||||||
|
|
||||||
|
cost = 0.33 * min_dist + 0.33 * dist_final + 0.33 * self.bounce_dist
|
||||||
|
reward = np.exp(-2 * cost) - 1e-2 * action_cost
|
||||||
|
success = self.bounce_dist < 0.05 and dist_final < 0.05 and ball_in_cup
|
||||||
|
else:
|
||||||
|
reward = - 1e-2 * action_cost
|
||||||
|
success = False
|
||||||
|
|
||||||
|
return reward, success, stop_sim
|
||||||
|
|
||||||
|
def _get_stage_wise_cost(self, ball_in_cup, min_dist, dist_final, dist_to_ctxt):
|
||||||
|
if not ball_in_cup:
|
||||||
|
cost = 3 + 2*(0.5 * min_dist**2 + 0.5 * dist_final**2)
|
||||||
|
else:
|
||||||
|
cost = 2 * dist_to_ctxt ** 2
|
||||||
|
print('Context Distance:', dist_to_ctxt)
|
||||||
|
return cost
|
||||||
|
|
||||||
|
def check_ball_table_contact(self, sim, ball_collision_id):
|
||||||
|
table_collision_id = sim.model._geom_name2id["table_contact_geom"]
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
collision = con.geom1 == table_collision_id and con.geom2 == ball_collision_id
|
||||||
|
collision_trans = con.geom1 == ball_collision_id and con.geom2 == table_collision_id
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_ball_in_cup(self, sim, ball_collision_id):
|
||||||
|
cup_base_collision_id = sim.model._geom_name2id["cup_base_table_contact"]
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 == cup_base_collision_id and con.geom2 == ball_collision_id
|
||||||
|
collision_trans = con.geom1 == ball_collision_id and con.geom2 == cup_base_collision_id
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_collision(self, sim):
|
||||||
|
for coni in range(0, sim.data.ncon):
|
||||||
|
con = sim.data.contact[coni]
|
||||||
|
|
||||||
|
collision = con.geom1 in self.collision_ids and con.geom2 == self.ball_collision_id
|
||||||
|
collision_trans = con.geom1 == self.ball_collision_id and con.geom2 in self.collision_ids
|
||||||
|
|
||||||
|
if collision or collision_trans:
|
||||||
|
return True
|
||||||
|
return False
|
164
alr_envs/mujoco/beerpong/beerpong_simple.py
Normal file
164
alr_envs/mujoco/beerpong/beerpong_simple.py
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
from gym import utils
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
from alr_envs.mujoco import alr_mujoco_env
|
||||||
|
|
||||||
|
|
||||||
|
class ALRBeerpongEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||||
|
def __init__(self, n_substeps=4, apply_gravity_comp=True, reward_function=None):
|
||||||
|
self._steps = 0
|
||||||
|
|
||||||
|
self.xml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets",
|
||||||
|
"beerpong" + ".xml")
|
||||||
|
|
||||||
|
self.start_pos = np.array([0.0, 1.35, 0.0, 1.18, 0.0, -0.786, -1.59])
|
||||||
|
self.start_vel = np.zeros(7)
|
||||||
|
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
# self.weight_matrix_scale = 50
|
||||||
|
self.max_ctrl = np.array([150., 125., 40., 60., 5., 5., 2.])
|
||||||
|
self.p_gains = 1 / self.max_ctrl * np.array([200, 300, 100, 100, 10, 10, 2.5])
|
||||||
|
self.d_gains = 1 / self.max_ctrl * np.array([7, 15, 5, 2.5, 0.3, 0.3, 0.05])
|
||||||
|
|
||||||
|
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||||
|
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||||
|
|
||||||
|
self.context = None
|
||||||
|
|
||||||
|
utils.EzPickle.__init__(self)
|
||||||
|
alr_mujoco_env.AlrMujocoEnv.__init__(self,
|
||||||
|
self.xml_path,
|
||||||
|
apply_gravity_comp=apply_gravity_comp,
|
||||||
|
n_substeps=n_substeps)
|
||||||
|
|
||||||
|
self.sim_time = 8 # seconds
|
||||||
|
self.sim_steps = int(self.sim_time / self.dt)
|
||||||
|
if reward_function is None:
|
||||||
|
from alr_envs.mujoco.beerpong.beerpong_reward_simple import BeerpongReward
|
||||||
|
reward_function = BeerpongReward
|
||||||
|
self.reward_function = reward_function(self.sim, self.sim_steps)
|
||||||
|
self.cup_robot_id = self.sim.model._site_name2id["cup_robot_final"]
|
||||||
|
self.ball_id = self.sim.model._body_name2id["ball"]
|
||||||
|
self.cup_table_id = self.sim.model._body_name2id["cup_table"]
|
||||||
|
# self.bounce_table_id = self.sim.model._body_name2id["bounce_table"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_pos(self):
|
||||||
|
return self.sim.data.qpos[0:7].copy()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_vel(self):
|
||||||
|
return self.sim.data.qvel[0:7].copy()
|
||||||
|
|
||||||
|
def configure(self, context):
|
||||||
|
if context is None:
|
||||||
|
context = np.array([0, -2, 0.840])
|
||||||
|
self.context = context
|
||||||
|
self.reward_function.reset(context)
|
||||||
|
|
||||||
|
def reset_model(self):
|
||||||
|
init_pos_all = self.init_qpos.copy()
|
||||||
|
init_pos_robot = self.start_pos
|
||||||
|
init_vel = np.zeros_like(init_pos_all)
|
||||||
|
|
||||||
|
self._steps = 0
|
||||||
|
self._q_pos = []
|
||||||
|
self._q_vel = []
|
||||||
|
|
||||||
|
start_pos = init_pos_all
|
||||||
|
start_pos[0:7] = init_pos_robot
|
||||||
|
# start_pos[7:] = np.copy(self.sim.data.site_xpos[self.cup_robot_id, :]) + np.array([0., 0.0, 0.05])
|
||||||
|
|
||||||
|
self.set_state(start_pos, init_vel)
|
||||||
|
|
||||||
|
ball_pos = np.copy(self.sim.data.site_xpos[self.cup_robot_id, :]) + np.array([0., 0.0, 0.05])
|
||||||
|
self.sim.model.body_pos[self.ball_id] = ball_pos.copy()
|
||||||
|
self.sim.model.body_pos[self.cup_table_id] = self.context.copy()
|
||||||
|
# self.sim.model.body_pos[self.bounce_table_id] = self.context.copy()
|
||||||
|
|
||||||
|
self.sim.forward()
|
||||||
|
|
||||||
|
return self._get_obs()
|
||||||
|
|
||||||
|
def step(self, a):
|
||||||
|
reward_dist = 0.0
|
||||||
|
angular_vel = 0.0
|
||||||
|
reward_ctrl = - np.square(a).sum()
|
||||||
|
action_cost = np.sum(np.square(a))
|
||||||
|
|
||||||
|
crash = self.do_simulation(a)
|
||||||
|
joint_cons_viol = self.check_traj_in_joint_limits()
|
||||||
|
|
||||||
|
self._q_pos.append(self.sim.data.qpos[0:7].ravel().copy())
|
||||||
|
self._q_vel.append(self.sim.data.qvel[0:7].ravel().copy())
|
||||||
|
|
||||||
|
ob = self._get_obs()
|
||||||
|
|
||||||
|
if not crash and not joint_cons_viol:
|
||||||
|
reward, success, stop_sim = self.reward_function.compute_reward(a, self.sim, self._steps)
|
||||||
|
done = success or self._steps == self.sim_steps - 1 or stop_sim
|
||||||
|
self._steps += 1
|
||||||
|
else:
|
||||||
|
reward = -10 - 1e-2 * action_cost
|
||||||
|
success = False
|
||||||
|
done = True
|
||||||
|
return ob, reward, done, dict(reward_dist=reward_dist,
|
||||||
|
reward_ctrl=reward_ctrl,
|
||||||
|
velocity=angular_vel,
|
||||||
|
traj=self._q_pos, is_success=success,
|
||||||
|
is_collided=crash or joint_cons_viol)
|
||||||
|
|
||||||
|
def check_traj_in_joint_limits(self):
|
||||||
|
return any(self.current_pos > self.j_max) or any(self.current_pos < self.j_min)
|
||||||
|
|
||||||
|
def extend_des_pos(self, des_pos):
|
||||||
|
des_pos_full = self.start_pos.copy()
|
||||||
|
des_pos_full[1] = des_pos[0]
|
||||||
|
des_pos_full[3] = des_pos[1]
|
||||||
|
des_pos_full[5] = des_pos[2]
|
||||||
|
return des_pos_full
|
||||||
|
|
||||||
|
def extend_des_vel(self, des_vel):
|
||||||
|
des_vel_full = self.start_vel.copy()
|
||||||
|
des_vel_full[1] = des_vel[0]
|
||||||
|
des_vel_full[3] = des_vel[1]
|
||||||
|
des_vel_full[5] = des_vel[2]
|
||||||
|
return des_vel_full
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
theta = self.sim.data.qpos.flat[:7]
|
||||||
|
return np.concatenate([
|
||||||
|
np.cos(theta),
|
||||||
|
np.sin(theta),
|
||||||
|
# self.get_body_com("target"), # only return target to make problem harder
|
||||||
|
[self._steps],
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
env = ALRBeerpongEnv()
|
||||||
|
ctxt = np.array([0, -2, 0.840]) # initial
|
||||||
|
|
||||||
|
env.configure(ctxt)
|
||||||
|
env.reset()
|
||||||
|
env.render()
|
||||||
|
for i in range(16000):
|
||||||
|
# test with random actions
|
||||||
|
ac = 0.0 * env.action_space.sample()[0:7]
|
||||||
|
ac[1] = -0.01
|
||||||
|
ac[3] = - 0.01
|
||||||
|
ac[5] = -0.01
|
||||||
|
# ac = env.start_pos
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render()
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
||||||
|
|
105
alr_envs/mujoco/beerpong/utils.py
Normal file
105
alr_envs/mujoco/beerpong/utils.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
from alr_envs.utils.wrapper.detpmp_wrapper import DetPMPWrapper
|
||||||
|
from alr_envs.mujoco.beerpong.beerpong import ALRBeerpongEnv
|
||||||
|
from alr_envs.mujoco.beerpong.beerpong_simple import ALRBeerpongEnv as ALRBeerpongEnvSimple
|
||||||
|
|
||||||
|
|
||||||
|
def make_contextual_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBeerpongEnv()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=7,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos,
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.5,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBeerpongEnvSimple()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=7,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos,
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.25,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
||||||
|
|
||||||
|
|
||||||
|
def make_simple_env(rank, seed=0):
|
||||||
|
"""
|
||||||
|
Utility function for multiprocessed env.
|
||||||
|
|
||||||
|
:param env_id: (str) the environment ID
|
||||||
|
:param num_env: (int) the number of environments you wish to have in subprocesses
|
||||||
|
:param seed: (int) the initial seed for RNG
|
||||||
|
:param rank: (int) index of the subprocess
|
||||||
|
:returns a function that generates an environment
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _init():
|
||||||
|
env = ALRBeerpongEnvSimple()
|
||||||
|
|
||||||
|
env = DetPMPWrapper(env,
|
||||||
|
num_dof=3,
|
||||||
|
num_basis=5,
|
||||||
|
width=0.005,
|
||||||
|
policy_type="motor",
|
||||||
|
start_pos=env.start_pos[1::2],
|
||||||
|
duration=3.5,
|
||||||
|
post_traj_time=4.5,
|
||||||
|
dt=env.dt,
|
||||||
|
weights_scale=0.5,
|
||||||
|
zero_start=True,
|
||||||
|
zero_goal=True
|
||||||
|
)
|
||||||
|
|
||||||
|
env.seed(seed + rank)
|
||||||
|
return env
|
||||||
|
|
||||||
|
return _init
|
1
alr_envs/mujoco/gym_table_tennis/__init__.py
Normal file
1
alr_envs/mujoco/gym_table_tennis/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
3
alr_envs/mujoco/gym_table_tennis/envs/MUJOCO_LOG.TXT
Normal file
3
alr_envs/mujoco/gym_table_tennis/envs/MUJOCO_LOG.TXT
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Mon Jan 25 15:45:30 2021
|
||||||
|
ERROR: GLEW initalization error: Missing GL version
|
||||||
|
|
1
alr_envs/mujoco/gym_table_tennis/envs/__init__.py
Normal file
1
alr_envs/mujoco/gym_table_tennis/envs/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,12 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<actuator boastype="none">
|
||||||
|
<motor name="wam/shoulder_yaw_link_right_motor" joint="wam/base_yaw_joint_right"/>
|
||||||
|
<motor name="wam/shoulder_pitch_joint_right_motor" joint='wam/shoulder_pitch_joint_right'/>
|
||||||
|
<motor name="wam/shoulder_yaw_joint_right_motor" joint='wam/shoulder_yaw_joint_right'/>
|
||||||
|
<motor name="wam/elbow_pitch_joint_right_motor" joint='wam/elbow_pitch_joint_right'/>
|
||||||
|
<motor name="wam/wrist_yaw_joint_right_motor" joint='wam/wrist_yaw_joint_right'/>
|
||||||
|
<motor name="wam/wrist_pitch_joint_right_motor" joint='wam/wrist_pitch_joint_right'/>
|
||||||
|
<motor name="wam/palm_yaw_joint_right_motor" joint='wam/palm_yaw_joint_right'/>
|
||||||
|
</actuator>
|
||||||
|
</mujocoinclude>
|
||||||
|
|
@ -0,0 +1,76 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<body name="wam/base_link_left" pos="-2.5 0 2" quat="0 1 0 0" childclass="wam">
|
||||||
|
<inertial pos="0 0 0" mass="1" diaginertia="0.1 0.1 0.1"/>
|
||||||
|
<geom class="viz" mesh="base_link_fine" rgba="0.5 0.5 0.5 0"/>
|
||||||
|
<geom class="col" mesh="base_link_convex" rgba="0.5 0.5 0.5 1"/>
|
||||||
|
<body name="wam/shoulder_yaw_link" pos="0 0 0.346">
|
||||||
|
<inertial pos="-0.00443422 -0.00066489 -0.128904" quat="0.69566 0.716713 -0.0354863 0.0334839" mass="5"
|
||||||
|
diaginertia="0.135089 0.113095 0.0904426"/>
|
||||||
|
<joint name="wam/base_yaw_joint" range="-2.6 2.6" damping="1.98"/>
|
||||||
|
<geom class="viz" mesh="shoulder_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="shoulder_link_convex_decomposition_p1"/>
|
||||||
|
<geom class="col" mesh="shoulder_link_convex_decomposition_p2"/>
|
||||||
|
<geom class="col" mesh="shoulder_link_convex_decomposition_p3"/>
|
||||||
|
<body name="wam/shoulder_pitch_link" pos="0 0 0" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00236981 -0.0154211 0.0310561" quat="0.961794 0.273112 -0.0169316 0.00866592"
|
||||||
|
mass="3.87494" diaginertia="0.0214195 0.0167127 0.0126452"/> <!--seems off-->
|
||||||
|
<joint name="wam/shoulder_pitch_joint" range="-1.985 1.985" damping="0.55"/>
|
||||||
|
<geom class="viz" mesh="shoulder_pitch_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="shoulder_pitch_link_convex"/>
|
||||||
|
<body name="wam/upper_arm_link" pos="0 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="0.00683259 3.309e-005 0.392492" quat="0.647136 0.0170822 0.0143038 0.762049"
|
||||||
|
mass="2.20228" diaginertia="0.0592718 0.0592207 0.00313419"/>
|
||||||
|
<joint name="wam/shoulder_yaw_joint" range="-2.8 2.8" damping="1.65"/>
|
||||||
|
<geom class="viz" mesh="upper_arm_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="upper_arm_link_convex_decomposition_p1" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<geom class="col" mesh="upper_arm_link_convex_decomposition_p2" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<body name="wam/forearm_link" pos="0.045 0 0.55" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.0400149 -0.142717 -0.00022942"
|
||||||
|
quat="0.704281 0.706326 0.0180333 0.0690353" mass="0.500168"
|
||||||
|
diaginertia="0.0151047 0.0148285 0.00275805"/>
|
||||||
|
<joint name="wam/elbow_pitch_joint" range="-0.9 3.14159" damping="0.88"/>
|
||||||
|
<geom class="viz" mesh="elbow_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="elbow_link_convex"/>
|
||||||
|
<geom class="viz" mesh="forearm_link_fine" pos="-.045 -0.0730 0" euler="1.57 0 0" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="forearm_link_convex_decomposition_p1" pos="-0.045 -0.0730 0"
|
||||||
|
euler="1.57 0 0" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<geom class="col" mesh="forearm_link_convex_decomposition_p2" pos="-.045 -0.0730 0"
|
||||||
|
euler="1.57 0 0" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<body name="wam/wrist_yaw_link" pos="-0.045 -0.3 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="8.921e-005 0.00435824 -0.00511217"
|
||||||
|
quat="0.630602 0.776093 0.00401969 -0.002372" mass="1.05376"
|
||||||
|
diaginertia="0.000555168 0.00046317 0.000234072"/> <!--this is an approximation-->
|
||||||
|
<joint name="wam/wrist_yaw_joint" range="-4.55 1.25" damping="0.55"/>
|
||||||
|
<geom class="viz" mesh="wrist_yaw_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="wrist_yaw_link_convex_decomposition_p1"/>
|
||||||
|
<geom class="col" mesh="wrist_yaw_link_convex_decomposition_p2"/>
|
||||||
|
<body name="wam/wrist_pitch_link" pos="0 0 0" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00012262 -0.0246834 -0.0170319"
|
||||||
|
quat="0.630602 0.776093 0.00401969 -0.002372" mass="0.517974"
|
||||||
|
diaginertia="0.000555168 0.00046317 0.000234072"/>
|
||||||
|
<joint name="wam/wrist_pitch_joint" range="-1.5707 1.5707" damping="0.11"/>
|
||||||
|
<geom class="viz" mesh="wrist_pitch_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p1" rgba="1 0.5 0.313 1"/>
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p2" rgba="1 0.5 0.313 1"/>
|
||||||
|
<geom class="col" mesh="wrist_pitch_link_convex_decomposition_p3" rgba="1 0.5 0.313 1"/>
|
||||||
|
<body name="wam/wrist_palm_link" pos="0 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="0 0 0.055" quat="0.707107 0 0 0.707107" mass="0.0828613"
|
||||||
|
diaginertia="0.00020683 0.00010859 0.00010851"/>
|
||||||
|
<joint name="wam/palm_yaw_joint" range="-3 3" damping="0.11"/>
|
||||||
|
<geom class="viz" mesh="wrist_palm_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom class="col" mesh="wrist_palm_link_convex"/>
|
||||||
|
<body name="paddle_left" pos="0 0 0.26" childclass="contact_geom">
|
||||||
|
<geom name="bat_left" type="cylinder" size="0.075 0.0015" rgba="1 0 0 1"
|
||||||
|
quat="0.71 0 0.71 0"/>
|
||||||
|
<geom name="handle_left" type="box" size="0.005 0.01 0.05" pos="0 0 -0.08"
|
||||||
|
rgba="1 1 1 1"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</mujocoinclude>
|
@ -0,0 +1,95 @@
|
|||||||
|
<mujocoinclue>
|
||||||
|
<body name="wam/base_link_right" pos="2.5 0 2" quat="0 0 1 0" childclass="wam" >
|
||||||
|
<inertial pos="0 0 0" mass="1" diaginertia="0.1 0.1 0.1"/>
|
||||||
|
<geom name="base_link_fine" class="viz" mesh="base_link_fine" rgba="0.5 0.5 0.5 0"/>
|
||||||
|
<geom name="base_link_convex" class="col" mesh="base_link_convex" rgba="0.5 0.5 0.5 1"/>
|
||||||
|
<body name="wam/shoulder_yaw_link_right" pos="0 0 0.346">
|
||||||
|
<inertial pos="-0.00443422 -0.00066489 -0.128904" quat="0.69566 0.716713 -0.0354863 0.0334839" mass="5"
|
||||||
|
diaginertia="0.135089 0.113095 0.0904426"/>
|
||||||
|
<joint name="wam/base_yaw_joint_right" range="-2.6 2.6" damping="1.98"/>
|
||||||
|
<geom name="shoulder_link_fine" class="viz" mesh="shoulder_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom name="shoulder_link_convex_decomposition_p1" class="col"
|
||||||
|
mesh="shoulder_link_convex_decomposition_p1"/>
|
||||||
|
<geom name="shoulder_link_convex_decomposition_p2" class="col"
|
||||||
|
mesh="shoulder_link_convex_decomposition_p2"/>
|
||||||
|
<geom name="shoulder_link_convex_decomposition_p3" class="col"
|
||||||
|
mesh="shoulder_link_convex_decomposition_p3"/>
|
||||||
|
<body name="wam/shoulder_pitch_link_right" pos="0 0 0" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00236981 -0.0154211 0.0310561" quat="0.961794 0.273112 -0.0169316 0.00866592"
|
||||||
|
mass="3.87494" diaginertia="0.0214195 0.0167127 0.0126452"/> <!--seems off-->
|
||||||
|
<joint name="wam/shoulder_pitch_joint_right" range="-2 2" damping="0.55"/>
|
||||||
|
<geom name="shoulder_pitch_link_fine" class="viz" mesh="shoulder_pitch_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom name="shoulder_pitch_link_convex" class="col" mesh="shoulder_pitch_link_convex"/>
|
||||||
|
<body name="wam/upper_arm_link_right" pos="0 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="0.00683259 3.309e-005 0.392492" quat="0.647136 0.0170822 0.0143038 0.762049"
|
||||||
|
mass="2.20228" diaginertia="0.0592718 0.0592207 0.00313419"/>
|
||||||
|
<joint name="wam/shoulder_yaw_joint_right" range="-2.8 2.8" damping="1.65"/>
|
||||||
|
<geom name="upper_arm_link_fine" class="viz" mesh="upper_arm_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom name="upper_arm_link_convex_decomposition_p1" class="col"
|
||||||
|
mesh="upper_arm_link_convex_decomposition_p1" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<geom name="upper_arm_link_convex_decomposition_p2" class="col"
|
||||||
|
mesh="upper_arm_link_convex_decomposition_p2" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<body name="wam/forearm_link_right" pos="0.045 0 0.55" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.0400149 -0.142717 -0.00022942"
|
||||||
|
quat="0.704281 0.706326 0.0180333 0.0690353" mass="0.500168"
|
||||||
|
diaginertia="0.0151047 0.0148285 0.00275805"/>
|
||||||
|
<joint name="wam/elbow_pitch_joint_right" range="-0.9 3.1" damping="0.88"/>
|
||||||
|
<geom name="elbow_link_fine" class="viz" mesh="elbow_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom name="elbow_link_convex" class="col" mesh="elbow_link_convex"/>
|
||||||
|
<geom name="forearm_link_fine" class="viz" mesh="forearm_link_fine" pos="-.045 -0.0730 0"
|
||||||
|
euler="1.57 0 0" rgba="1 1 1 0"/>
|
||||||
|
<geom name="forearm_link_convex_decomposition_p1" class="col"
|
||||||
|
mesh="forearm_link_convex_decomposition_p1" pos="-0.045 -0.0730 0"
|
||||||
|
euler="1.57 0 0" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<geom name="forearm_link_convex_decomposition_p2" class="col"
|
||||||
|
mesh="forearm_link_convex_decomposition_p2" pos="-.045 -0.0730 0"
|
||||||
|
euler="1.57 0 0" rgba="0.094 0.48 0.804 1"/>
|
||||||
|
<body name="wam/wrist_yaw_link_right" pos="-0.045 -0.3 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="8.921e-005 0.00435824 -0.00511217"
|
||||||
|
quat="0.630602 0.776093 0.00401969 -0.002372" mass="1.05376"
|
||||||
|
diaginertia="0.000555168 0.00046317 0.000234072"/> <!--this is an approximation-->
|
||||||
|
<joint name="wam/wrist_yaw_joint_right" range="-4.8 1.3" damping="0.55"/>
|
||||||
|
<geom name="wrist_yaw_link_fine" class="viz" mesh="wrist_yaw_link_fine" rgba="1 1 1 0"/>
|
||||||
|
<geom name="wrist_yaw_link_convex_decomposition_p1" class="col"
|
||||||
|
mesh="wrist_yaw_link_convex_decomposition_p1"/>
|
||||||
|
<geom name="wrist_yaw_link_convex_decomposition_p2" class="col"
|
||||||
|
mesh="wrist_yaw_link_convex_decomposition_p2"/>
|
||||||
|
<body name="wam/wrist_pitch_link_right" pos="0 0 0" quat="0.707107 -0.707107 0 0">
|
||||||
|
<inertial pos="-0.00012262 -0.0246834 -0.0170319"
|
||||||
|
quat="0.630602 0.776093 0.00401969 -0.002372" mass="0.517974"
|
||||||
|
diaginertia="0.000555168 0.00046317 0.000234072"/>
|
||||||
|
<joint name="wam/wrist_pitch_joint_right" range="-1.6 1.6" damping="0.11"/>
|
||||||
|
<geom name="wrist_pitch_link_fine" class="viz" mesh="wrist_pitch_link_fine"
|
||||||
|
rgba="1 1 1 0"/>
|
||||||
|
<geom name="wrist_pitch_link_convex_decomposition_p1" rgba="1 0.5 0.313 1"
|
||||||
|
class="col" mesh="wrist_pitch_link_convex_decomposition_p1"/>
|
||||||
|
<geom name="wrist_pitch_link_convex_decomposition_p2" rgba="1 0.5 0.313 1"
|
||||||
|
class="col" mesh="wrist_pitch_link_convex_decomposition_p2"/>
|
||||||
|
<geom name="wrist_pitch_link_convex_decomposition_p3" rgba="1 0.5 0.313 1"
|
||||||
|
class="col" mesh="wrist_pitch_link_convex_decomposition_p3"/>
|
||||||
|
<body name="wam/wrist_palm_link_right" pos="0 0 0" quat="0.707107 0.707107 0 0">
|
||||||
|
<inertial pos="0 0 0.055" quat="0.707107 0 0 0.707107" mass="0.0828613"
|
||||||
|
diaginertia="0.00020683 0.00010859 0.00010851"/>
|
||||||
|
<joint name="wam/palm_yaw_joint_right" range="-2.2 2.2" damping="0.11"/>
|
||||||
|
<geom name="wrist_palm_link_fine" class="viz" mesh="wrist_palm_link_fine"
|
||||||
|
rgba="1 1 1 0"/>
|
||||||
|
<geom name="wrist_palm_link_convex" class="col" mesh="wrist_palm_link_convex"/>
|
||||||
|
<!-- EE=wam/paddle, configure name to the end effector name-->
|
||||||
|
<body name="EE" pos="0 0 0.26" childclass="contact_geom">
|
||||||
|
<geom name="bat" type="cylinder" size="0.075 0.005" rgba="1 0 0 1"
|
||||||
|
quat="0.71 0 0.71 0"/>
|
||||||
|
<geom name="wam/paddle_handle" type="box" size="0.005 0.01 0.05" pos="0 0 -0.08"
|
||||||
|
rgba="1 1 1 1"/>
|
||||||
|
<!-- Extract information for sampling goals.-->
|
||||||
|
<site name="wam/paddle_center" pos="0 0 0" rgba="1 1 1 1" size="0.00001"/>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</mujocoinclue>
|
@ -0,0 +1,38 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<body name="table_tennis_table" pos="0 0 0">
|
||||||
|
<geom class="contact_geom" name="table_base_1" type="box" size="0.05 0.05 .375" rgba="1 1 1 1"
|
||||||
|
pos="1 0.7 0.375"/>
|
||||||
|
<geom class="contact_geom" name="table_base_2" type="box" size="0.05 0.05 .375" rgba="1 1 1 1"
|
||||||
|
pos="1 -0.7 0.375"/>
|
||||||
|
<geom class="contact_geom" name="table_base_3" type="box" size="0.05 0.05 .375" rgba="1 1 1 1"
|
||||||
|
pos="-1 -0.7 0.375"/>
|
||||||
|
<geom class="contact_geom" name="table_base_4" type="box" size="0.05 0.05 .375" rgba="1 1 1 1"
|
||||||
|
pos="-1 0.7 0.375"/>
|
||||||
|
<body name="table_top" pos="0 0 0.76">
|
||||||
|
<geom class="contact_geom" name="table_tennis_table" type="box" size="1.37 .7625 .01" rgba="0 0 0.5 1"
|
||||||
|
pos="0 0 0"/>
|
||||||
|
<!-- <geom class="contact_geom" name="table_tennis_table_right_side" type="box" size="0.685 .7625 .01"-->
|
||||||
|
<!-- rgba="0.5 0 0 1" pos="0.685 0 0"/>-->
|
||||||
|
<!-- <geom class="contact_geom" name="table_tennis_table_left_side" type="box" size="0.685 .7625 .01"-->
|
||||||
|
<!-- rgba="0 0.5 0 1" pos="-0.685 0 0"/>-->
|
||||||
|
<site name="left_up_corner" pos="-1.37 .7625 0.01" rgba="1 1 1 1" size="0.00001"/>
|
||||||
|
<site name="middle_up_corner" pos="0 .7625 0.01" rgba="1 1 1 1" size="0.00001"/>
|
||||||
|
<site name="left_down_corner" pos="-1.37 -0.7625 0.01" rgba="1 1 1 1" size="0.00001"/>
|
||||||
|
<site name="middle_down_corner" pos="0 -.7625 0.01" rgba="1 1 1 1" size="0.00001"/>
|
||||||
|
<geom class="contact_geom" name="table_tennis_net" type="box" size="0.01 0.915 0.07625"
|
||||||
|
material="floor_plane"
|
||||||
|
rgba="0 0 1 0.5"
|
||||||
|
pos="0 0 0.08625"/>
|
||||||
|
<geom class="contact_geom" name="left_while_line" type="box" size="1.37 .02 .001" rgba="1 1 1 1"
|
||||||
|
pos="0 -0.7425 0.01"/>
|
||||||
|
<geom class="contact_geom" name="center_while_line" type="box" size="1.37 .01 .001" rgba="1 1 1 1"
|
||||||
|
pos="0 0 0.01"/>
|
||||||
|
<geom class="contact_geom" name="right_while_line" type="box" size="1.37 .02 .001" rgba="1 1 1 1"
|
||||||
|
pos="0 0.7425 0.01"/>
|
||||||
|
<geom class="contact_geom" name="right_side_line" type="box" size="0.02 .7625 .001" rgba="1 1 1 1"
|
||||||
|
pos="1.35 0 0.01"/>
|
||||||
|
<geom class="contact_geom" name="left_side_line" type="box" size="0.02 .7625 .001" rgba="1 1 1 1"
|
||||||
|
pos="-1.35 0 0.01"/>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</mujocoinclude>
|
@ -0,0 +1,10 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<body name="target_ball" pos="-1.2 -0.6 1.5">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x" pos="0 0 0" stiffness="0" type="slide" frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y" pos="0 0 0" stiffness="0" type="slide" frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z" pos="0 0 0" stiffness="0" type="slide" frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="target_ball" rgba="1 1 0 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="target_ball" pos="0 0 0" size="0.02 0.02 0.02" rgba="1 0 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
</mujocoinclude>
|
@ -0,0 +1,80 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<body name="test_ball_table" pos="1 0 4">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_table" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_table" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_table" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_table" rgba="0 1 0 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_table" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<body name="test_ball_net" pos="0 0 4">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_net" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_net" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_net" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_net" rgba="1 1 0 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_net" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<body name="test_ball_racket_0" pos="2.54919187 0.81642672 4">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_racket_0" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_racket_0" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_racket_0" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_racket_0" rgba="1 0 1 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_racket_0" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<body name="test_ball_racket_1" pos="2.54919187 0.81642672 4.5">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_racket_1" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_racket_1" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_racket_1" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_racket_1" rgba="1 0 1 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_racket_1" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<body name="test_ball_racket_2" pos="2.54919187 0.81642672 3">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_racket_2" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_racket_2" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_racket_2" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_racket_2" rgba="1 0 1 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_racket" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<body name="test_ball_racket_3" pos="2.54919187 0.81642672 10">
|
||||||
|
<joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_racket_3" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_racket_3" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_racket_3" pos="0 0 0" stiffness="0" type="slide"
|
||||||
|
frictionloss="0"/>
|
||||||
|
<geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_racket_3" rgba="1 0 1 1" mass="0.1"
|
||||||
|
friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<site name="test_ball_racket_3" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>
|
||||||
|
</body>
|
||||||
|
<!-- <body name="test_ball_racket_4" pos="2.54919187 0.81642672 4">-->
|
||||||
|
<!-- <joint axis="1 0 0" damping="0.0" name="tar:x_test_ball_racket_4" pos="0 0 0" stiffness="0" type="slide"-->
|
||||||
|
<!-- frictionloss="0"/>-->
|
||||||
|
<!-- <joint axis="0 1 0" damping="0.0" name="tar:y_test_ball_racket_4" pos="0 0 0" stiffness="0" type="slide"-->
|
||||||
|
<!-- frictionloss="0"/>-->
|
||||||
|
<!-- <joint axis="0 0 1" damping="0.0" name="tar:z_test_ball_racket_4" pos="0 0 0" stiffness="0" type="slide"-->
|
||||||
|
<!-- frictionloss="0"/>-->
|
||||||
|
<!-- <geom size="0.025 0.025 0.025" type="sphere" condim="4" name="test_ball_racket_4" rgba="1 0 0 1" mass="0.1"-->
|
||||||
|
<!-- friction="0.1 0.1 0.1" solimp="1 1 0" solref="0.1 0.03"/>-->
|
||||||
|
<!-- <site name="test_ball_racket_4" pos="0 0 0" size="0.02 0.02 0.02" rgba="0 1 0 1" type="sphere"/>-->
|
||||||
|
<!-- </body>-->
|
||||||
|
|
||||||
|
</mujocoinclude>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,19 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<actuator>
|
||||||
|
|
||||||
|
<!-- <position ctrlrange="-2.6 2.6" joint="wam/base_yaw_joint_right" kp="100.0" />-->
|
||||||
|
<!-- <position ctrlrange="-1.985 1.985" joint="wam/shoulder_pitch_joint_right" kp="162.0" />-->
|
||||||
|
<!-- <position ctrlrange="-2.8 2.8" joint="wam/shoulder_yaw_joint_right" kp="100.0" />-->
|
||||||
|
<!-- <position ctrlrange="-0.9 3.14159" joint="wam/elbow_pitch_joint_right" kp="122.0" />-->
|
||||||
|
<!-- <position ctrlrange="-4.55 1.25" joint="wam/wrist_yaw_joint_right" kp="100.0" />-->
|
||||||
|
<!-- <position ctrlrange="-1.5707 1.5707" joint="wam/wrist_pitch_joint_right" kp="102.0" />-->
|
||||||
|
<!-- <position ctrlrange="-3 3" joint="wam/palm_yaw_joint_right" kp="100.0" />-->
|
||||||
|
<position ctrlrange="-2.6 2.6" joint="wam/base_yaw_joint_right" kp="151.0"/>
|
||||||
|
<position ctrlrange="-1.985 1.985" joint="wam/shoulder_pitch_joint_right" kp="125.0"/>
|
||||||
|
<position ctrlrange="-2.8 2.8" joint="wam/shoulder_yaw_joint_right" kp="122.0"/>
|
||||||
|
<position ctrlrange="-0.9 3.14159" joint="wam/elbow_pitch_joint_right" kp="121.0"/>
|
||||||
|
<position ctrlrange="-4.55 1.25" joint="wam/wrist_yaw_joint_right" kp="99.0"/>
|
||||||
|
<position ctrlrange="-1.5707 1.5707" joint="wam/wrist_pitch_joint_right" kp="103.0"/>
|
||||||
|
<position ctrlrange="-3 3" joint="wam/palm_yaw_joint_right" kp="99.0"/>
|
||||||
|
</actuator>
|
||||||
|
</mujocoinclude>
|
49
alr_envs/mujoco/gym_table_tennis/envs/assets/shared.xml
Normal file
49
alr_envs/mujoco/gym_table_tennis/envs/assets/shared.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<mujocoinclude>
|
||||||
|
<default>
|
||||||
|
<default class="wam">
|
||||||
|
<joint type="hinge" limited="true" pos="0 0 0" axis="0 0 1"/>
|
||||||
|
</default>
|
||||||
|
<default class="viz">
|
||||||
|
<geom type="mesh" contype="0" conaffinity="0" group="1" rgba="1 1 1 1"/>
|
||||||
|
</default>
|
||||||
|
<default class="col">
|
||||||
|
<geom type="mesh" contype="0" conaffinity="1" group="0" rgba="1 1 1 1"/>
|
||||||
|
</default>
|
||||||
|
<default class="contact_geom">
|
||||||
|
<geom condim="4" friction="0.1 0.1 0.1" margin="0" solimp="1 1 0" solref="0.1 0.03"/>
|
||||||
|
<!-- <geom condim="4" friction="0 0 0" margin="0" solimp="1 1 0" solref="0.01 1.1"/>-->
|
||||||
|
|
||||||
|
</default>
|
||||||
|
</default>
|
||||||
|
<asset>
|
||||||
|
<mesh file="base_link_fine.stl"/>
|
||||||
|
<mesh file="base_link_convex.stl"/>
|
||||||
|
<mesh file="shoulder_link_fine.stl"/>
|
||||||
|
<mesh file="shoulder_link_convex_decomposition_p1.stl"/>
|
||||||
|
<mesh file="shoulder_link_convex_decomposition_p2.stl"/>
|
||||||
|
<mesh file="shoulder_link_convex_decomposition_p3.stl"/>
|
||||||
|
<mesh file="shoulder_pitch_link_fine.stl"/>
|
||||||
|
<mesh file="shoulder_pitch_link_convex.stl"/>
|
||||||
|
<mesh file="upper_arm_link_fine.stl"/>
|
||||||
|
<mesh file="upper_arm_link_convex_decomposition_p1.stl"/>
|
||||||
|
<mesh file="upper_arm_link_convex_decomposition_p2.stl"/>
|
||||||
|
<mesh file="elbow_link_fine.stl"/>
|
||||||
|
<mesh file="elbow_link_convex.stl"/>
|
||||||
|
<mesh file="forearm_link_fine.stl"/>
|
||||||
|
<mesh file="forearm_link_convex_decomposition_p1.stl"/>
|
||||||
|
<mesh file="forearm_link_convex_decomposition_p2.stl"/>
|
||||||
|
<mesh file="wrist_yaw_link_fine.stl"/>
|
||||||
|
<mesh file="wrist_yaw_link_convex_decomposition_p1.stl"/>
|
||||||
|
<mesh file="wrist_yaw_link_convex_decomposition_p2.stl"/>
|
||||||
|
<mesh file="wrist_pitch_link_fine.stl"/>
|
||||||
|
<mesh file="wrist_pitch_link_convex_decomposition_p1.stl"/>
|
||||||
|
<mesh file="wrist_pitch_link_convex_decomposition_p2.stl"/>
|
||||||
|
<mesh file="wrist_pitch_link_convex_decomposition_p3.stl"/>
|
||||||
|
<mesh file="wrist_palm_link_fine.stl"/>
|
||||||
|
<mesh file="wrist_palm_link_convex.stl"/>
|
||||||
|
|
||||||
|
<texture builtin="checker" height="512" name="texplane" rgb1=".2 .3 .4" rgb2=".1 0.15 0.2" type="2d"
|
||||||
|
width="512"/>
|
||||||
|
<material name="floor_plane" reflectance="0.5" texrepeat="1 1" texture="texplane" texuniform="true"/>
|
||||||
|
</asset>
|
||||||
|
</mujocoinclude>
|
@ -0,0 +1,41 @@
|
|||||||
|
<mujoco model="table_tennis(v0.1)">
|
||||||
|
<compiler angle="radian" coordinate="local" meshdir="meshes/" />
|
||||||
|
|
||||||
|
<option gravity="0 0 -9.81" timestep="0.002">
|
||||||
|
<flag warmstart="enable" />
|
||||||
|
</option>
|
||||||
|
|
||||||
|
|
||||||
|
<custom>
|
||||||
|
<numeric data="0 0 0 0 0 0 0" name="START_ANGLES" />
|
||||||
|
</custom>
|
||||||
|
|
||||||
|
|
||||||
|
<include file="shared.xml" />
|
||||||
|
|
||||||
|
<worldbody>
|
||||||
|
<light cutoff="60" diffuse="1 1 1" dir="-.1 -.2 -1.3" directional="true" exponent="1" pos=".1 .2 1.3" specular=".1 .1 .1" />
|
||||||
|
<geom conaffinity="1" contype="1" material="floor_plane" name="floor" pos="0 0 0" size="10 5 1" type="plane" />
|
||||||
|
|
||||||
|
|
||||||
|
<include file="include_table.xml" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<include file="include_barrett_wam_7dof_right.xml" />
|
||||||
|
|
||||||
|
<include file="include_target_ball.xml" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</worldbody>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<include file="right_arm_actuator.xml" />
|
||||||
|
|
||||||
|
|
||||||
|
</mujoco>
|
244
alr_envs/mujoco/gym_table_tennis/envs/table_tennis_env.py
Normal file
244
alr_envs/mujoco/gym_table_tennis/envs/table_tennis_env.py
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
import numpy as np
|
||||||
|
from gym import spaces
|
||||||
|
from gym.envs.robotics import robot_env, utils
|
||||||
|
# import xml.etree.ElementTree as ET
|
||||||
|
from alr_envs.mujoco.gym_table_tennis.utils.rewards.hierarchical_reward import HierarchicalRewardTableTennis
|
||||||
|
import glfw
|
||||||
|
from alr_envs.mujoco.gym_table_tennis.utils.experiment import ball_initialize
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class TableTennisEnv(robot_env.RobotEnv):
|
||||||
|
"""Class for Table Tennis environment.
|
||||||
|
"""
|
||||||
|
def __init__(self, n_substeps=1,
|
||||||
|
model_path=None,
|
||||||
|
initial_qpos=None,
|
||||||
|
initial_ball_state=None,
|
||||||
|
config=None,
|
||||||
|
reward_obj=None
|
||||||
|
):
|
||||||
|
"""Initializes a new mujoco based Table Tennis environment.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
model_path (string): path to the environments XML file
|
||||||
|
initial_qpos (dict): a dictionary of joint names and values that define the initial
|
||||||
|
n_actions: Number of joints
|
||||||
|
n_substeps (int): number of substeps the simulation runs on every call to step
|
||||||
|
scale (double): limit maximum change in position
|
||||||
|
initial_ball_state: to reset the ball state
|
||||||
|
"""
|
||||||
|
# self.config = config.config
|
||||||
|
if model_path is None:
|
||||||
|
path_cws = Path.cwd()
|
||||||
|
print(path_cws)
|
||||||
|
current_dir = Path(os.path.split(os.path.realpath(__file__))[0])
|
||||||
|
table_tennis_env_xml_path = current_dir / "assets"/"table_tennis_env.xml"
|
||||||
|
model_path = str(table_tennis_env_xml_path)
|
||||||
|
self.config = config
|
||||||
|
action_space = True # self.config['trajectory']['args']['action_space']
|
||||||
|
time_step = 0.002 # self.config['mujoco_sim_env']['args']["time_step"]
|
||||||
|
if initial_qpos is None:
|
||||||
|
initial_qpos = {"wam/base_yaw_joint_right": 1.5,
|
||||||
|
"wam/shoulder_pitch_joint_right": 1,
|
||||||
|
"wam/shoulder_yaw_joint_right": 0,
|
||||||
|
"wam/elbow_pitch_joint_right": 1,
|
||||||
|
"wam/wrist_yaw_joint_right": 1,
|
||||||
|
"wam/wrist_pitch_joint_right": 0,
|
||||||
|
"wam/palm_yaw_joint_right": 0}
|
||||||
|
# initial_qpos = [1.5, 1, 0, 1, 1, 0, 0] # self.config['robot_config']['args']['initial_qpos']
|
||||||
|
|
||||||
|
# TODO should read all configuration in config
|
||||||
|
assert initial_qpos is not None, "Must initialize the initial q position of robot arm"
|
||||||
|
n_actions = 7
|
||||||
|
self.initial_qpos_value = np.array(list(initial_qpos.values())).copy()
|
||||||
|
# self.initial_qpos_value = np.array(initial_qpos)
|
||||||
|
# # change time step in .xml file
|
||||||
|
# tree = ET.parse(model_path)
|
||||||
|
# root = tree.getroot()
|
||||||
|
# for option in root.findall('option'):
|
||||||
|
# option.set("timestep", str(time_step))
|
||||||
|
#
|
||||||
|
# tree.write(model_path)
|
||||||
|
|
||||||
|
super(TableTennisEnv, self).__init__(
|
||||||
|
model_path=model_path, n_substeps=n_substeps, n_actions=n_actions,
|
||||||
|
initial_qpos=initial_qpos)
|
||||||
|
|
||||||
|
if action_space:
|
||||||
|
self.action_space = spaces.Box(low=np.array([-2.6, -2.0, -2.8, -0.9, -4.8, -1.6, -2.2]),
|
||||||
|
high=np.array([2.6, 2.0, 2.8, 3.1, 1.3, 1.6, 2.2]),
|
||||||
|
dtype='float64')
|
||||||
|
else:
|
||||||
|
self.action_space = spaces.Box(low=np.array([-np.inf] * 7),
|
||||||
|
high=np.array([-np.inf] * 7),
|
||||||
|
dtype='float64')
|
||||||
|
self.scale = None
|
||||||
|
self.desired_pos = None
|
||||||
|
self.n_actions = n_actions
|
||||||
|
self.action = None
|
||||||
|
self.time_step = time_step
|
||||||
|
self._dt = time_step
|
||||||
|
self.paddle_center_pos = self.sim.data.get_site_xpos('wam/paddle_center')
|
||||||
|
if reward_obj is None:
|
||||||
|
self.reward_obj = HierarchicalRewardTableTennis()
|
||||||
|
else:
|
||||||
|
self.reward_obj = reward_obj
|
||||||
|
|
||||||
|
if initial_ball_state is not None:
|
||||||
|
self.initial_ball_state = initial_ball_state
|
||||||
|
else:
|
||||||
|
self.initial_ball_state = ball_initialize(random=False)
|
||||||
|
self.target_ball_pos = self.sim.data.get_site_xpos("target_ball")
|
||||||
|
self.racket_center_pos = self.sim.data.get_site_xpos("wam/paddle_center")
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.viewer is not None:
|
||||||
|
glfw.destroy_window(self.viewer.window)
|
||||||
|
# self.viewer.window.close()
|
||||||
|
self.viewer = None
|
||||||
|
self._viewers = {}
|
||||||
|
|
||||||
|
# GoalEnv methods
|
||||||
|
# ----------------------------
|
||||||
|
def compute_reward(self, achieved_goal, goal, info):
|
||||||
|
# reset the reward, if action valid
|
||||||
|
# right_court_contact_obj = ["target_ball", "table_tennis_table_right_side"]
|
||||||
|
# right_court_contact_detector = self.reward_obj.contact_detection(self, right_court_contact_obj)
|
||||||
|
# if right_court_contact_detector:
|
||||||
|
# print("can detect the table ball contact")
|
||||||
|
self.reward_obj.total_reward = 0
|
||||||
|
# Stage 1 Hitting
|
||||||
|
self.reward_obj.hitting(self)
|
||||||
|
# if not hitted, return the highest reward
|
||||||
|
if not self.reward_obj.goal_achievement:
|
||||||
|
# return self.reward_obj.highest_reward
|
||||||
|
return self.reward_obj.total_reward
|
||||||
|
# # Stage 2 Right Table Contact
|
||||||
|
# self.reward_obj.right_table_contact(self)
|
||||||
|
# if not self.reward_obj.goal_achievement:
|
||||||
|
# return self.reward_obj.highest_reward
|
||||||
|
# # Stage 2 Net Contact
|
||||||
|
# self.reward_obj.net_contact(self)
|
||||||
|
# if not self.reward_obj.goal_achievement:
|
||||||
|
# return self.reward_obj.highest_reward
|
||||||
|
# Stage 3 Opponent court Contact
|
||||||
|
# self.reward_obj.landing_on_opponent_court(self)
|
||||||
|
# if not self.reward_obj.goal_achievement:
|
||||||
|
# print("self.reward_obj.highest_reward: ", self.reward_obj.highest_reward)
|
||||||
|
# TODO
|
||||||
|
self.reward_obj.target_achievement(self)
|
||||||
|
# return self.reward_obj.highest_reward
|
||||||
|
return self.reward_obj.total_reward
|
||||||
|
|
||||||
|
def _reset_sim(self):
|
||||||
|
self.sim.set_state(self.initial_state)
|
||||||
|
[initial_x, initial_y, initial_z, v_x, v_y, v_z] = self.initial_ball_state
|
||||||
|
self.sim.data.set_joint_qpos('tar:x', initial_x)
|
||||||
|
self.sim.data.set_joint_qpos('tar:y', initial_y)
|
||||||
|
self.sim.data.set_joint_qpos('tar:z', initial_z)
|
||||||
|
self.energy_corrected = True
|
||||||
|
self.give_reflection_reward = False
|
||||||
|
|
||||||
|
# velocity is positive direction
|
||||||
|
self.sim.data.set_joint_qvel('tar:x', v_x)
|
||||||
|
self.sim.data.set_joint_qvel('tar:y', v_y)
|
||||||
|
self.sim.data.set_joint_qvel('tar:z', v_z)
|
||||||
|
|
||||||
|
# Apply gravity compensation
|
||||||
|
if self.sim.data.qfrc_applied[:7] is not self.sim.data.qfrc_bias[:7]:
|
||||||
|
self.sim.data.qfrc_applied[:7] = self.sim.data.qfrc_bias[:7]
|
||||||
|
self.sim.forward()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _env_setup(self, initial_qpos):
|
||||||
|
for name, value in initial_qpos.items():
|
||||||
|
self.sim.data.set_joint_qpos(name, value)
|
||||||
|
|
||||||
|
# Apply gravity compensation
|
||||||
|
if self.sim.data.qfrc_applied[:7] is not self.sim.data.qfrc_bias[:7]:
|
||||||
|
self.sim.data.qfrc_applied[:7] = self.sim.data.qfrc_bias[:7]
|
||||||
|
self.sim.forward()
|
||||||
|
|
||||||
|
# Get the target position
|
||||||
|
self.initial_paddle_center_xpos = self.sim.data.get_site_xpos('wam/paddle_center').copy()
|
||||||
|
self.initial_paddle_center_vel = None # self.sim.get_site_
|
||||||
|
|
||||||
|
def _sample_goal(self):
|
||||||
|
goal = self.initial_paddle_center_xpos[:3] + self.np_random.uniform(-0.2, 0.2, size=3)
|
||||||
|
return goal.copy()
|
||||||
|
|
||||||
|
def _get_obs(self):
|
||||||
|
|
||||||
|
# positions of racket center
|
||||||
|
paddle_center_pos = self.sim.data.get_site_xpos('wam/paddle_center')
|
||||||
|
ball_pos = self.sim.data.get_site_xpos("target_ball")
|
||||||
|
|
||||||
|
dt = self.sim.nsubsteps * self.sim.model.opt.timestep
|
||||||
|
paddle_center_velp = self.sim.data.get_site_xvelp('wam/paddle_center') * dt
|
||||||
|
robot_qpos, robot_qvel = utils.robot_get_obs(self.sim)
|
||||||
|
|
||||||
|
wrist_state = robot_qpos[-3:]
|
||||||
|
wrist_vel = robot_qvel[-3:] * dt # change to a scalar if the gripper is made symmetric
|
||||||
|
|
||||||
|
# achieved_goal = paddle_body_EE_pos
|
||||||
|
obs = np.concatenate([
|
||||||
|
paddle_center_pos, paddle_center_velp, wrist_state, wrist_vel
|
||||||
|
])
|
||||||
|
|
||||||
|
out_dict = {
|
||||||
|
'observation': obs.copy(),
|
||||||
|
'achieved_goal': paddle_center_pos.copy(),
|
||||||
|
'desired_goal': self.goal.copy(),
|
||||||
|
'q_pos': self.sim.data.qpos[:].copy(),
|
||||||
|
"ball_pos": ball_pos.copy(),
|
||||||
|
# "hitting_flag": self.reward_obj.hitting_flag
|
||||||
|
}
|
||||||
|
|
||||||
|
return out_dict
|
||||||
|
|
||||||
|
def _step_callback(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _set_action(self, action):
|
||||||
|
# Apply gravity compensation
|
||||||
|
if self.sim.data.qfrc_applied[:7] is not self.sim.data.qfrc_bias[:7]:
|
||||||
|
self.sim.data.qfrc_applied[:7] = self.sim.data.qfrc_bias[:7]
|
||||||
|
# print("set action process running")
|
||||||
|
assert action.shape == (self.n_actions,)
|
||||||
|
self.action = action.copy() # ensure that we don't change the action outside of this scope
|
||||||
|
pos_ctrl = self.action[:] # limit maximum change in position
|
||||||
|
pos_ctrl = np.clip(pos_ctrl, self.action_space.low, self.action_space.high)
|
||||||
|
|
||||||
|
# get desired trajectory
|
||||||
|
self.sim.data.qpos[:7] = pos_ctrl
|
||||||
|
self.sim.forward()
|
||||||
|
self.desired_pos = self.sim.data.get_site_xpos('wam/paddle_center').copy()
|
||||||
|
|
||||||
|
self.sim.data.ctrl[:] = pos_ctrl
|
||||||
|
|
||||||
|
def _is_success(self, achieved_goal, desired_goal):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
render_mode = "human" # "human" or "partial" or "final"
|
||||||
|
env = TableTennisEnv()
|
||||||
|
env.reset()
|
||||||
|
# env.render(mode=render_mode)
|
||||||
|
|
||||||
|
for i in range(500):
|
||||||
|
# objective.load_result("/tmp/cma")
|
||||||
|
# test with random actions
|
||||||
|
ac = env.action_space.sample()
|
||||||
|
# ac[0] += np.pi/2
|
||||||
|
obs, rew, d, info = env.step(ac)
|
||||||
|
env.render(mode=render_mode)
|
||||||
|
|
||||||
|
print(rew)
|
||||||
|
|
||||||
|
if d:
|
||||||
|
break
|
||||||
|
|
||||||
|
env.close()
|
0
alr_envs/mujoco/gym_table_tennis/utils/__init__.py
Normal file
0
alr_envs/mujoco/gym_table_tennis/utils/__init__.py
Normal file
83
alr_envs/mujoco/gym_table_tennis/utils/experiment.py
Normal file
83
alr_envs/mujoco/gym_table_tennis/utils/experiment.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import numpy as np
|
||||||
|
from gym.utils import seeding
|
||||||
|
from alr_envs.mujoco.gym_table_tennis.utils.util import read_yaml, read_json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def ball_initialize(random=False, scale=False, context_range=None, scale_value=None):
|
||||||
|
if random:
|
||||||
|
if scale:
|
||||||
|
# if scale_value is None:
|
||||||
|
scale_value = context_scale_initialize(context_range)
|
||||||
|
v_x, v_y, v_z = [2.5, 2, 0.5] * scale_value
|
||||||
|
dx = 1
|
||||||
|
dy = 0
|
||||||
|
dz = 0.05
|
||||||
|
else:
|
||||||
|
seed = None
|
||||||
|
np_random, seed = seeding.np_random(seed)
|
||||||
|
dx = np_random.uniform(-0.1, 0.1)
|
||||||
|
dy = np_random.uniform(-0.1, 0.1)
|
||||||
|
dz = np_random.uniform(-0.1, 0.1)
|
||||||
|
|
||||||
|
v_x = np_random.uniform(1.7, 1.8)
|
||||||
|
v_y = np_random.uniform(0.7, 0.8)
|
||||||
|
v_z = np_random.uniform(0.1, 0.2)
|
||||||
|
# print(dx, dy, dz, v_x, v_y, v_z)
|
||||||
|
# else:
|
||||||
|
# dx = -0.1
|
||||||
|
# dy = 0.05
|
||||||
|
# dz = 0.05
|
||||||
|
# v_x = 1.5
|
||||||
|
# v_y = 0.7
|
||||||
|
# v_z = 0.06
|
||||||
|
# initial_x = -0.6 + dx
|
||||||
|
# initial_y = -0.3 + dy
|
||||||
|
# initial_z = 0.8 + dz
|
||||||
|
else:
|
||||||
|
if scale:
|
||||||
|
v_x, v_y, v_z = [2.5, 2, 0.5] * scale_value
|
||||||
|
else:
|
||||||
|
v_x = 2.5
|
||||||
|
v_y = 2
|
||||||
|
v_z = 0.5
|
||||||
|
dx = 1
|
||||||
|
dy = 0
|
||||||
|
dz = 0.05
|
||||||
|
|
||||||
|
initial_x = 0 + dx
|
||||||
|
initial_y = -0.2 + dy
|
||||||
|
initial_z = 0.3 + dz
|
||||||
|
# print("initial ball state: ", initial_x, initial_y, initial_z, v_x, v_y, v_z)
|
||||||
|
initial_ball_state = np.array([initial_x, initial_y, initial_z, v_x, v_y, v_z])
|
||||||
|
return initial_ball_state
|
||||||
|
|
||||||
|
|
||||||
|
def context_scale_initialize(range):
|
||||||
|
"""
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
low, high = range
|
||||||
|
scale = np.random.uniform(low, high, 1)
|
||||||
|
return scale
|
||||||
|
|
||||||
|
|
||||||
|
def config_handle_generation(config_file_path):
|
||||||
|
"""Generate config handle for multiprocessing
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config_file_path:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
cfg_fname = Path(config_file_path)
|
||||||
|
# .json and .yml file
|
||||||
|
if cfg_fname.suffix == ".json":
|
||||||
|
config = read_json(cfg_fname)
|
||||||
|
elif cfg_fname.suffix == ".yml":
|
||||||
|
config = read_yaml(cfg_fname)
|
||||||
|
|
||||||
|
return config
|
@ -0,0 +1,402 @@
|
|||||||
|
import numpy as np
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
class HierarchicalRewardTableTennis(object):
|
||||||
|
"""Class for hierarchical reward function for table tennis experiment.
|
||||||
|
|
||||||
|
Return Highest Reward.
|
||||||
|
Reward = 0
|
||||||
|
Step 1: Action Valid. Upper Bound 0
|
||||||
|
[-∞, 0]
|
||||||
|
Reward += -1 * |hit_duration - hit_duration_threshold| * |hit_duration < hit_duration_threshold| * 10
|
||||||
|
Step 2: Hitting. Upper Bound 2
|
||||||
|
if hitting:
|
||||||
|
[0, 2]
|
||||||
|
Reward = 2 * (1 - tanh(|shortest_hitting_dist|))
|
||||||
|
if not hitting:
|
||||||
|
[0, 0.2]
|
||||||
|
Reward = 2 * (1 - tanh(|shortest_hitting_dist|))
|
||||||
|
Step 3: Target Point Achievement. Upper Bound 6
|
||||||
|
[0, 4]
|
||||||
|
if table_contact_detector:
|
||||||
|
Reward += 1
|
||||||
|
Reward += (1 - tanh(|shortest_hitting_dist|)) * 2
|
||||||
|
if contact_coordinate[0] < 0:
|
||||||
|
Reward += 1
|
||||||
|
else:
|
||||||
|
Reward += 0
|
||||||
|
elif:
|
||||||
|
Reward += (1 - tanh(|shortest_hitting_dist|))
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.reward = None
|
||||||
|
self.goal_achievement = False
|
||||||
|
self.total_reward = 0
|
||||||
|
self.shortest_hitting_dist = 1000
|
||||||
|
self.highest_reward = -1000
|
||||||
|
self.lowest_corner_dist = 100
|
||||||
|
self.right_court_contact_detector = False
|
||||||
|
self.table_contact_detector = False
|
||||||
|
self.floor_contact_detector = False
|
||||||
|
self.radius = 0.025
|
||||||
|
self.min_ball_x_pos = 100
|
||||||
|
self.hit_contact_detector = False
|
||||||
|
self.net_contact_detector = False
|
||||||
|
self.ratio = 1
|
||||||
|
self.lowest_z = 100
|
||||||
|
self.target_flag = False
|
||||||
|
self.dist_target_virtual = 100
|
||||||
|
self.ball_z_pos_lowest = 100
|
||||||
|
self.hitting_flag = False
|
||||||
|
self.hitting_time_point = None
|
||||||
|
self.ctxt_dim = None
|
||||||
|
self.context_range_bounds = None
|
||||||
|
# self.ctxt_out_of_range_punishment = None
|
||||||
|
# self.ctxt_in_side_of_range_punishment = None
|
||||||
|
#
|
||||||
|
# def check_where_invalid(self, ctxt, context_range_bounds, set_to_valid_region=False):
|
||||||
|
# idx_max = []
|
||||||
|
# idx_min = []
|
||||||
|
# for dim in range(self.ctxt_dim):
|
||||||
|
# min_dim = context_range_bounds[0][dim]
|
||||||
|
# max_dim = context_range_bounds[1][dim]
|
||||||
|
# idx_max_c = np.where(ctxt[:, dim] > max_dim)[0]
|
||||||
|
# idx_min_c = np.where(ctxt[:, dim] < min_dim)[0]
|
||||||
|
# if set_to_valid_region:
|
||||||
|
# if idx_max_c.shape[0] != 0:
|
||||||
|
# ctxt[idx_max_c, dim] = max_dim
|
||||||
|
# if idx_min_c.shape[0] != 0:
|
||||||
|
# ctxt[idx_min_c, dim] = min_dim
|
||||||
|
# idx_max.append(idx_max_c)
|
||||||
|
# idx_min.append(idx_min_c)
|
||||||
|
# return idx_max, idx_min, ctxt
|
||||||
|
|
||||||
|
def check_valid(self, scale, context_range_bounds):
|
||||||
|
|
||||||
|
min_dim = context_range_bounds[0][0]
|
||||||
|
max_dim = context_range_bounds[1][0]
|
||||||
|
valid = (scale < max_dim) and (scale > min_dim)
|
||||||
|
return valid
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def goal_distance(cls, goal_a, goal_b):
|
||||||
|
assert goal_a.shape == goal_b.shape
|
||||||
|
return np.linalg.norm(goal_a - goal_b, axis=-1)
|
||||||
|
|
||||||
|
def refresh_highest_reward(self):
|
||||||
|
if self.total_reward >= self.highest_reward:
|
||||||
|
self.highest_reward = self.total_reward
|
||||||
|
|
||||||
|
def duration_valid(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def huge_value_unstable(self):
|
||||||
|
self.total_reward += -10
|
||||||
|
self.highest_reward = -1
|
||||||
|
|
||||||
|
def context_valid(self, context):
|
||||||
|
valid = self.check_valid(context.copy(), context_range_bounds=self.context_range_bounds)
|
||||||
|
# when using dirac punishments
|
||||||
|
if valid:
|
||||||
|
self.total_reward += 1 # If Action Valid and Context Valid, total_reward = 0
|
||||||
|
else:
|
||||||
|
self.total_reward += 0
|
||||||
|
self.refresh_highest_reward()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# If in the ctxt, add 1, otherwise, 0
|
||||||
|
|
||||||
|
def action_valid(self, durations=None):
|
||||||
|
"""Ensure the execution of the robot movement with parameters which are in a valid domain.
|
||||||
|
|
||||||
|
Time should always be positive,
|
||||||
|
the joint position of the robot should be a subset of [−π, π].
|
||||||
|
if all parameters are valid, the robot gets a zero score,
|
||||||
|
otherwise it gets a negative score proportional to how much it is beyond the valid parameter domain.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
rewards: if valid, reward is equal to 0.
|
||||||
|
if not valid, reward is negative and proportional to the distance beyond the valid parameter domain
|
||||||
|
"""
|
||||||
|
assert durations.shape[0] == 2, "durations type should be np.array and the shape should be 2"
|
||||||
|
# pre_duration = durations[0]
|
||||||
|
hit_duration = durations[1]
|
||||||
|
# pre_duration_thres = 0.01
|
||||||
|
hit_duration_thres = 1
|
||||||
|
# self.goal_achievement = np.all(
|
||||||
|
# [(pre_duration > pre_duration_thres), (hit_duration > hit_duration_thres), (0.3 < pre_duration < 0.6)])
|
||||||
|
self.goal_achievement = (hit_duration > hit_duration_thres)
|
||||||
|
if self.goal_achievement:
|
||||||
|
self.total_reward = -1
|
||||||
|
self.goal_achievement = True
|
||||||
|
else:
|
||||||
|
# self.total_reward += -1 * ((np.abs(pre_duration - pre_duration_thres) * int(
|
||||||
|
# pre_duration < pre_duration_thres) + np.abs(hit_duration - hit_duration_thres) * int(
|
||||||
|
# hit_duration < hit_duration_thres)) * 10)
|
||||||
|
self.total_reward = -1 * ((np.abs(hit_duration - hit_duration_thres) * int(
|
||||||
|
hit_duration < hit_duration_thres)) * 10)
|
||||||
|
self.total_reward += -1
|
||||||
|
self.goal_achievement = False
|
||||||
|
self.refresh_highest_reward()
|
||||||
|
|
||||||
|
def motion_penalty(self, action, high_motion_penalty):
|
||||||
|
"""Protects the robot from high acceleration and dangerous movement.
|
||||||
|
"""
|
||||||
|
if not high_motion_penalty:
|
||||||
|
reward_ctrl = - 0.05 * np.square(action).sum()
|
||||||
|
else:
|
||||||
|
reward_ctrl = - 0.075 * np.square(action).sum()
|
||||||
|
self.total_reward += reward_ctrl
|
||||||
|
self.refresh_highest_reward()
|
||||||
|
self.goal_achievement = True
|
||||||
|
|
||||||
|
def hitting(self, env): # , target_ball_pos, racket_center_pos, hit_contact_detector=False
|
||||||
|
"""Hitting reward calculation
|
||||||
|
|
||||||
|
If racket successfully hit the ball, the reward +1
|
||||||
|
Otherwise calculate the distance between the center of racket and the center of ball,
|
||||||
|
reward = tanh(r/dist) if dist<1 reward almost 2 , if dist >= 1 reward is between [0, 0.2]
|
||||||
|
|
||||||
|
|
||||||
|
Args:
|
||||||
|
env:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
hit_contact_obj = ["target_ball", "bat"]
|
||||||
|
target_ball_pos = env.target_ball_pos
|
||||||
|
racket_center_pos = env.racket_center_pos
|
||||||
|
# hit contact detection
|
||||||
|
# Record the hitting history
|
||||||
|
self.hitting_flag = False
|
||||||
|
if not self.hit_contact_detector:
|
||||||
|
self.hit_contact_detector = self.contact_detection(env, hit_contact_obj)
|
||||||
|
if self.hit_contact_detector:
|
||||||
|
print("First time detect hitting")
|
||||||
|
self.hitting_flag = True
|
||||||
|
if self.hit_contact_detector:
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
dist = self.goal_distance(target_ball_pos, racket_center_pos)
|
||||||
|
if dist < 0:
|
||||||
|
dist = 0
|
||||||
|
# print("goal distance is:", dist)
|
||||||
|
if dist <= self.shortest_hitting_dist:
|
||||||
|
self.shortest_hitting_dist = dist
|
||||||
|
# print("shortest_hitting_dist is:", self.shortest_hitting_dist)
|
||||||
|
# Keep the shortest hitting distance.
|
||||||
|
dist_reward = 2 * (1 - np.tanh(np.abs(self.shortest_hitting_dist)))
|
||||||
|
|
||||||
|
# TODO sparse
|
||||||
|
# dist_reward = 2
|
||||||
|
|
||||||
|
self.total_reward += dist_reward
|
||||||
|
self.goal_achievement = True
|
||||||
|
|
||||||
|
# if self.hitting_time_point is not None and self.hitting_time_point > 600:
|
||||||
|
# self.total_reward += 1
|
||||||
|
|
||||||
|
else:
|
||||||
|
dist = self.goal_distance(target_ball_pos, racket_center_pos)
|
||||||
|
if dist <= self.shortest_hitting_dist:
|
||||||
|
self.shortest_hitting_dist = dist
|
||||||
|
dist_reward = 1 - np.tanh(self.shortest_hitting_dist)
|
||||||
|
reward = 0.2 * dist_reward # because it does not hit the ball, so multiply 0.2
|
||||||
|
self.total_reward += reward
|
||||||
|
self.goal_achievement = False
|
||||||
|
|
||||||
|
self.refresh_highest_reward()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def relu(cls, x):
|
||||||
|
return np.maximum(0, x)
|
||||||
|
|
||||||
|
# def right_table_contact(self, env):
|
||||||
|
# right_court_contact_obj = ["target_ball", "table_tennis_table_right_side"]
|
||||||
|
# if env.target_ball_pos[0] >= 0 and env.target_ball_pos[2] >= 0.7:
|
||||||
|
# # update right court contact detection
|
||||||
|
# if not self.right_court_contact_detector:
|
||||||
|
# self.right_court_contact_detector = self.contact_detection(env, right_court_contact_obj)
|
||||||
|
# if self.right_court_contact_detector:
|
||||||
|
# self.contact_x_pos = env.target_ball_pos[0]
|
||||||
|
# if self.right_court_contact_detector:
|
||||||
|
# self.total_reward += 1 - norm(0.685, 1).pdf(self.contact_x_pos) # x axis middle of right table
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# else:
|
||||||
|
# self.total_reward += 1
|
||||||
|
# self.goal_achievement = True
|
||||||
|
# # else:
|
||||||
|
# # self.total_reward += 0
|
||||||
|
# # self.goal_achievement = False
|
||||||
|
# self.refresh_highest_reward()
|
||||||
|
|
||||||
|
# def net_contact(self, env):
|
||||||
|
# net_contact_obj = ["target_ball", "table_tennis_net"]
|
||||||
|
# # net_contact_detector = self.contact_detection(env, net_contact_obj)
|
||||||
|
# # ball_x_pos = env.target_ball_pos[0]
|
||||||
|
# # if self.min_ball_x_pos >= ball_x_pos:
|
||||||
|
# # self.min_ball_x_pos = ball_x_pos
|
||||||
|
# # table_left_edge_x_pos = -1.37
|
||||||
|
# # if np.abs(ball_x_pos) <= 0.01: # x threshold of net
|
||||||
|
# # if self.lowest_z >= env.target_ball_pos[2]:
|
||||||
|
# # self.lowest_z = env.target_ball_pos[2]
|
||||||
|
# # # construct a gaussian distribution of z
|
||||||
|
# # z_reward = 4 - norm(0, 0.1).pdf(self.lowest_z - 0.07625) # maximum 4
|
||||||
|
# # self.total_reward += z_reward
|
||||||
|
# # self.total_reward += 2 - np.minimum(1, self.relu(np.abs(self.min_ball_x_pos)))
|
||||||
|
# if not self.net_contact_detector:
|
||||||
|
# self.net_contact_detector = self.contact_detection(env, net_contact_obj)
|
||||||
|
# if self.net_contact_detector:
|
||||||
|
# self.total_reward += 0 # very high cost
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# else:
|
||||||
|
# self.total_reward += 1
|
||||||
|
# self.goal_achievement = True
|
||||||
|
# self.refresh_highest_reward()
|
||||||
|
|
||||||
|
# def landing_on_opponent_court(self, env):
|
||||||
|
# # Very sparse reward
|
||||||
|
# # don't contact the right side court
|
||||||
|
# # right_court_contact_obj = ["target_ball", "table_tennis_table_right_side"]
|
||||||
|
# # right_court_contact_detector = self.contact_detection(env, right_court_contact_obj)
|
||||||
|
# left_court_contact_obj = ["target_ball", "table_tennis_table_left_side"]
|
||||||
|
# # left_court_contact_detector = self.contact_detection(env, left_court_contact_obj)
|
||||||
|
# # record the contact history
|
||||||
|
# # if not self.right_court_contact_detector:
|
||||||
|
# # self.right_court_contact_detector = self.contact_detection(env, right_court_contact_obj)
|
||||||
|
# if not self.table_contact_detector:
|
||||||
|
# self.table_contact_detector = self.contact_detection(env, left_court_contact_obj)
|
||||||
|
#
|
||||||
|
# dist_left_up_corner = self.goal_distance(env.target_ball_pos, env.sim.data.get_site_xpos("left_up_corner"))
|
||||||
|
# dist_middle_up_corner = self.goal_distance(env.target_ball_pos, env.sim.data.get_site_xpos("middle_up_corner"))
|
||||||
|
# dist_left_down_corner = self.goal_distance(env.target_ball_pos, env.sim.data.get_site_xpos("left_down_corner"))
|
||||||
|
# dist_middle_down_corner = self.goal_distance(env.target_ball_pos,
|
||||||
|
# env.sim.data.get_site_xpos("middle_down_corner"))
|
||||||
|
# dist_array = np.array(
|
||||||
|
# [dist_left_up_corner, dist_middle_up_corner, dist_left_down_corner, dist_middle_down_corner])
|
||||||
|
# dist_corner = np.amin(dist_array)
|
||||||
|
# if self.lowest_corner_dist >= dist_corner:
|
||||||
|
# self.lowest_corner_dist = dist_corner
|
||||||
|
#
|
||||||
|
# right_contact_cost = 1
|
||||||
|
# left_contact_reward = 2
|
||||||
|
# dist_left_table_reward = (2 - np.tanh(self.lowest_corner_dist))
|
||||||
|
# # TODO Try multi dimensional gaussian distribution
|
||||||
|
# # contact only the left side court
|
||||||
|
# if self.right_court_contact_detector:
|
||||||
|
# self.total_reward += 0
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# if self.table_contact_detector:
|
||||||
|
# self.total_reward += left_contact_reward
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# else:
|
||||||
|
# self.total_reward += dist_left_table_reward
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# else:
|
||||||
|
# self.total_reward += right_contact_cost
|
||||||
|
# if self.table_contact_detector:
|
||||||
|
# self.total_reward += left_contact_reward
|
||||||
|
# self.goal_achievement = True
|
||||||
|
# else:
|
||||||
|
# self.total_reward += dist_left_table_reward
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# self.refresh_highest_reward()
|
||||||
|
# # if self.left_court_contact_detector and not self.right_court_contact_detector:
|
||||||
|
# # self.total_reward += self.ratio * left_contact_reward
|
||||||
|
# # print("only left court reward return!!!!!!!!!")
|
||||||
|
# # print("contact only left court!!!!!!")
|
||||||
|
# # self.goal_achievement = True
|
||||||
|
# # # no contact with table
|
||||||
|
# # elif not self.right_court_contact_detector and not self.left_court_contact_detector:
|
||||||
|
# # self.total_reward += 0 + self.ratio * dist_left_table_reward
|
||||||
|
# # self.goal_achievement = False
|
||||||
|
# # # contact both side
|
||||||
|
# # elif self.right_court_contact_detector and self.left_court_contact_detector:
|
||||||
|
# # self.total_reward += self.ratio * (left_contact_reward - right_contact_cost) # cost of contact of right court
|
||||||
|
# # self.goal_achievement = False
|
||||||
|
# # # contact only the right side court
|
||||||
|
# # elif self.right_court_contact_detector and not self.left_court_contact_detector:
|
||||||
|
# # self.total_reward += 0 + self.ratio * (
|
||||||
|
# # dist_left_table_reward - right_contact_cost) # cost of contact of right court
|
||||||
|
# # self.goal_achievement = False
|
||||||
|
|
||||||
|
def target_achievement(self, env):
|
||||||
|
target_coordinate = np.array([-0.5, -0.5])
|
||||||
|
# net_contact_obj = ["target_ball", "table_tennis_net"]
|
||||||
|
table_contact_obj = ["target_ball", "table_tennis_table"]
|
||||||
|
floor_contact_obj = ["target_ball", "floor"]
|
||||||
|
|
||||||
|
if 0.78 < env.target_ball_pos[2] < 0.8:
|
||||||
|
dist_target_virtual = np.linalg.norm(env.target_ball_pos[:2] - target_coordinate)
|
||||||
|
if self.dist_target_virtual > dist_target_virtual:
|
||||||
|
self.dist_target_virtual = dist_target_virtual
|
||||||
|
if -0.07 < env.target_ball_pos[0] < 0.07 and env.sim.data.get_joint_qvel('tar:x') < 0:
|
||||||
|
if self.ball_z_pos_lowest > env.target_ball_pos[2]:
|
||||||
|
self.ball_z_pos_lowest = env.target_ball_pos[2].copy()
|
||||||
|
# if not self.net_contact_detector:
|
||||||
|
# self.net_contact_detector = self.contact_detection(env, net_contact_obj)
|
||||||
|
if not self.table_contact_detector:
|
||||||
|
self.table_contact_detector = self.contact_detection(env, table_contact_obj)
|
||||||
|
if not self.floor_contact_detector:
|
||||||
|
self.floor_contact_detector = self.contact_detection(env, floor_contact_obj)
|
||||||
|
if not self.target_flag:
|
||||||
|
# Table Contact Reward.
|
||||||
|
if self.table_contact_detector:
|
||||||
|
self.total_reward += 1
|
||||||
|
# only update when the first contact because of the flag
|
||||||
|
contact_coordinate = env.target_ball_pos[:2].copy()
|
||||||
|
print("contact table ball coordinate: ", env.target_ball_pos)
|
||||||
|
logging.info("contact table ball coordinate: {}".format(env.target_ball_pos))
|
||||||
|
dist_target = np.linalg.norm(contact_coordinate - target_coordinate)
|
||||||
|
self.total_reward += (1 - np.tanh(dist_target)) * 2
|
||||||
|
self.target_flag = True
|
||||||
|
# Net Contact Reward. Precondition: Table Contact exits.
|
||||||
|
if contact_coordinate[0] < 0:
|
||||||
|
print("left table contact")
|
||||||
|
logging.info("~~~~~~~~~~~~~~~left table contact~~~~~~~~~~~~~~~")
|
||||||
|
self.total_reward += 1
|
||||||
|
# TODO Z coordinate reward
|
||||||
|
# self.total_reward += np.maximum(np.tanh(self.ball_z_pos_lowest), 0)
|
||||||
|
self.goal_achievement = True
|
||||||
|
else:
|
||||||
|
print("right table contact")
|
||||||
|
logging.info("~~~~~~~~~~~~~~~right table contact~~~~~~~~~~~~~~~")
|
||||||
|
self.total_reward += 0
|
||||||
|
self.goal_achievement = False
|
||||||
|
# if self.net_contact_detector:
|
||||||
|
# self.total_reward += 0
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# else:
|
||||||
|
# self.total_reward += 1
|
||||||
|
# self.goal_achievement = False
|
||||||
|
# Floor Contact Reward. Precondition: Table Contact exits.
|
||||||
|
elif self.floor_contact_detector:
|
||||||
|
self.total_reward += (1 - np.tanh(self.dist_target_virtual))
|
||||||
|
self.target_flag = True
|
||||||
|
self.goal_achievement = False
|
||||||
|
# No Contact of Floor or Table, flying
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
# else:
|
||||||
|
# print("Flag is True already")
|
||||||
|
self.refresh_highest_reward()
|
||||||
|
|
||||||
|
def distance_to_target(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def contact_detection(cls, env, goal_contact):
|
||||||
|
for i in range(env.sim.data.ncon):
|
||||||
|
contact = env.sim.data.contact[i]
|
||||||
|
achieved_geom1_name = env.sim.model.geom_id2name(contact.geom1)
|
||||||
|
achieved_geom2_name = env.sim.model.geom_id2name(contact.geom2)
|
||||||
|
if np.all([(achieved_geom1_name in goal_contact), (achieved_geom2_name in goal_contact)]):
|
||||||
|
print("contact of " + achieved_geom1_name + " " + achieved_geom2_name)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
136
alr_envs/mujoco/gym_table_tennis/utils/rewards/rewards.py
Normal file
136
alr_envs/mujoco/gym_table_tennis/utils/rewards/rewards.py
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
# Copyright 2017 The dm_control Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
# """Soft indicator function evaluating whether a number is within bounds."""
|
||||||
|
#
|
||||||
|
# from __future__ import absolute_import
|
||||||
|
# from __future__ import division
|
||||||
|
# from __future__ import print_function
|
||||||
|
|
||||||
|
# Internal dependencies.
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# The value returned by tolerance() at `margin` distance from `bounds` interval.
|
||||||
|
_DEFAULT_VALUE_AT_MARGIN = 0.1
|
||||||
|
|
||||||
|
|
||||||
|
def _sigmoids(x, value_at_1, sigmoid):
|
||||||
|
"""Returns 1 when `x` == 0, between 0 and 1 otherwise.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
x: A scalar or numpy array.
|
||||||
|
value_at_1: A float between 0 and 1 specifying the output when `x` == 1.
|
||||||
|
sigmoid: String, choice of sigmoid type.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A numpy array with values between 0.0 and 1.0.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: If not 0 < `value_at_1` < 1, except for `linear`, `cosine` and
|
||||||
|
`quadratic` sigmoids which allow `value_at_1` == 0.
|
||||||
|
ValueError: If `sigmoid` is of an unknown type.
|
||||||
|
"""
|
||||||
|
if sigmoid in ('cosine', 'linear', 'quadratic'):
|
||||||
|
if not 0 <= value_at_1 < 1:
|
||||||
|
raise ValueError('`value_at_1` must be nonnegative and smaller than 1, '
|
||||||
|
'got {}.'.format(value_at_1))
|
||||||
|
else:
|
||||||
|
if not 0 < value_at_1 < 1:
|
||||||
|
raise ValueError('`value_at_1` must be strictly between 0 and 1, '
|
||||||
|
'got {}.'.format(value_at_1))
|
||||||
|
|
||||||
|
if sigmoid == 'gaussian':
|
||||||
|
scale = np.sqrt(-2 * np.log(value_at_1))
|
||||||
|
return np.exp(-0.5 * (x*scale)**2)
|
||||||
|
|
||||||
|
elif sigmoid == 'hyperbolic':
|
||||||
|
scale = np.arccosh(1/value_at_1)
|
||||||
|
return 1 / np.cosh(x*scale)
|
||||||
|
|
||||||
|
elif sigmoid == 'long_tail':
|
||||||
|
scale = np.sqrt(1/value_at_1 - 1)
|
||||||
|
return 1 / ((x*scale)**2 + 1)
|
||||||
|
|
||||||
|
elif sigmoid == 'cosine':
|
||||||
|
scale = np.arccos(2*value_at_1 - 1) / np.pi
|
||||||
|
scaled_x = x*scale
|
||||||
|
return np.where(abs(scaled_x) < 1, (1 + np.cos(np.pi*scaled_x))/2, 0.0)
|
||||||
|
|
||||||
|
elif sigmoid == 'linear':
|
||||||
|
scale = 1-value_at_1
|
||||||
|
scaled_x = x*scale
|
||||||
|
return np.where(abs(scaled_x) < 1, 1 - scaled_x, 0.0)
|
||||||
|
|
||||||
|
elif sigmoid == 'quadratic':
|
||||||
|
scale = np.sqrt(1-value_at_1)
|
||||||
|
scaled_x = x*scale
|
||||||
|
return np.where(abs(scaled_x) < 1, 1 - scaled_x**2, 0.0)
|
||||||
|
|
||||||
|
elif sigmoid == 'tanh_squared':
|
||||||
|
scale = np.arctanh(np.sqrt(1-value_at_1))
|
||||||
|
return 1 - np.tanh(x*scale)**2
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise ValueError('Unknown sigmoid type {!r}.'.format(sigmoid))
|
||||||
|
|
||||||
|
|
||||||
|
def tolerance(x, bounds=(0.0, 0.0), margin=0.0, sigmoid='gaussian',
|
||||||
|
value_at_margin=_DEFAULT_VALUE_AT_MARGIN):
|
||||||
|
"""Returns 1 when `x` falls inside the bounds, between 0 and 1 otherwise.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
x: A scalar or numpy array.
|
||||||
|
bounds: A tuple of floats specifying inclusive `(lower, upper)` bounds for
|
||||||
|
the target interval. These can be infinite if the interval is unbounded
|
||||||
|
at one or both ends, or they can be equal to one another if the target
|
||||||
|
value is exact.
|
||||||
|
margin: Float. Parameter that controls how steeply the output decreases as
|
||||||
|
`x` moves out-of-bounds.
|
||||||
|
* If `margin == 0` then the output will be 0 for all values of `x`
|
||||||
|
outside of `bounds`.
|
||||||
|
* If `margin > 0` then the output will decrease sigmoidally with
|
||||||
|
increasing distance from the nearest bound.
|
||||||
|
sigmoid: String, choice of sigmoid type. Valid values are: 'gaussian',
|
||||||
|
'linear', 'hyperbolic', 'long_tail', 'cosine', 'tanh_squared'.
|
||||||
|
value_at_margin: A float between 0 and 1 specifying the output value when
|
||||||
|
the distance from `x` to the nearest bound is equal to `margin`. Ignored
|
||||||
|
if `margin == 0`.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A float or numpy array with values between 0.0 and 1.0.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: If `bounds[0] > bounds[1]`.
|
||||||
|
ValueError: If `margin` is negative.
|
||||||
|
"""
|
||||||
|
lower, upper = bounds
|
||||||
|
if lower > upper:
|
||||||
|
raise ValueError('Lower bound must be <= upper bound.')
|
||||||
|
if margin < 0:
|
||||||
|
raise ValueError('`margin` must be non-negative.')
|
||||||
|
|
||||||
|
in_bounds = np.logical_and(lower <= x, x <= upper)
|
||||||
|
if margin == 0:
|
||||||
|
value = np.where(in_bounds, 1.0, 0.0)
|
||||||
|
else:
|
||||||
|
d = np.where(x < lower, lower - x, x - upper) / margin
|
||||||
|
value = np.where(in_bounds, 1.0, _sigmoids(d, value_at_margin, sigmoid))
|
||||||
|
|
||||||
|
return float(value) if np.isscalar(x) else value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
49
alr_envs/mujoco/gym_table_tennis/utils/util.py
Normal file
49
alr_envs/mujoco/gym_table_tennis/utils/util.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import json
|
||||||
|
import yaml
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
from collections import OrderedDict
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def read_json(fname):
|
||||||
|
fname = Path(fname)
|
||||||
|
with fname.open('rt') as handle:
|
||||||
|
return json.load(handle, object_hook=OrderedDict)
|
||||||
|
|
||||||
|
|
||||||
|
def write_json(content, fname):
|
||||||
|
fname = Path(fname)
|
||||||
|
with fname.open('wt') as handle:
|
||||||
|
json.dump(content, handle, indent=4, sort_keys=False)
|
||||||
|
|
||||||
|
|
||||||
|
def read_yaml(fname):
|
||||||
|
fname = Path(fname)
|
||||||
|
with fname.open('rt') as handle:
|
||||||
|
return yaml.load(handle, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
|
||||||
|
def write_yaml(content, fname):
|
||||||
|
fname = Path(fname)
|
||||||
|
with fname.open('wt') as handle:
|
||||||
|
yaml.dump(content, handle)
|
||||||
|
|
||||||
|
|
||||||
|
def config_save(dir_path, config):
|
||||||
|
dir_path = Path(dir_path)
|
||||||
|
config_path_json = dir_path / "config.json"
|
||||||
|
config_path_yaml = dir_path / "config.yml"
|
||||||
|
# .json and .yml file,save 2 version of configuration.
|
||||||
|
write_json(config, config_path_json)
|
||||||
|
write_yaml(config, config_path_yaml)
|
||||||
|
|
||||||
|
|
||||||
|
def change_kp_in_xml(kp_list,
|
||||||
|
model_path="/home/zhou/slow/table_tennis_rl/simulation/gymTableTennis/gym_table_tennis/envs/robotics/assets/table_tennis/right_arm_actuator.xml"):
|
||||||
|
tree = ET.parse(model_path)
|
||||||
|
root = tree.getroot()
|
||||||
|
# for actuator in root.find("actuator"):
|
||||||
|
for position, kp in zip(root.iter('position'), kp_list):
|
||||||
|
position.set("kp", str(kp))
|
||||||
|
tree.write(model_path)
|
||||||
|
|
BIN
alr_envs/mujoco/meshes/wam/base_link_convex.stl
Executable file
BIN
alr_envs/mujoco/meshes/wam/base_link_convex.stl
Executable file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/base_link_fine.stl
Executable file
BIN
alr_envs/mujoco/meshes/wam/base_link_fine.stl
Executable file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split1.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split1.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split10.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split10.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split11.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split11.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split12.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split12.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split13.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split13.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split14.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split14.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split15.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split15.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split16.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split16.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split17.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split17.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split18.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split18.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split2.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split2.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split3.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split3.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split4.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split4.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split5.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split5.stl
Normal file
Binary file not shown.
BIN
alr_envs/mujoco/meshes/wam/cup_split6.stl
Normal file
BIN
alr_envs/mujoco/meshes/wam/cup_split6.stl
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user