Skip to content

Commit 7c3f6e8

Browse files
author
David Butterworth
committed
Add util function to compute forward kinematics
1 parent 0496943 commit 7c3f6e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/prpy/util.py

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

10291029

1030+
def GetForwardKinematics(robot, q):
1031+
"""
1032+
Get the forward kinematics for a specific joint configuration.
1033+
1034+
@param openravepy.robot robot: The robot object.
1035+
@param list q: List or array of joint positions.
1036+
1037+
@returns T_ee: The pose of the end effector (or last link in the
1038+
serial chain) as a 4x4 matrix.
1039+
"""
1040+
T_ee = None
1041+
1042+
# Save the robot state
1043+
sp = openravepy.Robot.SaveParameters
1044+
with robot.CreateRobotStateSaver():
1045+
robot.SetActiveDOFValues(q)
1046+
T_ee = robot.GetActiveManipulator().GetTransform()
1047+
# Robot state is restored
1048+
return T_ee
1049+
1050+
10301051
def ConvertIntToBinaryString(x, reverse=False):
10311052
"""
10321053
Convert an integer to a binary string.

0 commit comments

Comments
 (0)