fancy_gym/alr_envs/envs/mujoco/reacher/mp_wrapper.py

28 lines
888 B
Python
Raw Normal View History

2022-06-30 14:20:52 +02:00
from typing import Union, Tuple
2022-01-25 15:23:57 +01:00
import gym
2022-01-25 15:23:57 +01:00
import numpy as np
2022-06-30 17:33:05 +02:00
from alr_envs.black_box.raw_interface_wrapper import RawInterfaceWrapper
2022-01-25 15:23:57 +01:00
2022-06-30 14:08:54 +02:00
class MPWrapper(RawInterfaceWrapper):
2022-01-25 15:23:57 +01:00
@property
2022-06-30 14:20:52 +02:00
def context_mask(self):
2022-07-13 13:28:39 +02:00
return np.concatenate([[False] * self.n_links, # cos
[False] * self.n_links, # sin
[True] * 2, # goal position
2022-07-13 13:28:39 +02:00
[False] * self.n_links, # angular velocity
[False] * 3, # goal distance
# [False], # step
])
2022-01-25 15:23:57 +01:00
@property
2022-06-30 14:20:52 +02:00
def current_pos(self) -> Union[float, int, np.ndarray, Tuple]:
2022-07-13 13:28:39 +02:00
return self.data.qpos.flat[:self.n_links]
2022-01-25 15:23:57 +01:00
@property
2022-06-30 14:20:52 +02:00
def current_vel(self) -> Union[float, int, np.ndarray, Tuple]:
2022-07-13 13:28:39 +02:00
return self.data.qvel.flat[:self.n_links]