-
Notifications
You must be signed in to change notification settings - Fork 3
/
staubli_or_interface.py
71 lines (56 loc) · 2.09 KB
/
staubli_or_interface.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
68
69
70
71
import util
from barrett_manager import *
from staubli_manager import *
import roslib.packages
import util.str2num
def check_or_load_staubli( or_env ):
"""@brief - make sure staubli is loaded into openrave environment
@param or_env - openrave python environment
"""
robot_list = or_env.GetRobots()
current_robot = []
if (len(robot_list) > 0):
print "trajectory_planner::run_cbirrt:: WARNING: too many robots in openrave environment \n"
current_robot = robot_list[0]
else:
print "trajectory planner directory: " + str(roslib.packages.get_pkg_dir("trajectory_planner"))
current_robot = or_env.ReadRobotXMLFile(str(roslib.packages.get_pkg_dir("trajectory_planner") + "/models/staubli.robot.xml"))
print "robot loaded"
if current_robot:
or_env.AddRobot(current_robot)
return current_robot
def dof_list_from_traj_file(filename, active_dof_list):
"""@brief - Open trajectory file and read dof trajectory
@param filename - file containing trajectory from openrave
@param active_dof_list - list of dofs used by this robot
returns a list of dof lists for each point in the trajectory
"""
f = open( filename )
dof_traj_list = []
f.readline()
f.readline()
#The first line of the file is metadata
for line in f:
traj_list = util.str2num.str2num( line )
dof_traj_point = []
for n in active_dof_list:
dof_traj_point.append( traj_list[n+1] )
dof_traj_list.append( dof_traj_point )
return dof_traj_list
def update_robot(rob):
"""@brief - Update the robot in OpenRave representation of the robot from the staubli manager
@param rob - OpenRave robot object.
"""
rob.SetActiveDOFs(range(6))
succeeded = True
try:
j = get_staubli_joints()
rob.SetActiveDOFValues(j)
barret_joints = get_barrett_joints()
rob.SetActiveDOFs(range(6,10))
rob.SetActiveDOFValues(barret_joints)
except:
succeeded = False
pass
rob.SetActiveDOFs(range(6))
return succeeded