Skip to content

Commit cd85a7a

Browse files
committed
Merge pull request #215 from rachelholladay/feature/ManipIndexUtil
Added GetManipIndex function to util.
2 parents 07bd109 + e70abee commit cd85a7a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/prpy/util.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#/usr/bin/env python
22

33
# Copyright (c) 2013, Carnegie Mellon University
44
# All rights reserved.
@@ -1167,3 +1167,22 @@ def wrap_to_interval(angles, lower=-numpy.pi):
11671167
@type lower float or numpy.array
11681168
"""
11691169
return (angles - lower) % (2*numpy.pi) + lower
1170+
1171+
def GetManipulatorIndex(robot, manip=None):
1172+
"""
1173+
Takes a robot and returns the active manipulator and its index
1174+
@param robot The OpenRAVE robot
1175+
@param manip The robot manipulator
1176+
@return (manip, manip_idx) The manipulator and its index
1177+
"""
1178+
1179+
with robot.GetEnv():
1180+
if manip is None:
1181+
manip = robot.GetActiveManipulator()
1182+
1183+
with robot.CreateRobotStateSaver(
1184+
robot.SaveParameters.ActiveManipulator):
1185+
robot.SetActiveManipulator(manip)
1186+
manip_idx = manip.GetRobot().GetActiveManipulatorIndex()
1187+
1188+
return (manip, manip_idx)

0 commit comments

Comments
 (0)