2021-07-02 13:09:56 +02:00
|
|
|
from typing import Tuple, Union
|
2021-06-24 15:52:21 +02:00
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2021-07-30 11:59:02 +02:00
|
|
|
from mp_env_api import MPEnvWrapper
|
2021-06-24 15:52:21 +02:00
|
|
|
|
|
|
|
|
2021-07-30 11:59:02 +02:00
|
|
|
class MPWrapper(MPEnvWrapper):
|
2021-06-24 15:52:21 +02:00
|
|
|
@property
|
|
|
|
def active_obs(self):
|
|
|
|
return np.hstack([
|
|
|
|
[self.env.random_start] * self.env.n_links, # cos
|
|
|
|
[self.env.random_start] * self.env.n_links, # sin
|
|
|
|
[self.env.random_start] * self.env.n_links, # velocity
|
2021-06-25 16:16:56 +02:00
|
|
|
[self.env.initial_width is None], # hole width
|
2021-06-24 15:52:21 +02:00
|
|
|
# [self.env.hole_depth is None], # hole depth
|
|
|
|
[True] * 2, # x-y coordinates of target distance
|
|
|
|
[False] # env steps
|
|
|
|
])
|
|
|
|
|
|
|
|
@property
|
2021-07-02 13:09:56 +02:00
|
|
|
def current_pos(self) -> Union[float, int, np.ndarray, Tuple]:
|
|
|
|
return self.env.current_pos
|
2021-06-24 15:52:21 +02:00
|
|
|
|
|
|
|
@property
|
2021-07-02 13:09:56 +02:00
|
|
|
def current_vel(self) -> Union[float, int, np.ndarray, Tuple]:
|
|
|
|
return self.env.current_vel
|
|
|
|
|
|
|
|
@property
|
|
|
|
def goal_pos(self) -> Union[float, int, np.ndarray, Tuple]:
|
2021-06-24 15:52:21 +02:00
|
|
|
raise ValueError("Goal position is not available and has to be learnt based on the environment.")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def dt(self) -> Union[float, int]:
|
2021-06-25 16:16:56 +02:00
|
|
|
return self.env.dt
|