-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python/gym] Add termination conditions and reward components toolboxes. #671
Comments
After thinking twice, I think it makes more sense provide a class QuantityManager:
def __init__(self, robot: BaseJiminyRobot, quantities: Dict[str, Callable[[], Any]]) -> None:
self.robot = env.robot
self.quantities = quantities
self._cache : Dict[str, Any]
def __getattr__(self, name: str) -> Any:
return self.__cache.setdefault(name, self.quantities.get(name))
def __item__(self, name:str) -> Any:
return getattr(self, name)
def reset() -> None:
self.__cache.clear()
class RelativePose:
def __init__(self, robot: BaseJiminyRobot, first_name: str, second_name: str) -> None:
first_index = robot.pinocchio_model.getFrameId(first_name)
second_index = robot.pinocchio_model.getFrameId(second_name)
self.first_pose = self.robot.oMf[first_index]
self.second_pose = self.robot.oMf[second_index]
def __call__(self) -> pin.SE3:
return self.first_pose.actInv(self.second_pose)
def foot_placement_reward(quantities: QuantityManager) -> float:
return np.linalg.norm(quantities.foot_pose_rel.translation)
[...]
foot_pose_rel_qty = RelativePose(env.robot, "LeftSole", "RightSole")
quantities = QuantityManager(env.robot, {"foot_pose_rel": foot_pose_rel_qty})) There would be a reward manager, taking a quantity manager and a set of reward components as input. It would expose a single |
Currently, there is no toolbox with various pre-implemented toolboxes for termination conditions and reward components. It would be nice to provide some highly optimized yet modular implementations of the most common cases. Here is a template of what would be done for the reward:
The text was updated successfully, but these errors were encountered: