fancy_gym/alr_envs/alr/mujoco/reacher/new_mp_wrapper.py

24 lines
861 B
Python
Raw Normal View History

2022-06-29 09:37:18 +02:00
from alr_envs.mp.black_box_wrapper import BlackBoxWrapper
2022-04-28 09:05:28 +02:00
from typing import Union, Tuple
import numpy as np
2022-06-29 09:37:18 +02:00
class MPWrapper(BlackBoxWrapper):
2022-04-28 09:05:28 +02:00
@property
def current_pos(self) -> Union[float, int, np.ndarray, Tuple]:
return self.env.sim.data.qpos.flat[:self.env.n_links]
@property
def current_vel(self) -> Union[float, int, np.ndarray, Tuple]:
return self.env.sim.data.qvel.flat[:self.env.n_links]
2022-06-29 09:37:18 +02:00
def get_context_mask(self):
2022-04-28 09:05:28 +02:00
return np.concatenate([
[False] * self.env.n_links, # cos
[False] * self.env.n_links, # sin
[True] * 2, # goal position
[False] * self.env.n_links, # angular velocity
[False] * 3, # goal distance
# self.get_body_com("target"), # only return target to make problem harder
[False], # step
2022-05-02 15:06:21 +02:00
])