add target_link to Strike goal

This commit is contained in:
Bart Moyaers
2020-02-17 10:26:41 +01:00
parent 739f9a61a7
commit 595d3af4f4
2 changed files with 8 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import random
import math import math
import pybullet as pb import pybullet as pb
import numpy import numpy
from pybullet_envs.deep_mimic.env.humanoid_link_ids import HumanoidLinks
class RandomBounds: class RandomBounds:
def __init__(self, lower_bound: float, upper_bound: float): def __init__(self, lower_bound: float, upper_bound: float):
@@ -65,13 +66,15 @@ class Strike(Goal):
height_RB: RandomBounds, height_RB: RandomBounds,
rot_RB: RandomBounds, rot_RB: RandomBounds,
hit_range = 0.2, hit_range = 0.2,
follow_rot = True): follow_rot = True,
target_link = HumanoidLinks.rightAnkle):
self.follow_rot = follow_rot self.follow_rot = follow_rot
self.is_hit_prev = False self.is_hit_prev = False
self.distance_RB = distance_RB self.distance_RB = distance_RB
self.height_RB = height_RB self.height_RB = height_RB
self.rot_RB = rot_RB self.rot_RB = rot_RB
self.hit_range = hit_range self.hit_range = hit_range
self.target_link = target_link
super().__init__(GoalType.Strike) super().__init__(GoalType.Strike)
def generateGoalData(self, def generateGoalData(self,
@@ -133,7 +136,8 @@ class Grab(Strike):
height_RB = RandomBounds(0.8, 1.1) height_RB = RandomBounds(0.8, 1.1)
rot_RB = RandomBounds(3.14159 - 0.5, 3.14159 + 0.5) rot_RB = RandomBounds(3.14159 - 0.5, 3.14159 + 0.5)
hit_range = 0.1 hit_range = 0.1
super().__init__(distance_RB, height_RB, rot_RB, hit_range=hit_range, follow_rot=False) target_link = HumanoidLinks.rightWrist
super().__init__(distance_RB, height_RB, rot_RB, hit_range=hit_range, follow_rot=False, target_link=target_link)
class TargetHeadingGoal(Goal): class TargetHeadingGoal(Goal):
def __init__(self): def __init__(self):

View File

@@ -257,10 +257,7 @@ class PyBulletDeepMimicEnv(Env):
goal_weight = 0.3 goal_weight = 0.3
if self.goal.goal_type == GoalType.Strike: if self.goal.goal_type == GoalType.Strike:
if self.goal.__class__ == Kick: linkPos, linkOrient = self._humanoid.getLinkPositionAndOrientation(self.goal.target_link)
linkPos, linkOrient = self._humanoid.getLinkPositionAndOrientation(HumanoidLinks.rightAnkle)
else: #elif type(self.goal) == Grab:
linkPos, linkOrient = self._humanoid.getLinkPositionAndOrientation(HumanoidLinks.rightWrist)
reward = mimic_weight * reward + goal_weight * self.calcStrikeGoalReward(linkPos) reward = mimic_weight * reward + goal_weight * self.calcStrikeGoalReward(linkPos)
return reward return reward
@@ -292,7 +289,7 @@ class PyBulletDeepMimicEnv(Env):
#print("pybullet_deep_mimic_env:update timeStep=",timeStep," t=",self.t) #print("pybullet_deep_mimic_env:update timeStep=",timeStep," t=",self.t)
self._pybullet_client.setTimeStep(timeStep) self._pybullet_client.setTimeStep(timeStep)
self._humanoid._timeStep = timeStep self._humanoid._timeStep = timeStep
self.updateGoal(self._humanoid.getLinkPositionAndOrientation(HumanoidLinks.rightAnkle)[0]) self.updateGoal(self._humanoid.getLinkPositionAndOrientation(self.goal.target_link)[0])
if self.target_id is not None: # TODO: check goal type if self.target_id is not None: # TODO: check goal type
self.updateDrawStrikeGoal() self.updateDrawStrikeGoal()