Skip to content

Commit c1fac84

Browse files
author
David Butterworth
committed
Add optional parameter to get F.K. relative to a specific frame
1 parent 48b6a58 commit c1fac84

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/prpy/util.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,16 +1027,21 @@ def CheckJointLimits(robot, q):
10271027
description='position')
10281028

10291029

1030-
def GetForwardKinematics(robot, q, manipulator=None):
1030+
def GetForwardKinematics(robot, q, manipulator=None, frame=None):
10311031
"""
1032-
Get the forward kinematics for a specific joint configuration.
1032+
Get the forward kinematics for a specific joint configuration,
1033+
relative to the OpenRAVE world frame.
10331034
10341035
@param openravepy.robot robot: The robot object.
10351036
@param list q: List or array of joint positions.
1036-
1037+
@param manipulator
1038+
@param string frame: Get the end effector transform relative to a
1039+
specific frame e.g. '/right/wam_base'
10371040
@returns T_ee: The pose of the end effector (or last link in the
10381041
serial chain) as a 4x4 matrix.
10391042
"""
1043+
from tf import transformations
1044+
10401045
if manipulator == None:
10411046
manipulator = robot.GetActiveManipulator()
10421047

@@ -1051,6 +1056,10 @@ def GetForwardKinematics(robot, q, manipulator=None):
10511056
T_ee = manipulator.GetEndEffectorTransform()
10521057
# Robot state is restored
10531058

1059+
if frame != None:
1060+
T_ref_frame = robot.GetLink(frame).GetTransform()
1061+
T_ee = transformations.concatenate_matrices(numpy.linalg.inv(T_ref_frame), T_ee)
1062+
10541063
return T_ee
10551064

10561065

0 commit comments

Comments
 (0)