-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHerbRobot.py
55 lines (39 loc) · 1.96 KB
/
HerbRobot.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
import openravepy
class HerbRobot(object):
def __init__(self, env, manip):
self.name = 'herb'
self.robot = env.ReadRobotXMLFile('models/robots/herb2_padded.robot.xml')
env.Add(self.robot)
right_relaxed = [ 5.65, -1.76, -0.26, 1.96, -1.15 , 0.87, -1.43 ]
left_relaxed = [ 0.64, -1.76, 0.26, 1.96, 1.16, 0.87, 1.43 ]
right_manip = self.robot.GetManipulator('right_wam')
self.robot.SetActiveDOFs(right_manip.GetArmIndices())
self.robot.SetActiveDOFValues(right_relaxed)
left_manip = self.robot.GetManipulator('left_wam')
self.robot.SetActiveDOFs(left_manip.GetArmIndices())
self.robot.SetActiveDOFValues(left_relaxed)
if manip == 'right':
self.manip = right_manip
self.robot.SetActiveManipulator('right_wam')
else:
self.manip = left_manip
self.robot.SetActiveManipulator('left_wam')
self.robot.SetActiveDOFs(self.manip.GetArmIndices())
self.robot.controller = openravepy.RaveCreateController(self.robot.GetEnv(), 'IdealController')
def GetCurrentConfiguration(self):
return self.robot.GetActiveDOFValues()
def ConvertPlanToTrajectory(self, plan):
# Create a trajectory
traj = openravepy.RaveCreateTrajectory(self.robot.GetEnv(), 'GenericTrajectory')
config_spec = self.robot.GetActiveConfigurationSpecification()
traj.Init(config_spec)
idx = 0
for pt in plan:
traj.Insert(idx, pt)
idx = idx + 1
openravepy.planningutils.RetimeActiveDOFTrajectory(traj, self.robot, maxvelmult=1, maxaccelmult=1, hastimestamps=False, plannername='ParabolicTrajectoryRetimer')
return traj
def ExecuteTrajectory(self, traj):
# Send the trajectory to the controller and wait for execution to complete
self.robot.GetController().SetPath(traj)
self.robot.WaitForController(0)