Skip to content

Commit cde6d1f

Browse files
committed
Merge pull request #259 from personalrobotics/feature/GetJointDerivativeGroup
Added a helper function to extract joint groups.
2 parents e90be3d + bf85364 commit cde6d1f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/prpy/util.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,39 @@ def IsInCollision(traj, robot, selfcoll_only=False):
13741374
return False
13751375

13761376

1377+
OPENRAVE_JOINT_DERIVATIVES = {
1378+
0: "joint_values",
1379+
1: "joint_velocities",
1380+
2: "joint_accelerations",
1381+
3: "joint_jerks",
1382+
4: "joint_snaps",
1383+
5: "joint_crackles",
1384+
6: "joint_pops"
1385+
}
1386+
1387+
1388+
def GetJointDerivativeGroup(cspec, derivative):
1389+
"""
1390+
Helper function to extract a joint derivative group from a trajectory.
1391+
1392+
We use a manual mapping of joint derivatives to string values because the
1393+
OpenRAVE source code internally hard codes these constants anyway:
1394+
https://github.com/rdiankov/openrave/blob/master/src/libopenrave/configurationspecification.cpp#L983
1395+
1396+
@param cspec a trajectory configurationspecification
1397+
@param derivative the desired joint position derivative
1398+
(e.g. 0 = positions, 1 = velocities, ...)
1399+
@return a ConfigurationSpecification Group for the derivative
1400+
or None if it does not exist in the specification.
1401+
"""
1402+
try:
1403+
return cspec.GetGroupFromName(OPENRAVE_JOINT_DERIVATIVES[derivative])
1404+
except KeyError:
1405+
return None
1406+
except openravepy.openrave_exception:
1407+
return None
1408+
1409+
13771410
def JointStatesFromTraj(robot, traj, times, derivatives=[0, 1, 2]):
13781411
"""
13791412
Helper function to extract the joint position, velocity and acceleration

0 commit comments

Comments
 (0)