-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHerbEnvironment.py
67 lines (48 loc) · 2.05 KB
/
HerbEnvironment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import numpy
class HerbEnvironment(object):
def __init__(self, herb):
self.robot = herb.robot
# add a table and move the robot into place
table = self.robot.GetEnv().ReadKinBodyXMLFile('models/objects/table.kinbody.xml')
self.robot.GetEnv().Add(table)
table_pose = numpy.array([[ 0, 0, -1, 0.7],
[-1, 0, 0, 0],
[ 0, 1, 0, 0],
[ 0, 0, 0, 1]])
table.SetTransform(table_pose)
# set the camera
camera_pose = numpy.array([[ 0.3259757 , 0.31990565, -0.88960678, 2.84039211],
[ 0.94516159, -0.0901412 , 0.31391738, -0.87847549],
[ 0.02023372, -0.9431516 , -0.33174637, 1.61502194],
[ 0. , 0. , 0. , 1. ]])
self.robot.GetEnv().GetViewer().SetCamera(camera_pose)
# goal sampling probability
self.p = 0.0
def SetGoalParameters(self, goal_config, p = 0.2):
self.goal_config = goal_config
self.p = p
def GenerateRandomConfiguration(self):
config = [0] * len(self.robot.GetActiveDOFIndices())
#
# TODO: Generate and return a random configuration
#
return numpy.array(config)
def ComputeDistance(self, start_config, end_config):
#
# TODO: Implement a function which computes the distance between
# two configurations
#
pass
def Extend(self, start_config, end_config):
#
# TODO: Implement a function which attempts to extend from
# a start configuration to a goal configuration
#
pass
def ShortenPath(self, path, timeout=5.0):
#
# TODO: Implement a function which performs path shortening
# on the given path. Terminate the shortening after the
# given timout (in seconds).
#
return path