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

28 lines
808 B
Python
Raw Normal View History

2022-06-30 17:33:05 +02:00
from typing import Union, Tuple
2022-04-13 17:28:25 +02:00
import numpy as np
2022-06-30 17:33:05 +02:00
from alr_envs.black_box.raw_interface_wrapper import RawInterfaceWrapper
2022-04-13 17:28:25 +02:00
2022-06-30 14:08:54 +02:00
class MPWrapper(RawInterfaceWrapper):
2022-04-13 17:28:25 +02:00
2022-06-30 17:33:05 +02:00
# Random x goal + random init pos
2022-07-06 09:05:35 +02:00
@property
2022-06-30 17:33:05 +02:00
def context_mask(self):
2022-04-20 14:50:02 +02:00
return np.hstack([
2022-06-30 17:33:05 +02:00
[False] * (2 + int(not self.exclude_current_positions_from_observation)), # position
[True] * 3, # set to true if randomize initial pos
2022-04-20 14:50:02 +02:00
[False] * 6, # velocity
2022-07-07 10:47:04 +02:00
[True] * 3, # goal distance
[True] # goal
2022-04-20 14:50:02 +02:00
])
@property
2022-06-30 17:33:05 +02:00
def current_pos(self) -> Union[float, int, np.ndarray, Tuple]:
return self.sim.data.qpos[3:6].copy()
2022-04-20 14:50:02 +02:00
@property
def current_vel(self) -> Union[float, int, np.ndarray, Tuple]:
2022-06-30 17:33:05 +02:00
return self.sim.data.qvel[3:6].copy()