Skip to content

Commit 422b2ab

Browse files
author
Siddhartha Srinivasa
committed
Oh reduce, you are so troublesome. FWIW: Python only implements a left reduce and we needed a right reduce.
1 parent cab8e82 commit 422b2ab

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/prpy/util.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ def JointStatesFromTraj(robot, traj, times, derivatives=[0, 1, 2]):
767767
"""
768768
duration = traj.GetDuration()
769769

770+
times = numpy.array(times)
770771
if any(times > duration):
771772
raise ValueError('Input times {0:} exceed duration {1:.2f}'
772773
.format(times, duration))
@@ -852,7 +853,10 @@ def BodyPointsStatesFromJointStates(bodypoints,
852853
bp_state = [None] * numd
853854
link, local_pos = bp
854855
link_index = link.GetIndex()
855-
world_pos = numpy.dot(link.GetTransform(), local_pos)
856+
link_transform = link.GetTransform()
857+
world_pos = (numpy.dot(link_transform[0:3, 0:3],
858+
local_pos) +
859+
link_transform[0:3, 3])
856860
bp_state[0] = world_pos
857861
if qd is not None:
858862
Jpos = robot.CalculateJacobian(link_index, world_pos)
@@ -868,9 +872,9 @@ def BodyPointsStatesFromJointStates(bodypoints,
868872
link_index, world_pos)
869873
Hang = robot.ComputeHessianAxisAngle(link_index)
870874
apos = (numpy.dot(Jpos, qdd) +
871-
reduce(numpy.dot, [qd, Hpos, qd]))
875+
numpy.dot(qd, numpy.dot(Hpos, qd)))
872876
aang = (numpy.dot(Jang, qdd) +
873-
reduce(numpy.dot, [qd, Hang, qd]))
877+
numpy.dot(qd, numpy.dot(Hang, qd)))
874878
bp_state[2] = numpy.hstack((apos, aang))
875879
bpstate_list.append(bp_state)
876880
return bpstate_list

0 commit comments

Comments
 (0)