Skip to content

Commit 4c9af43

Browse files
committed
Modified check to use all trajectory DOFs instead of active.
1 parent 798daac commit 4c9af43

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/prpy/util.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -697,40 +697,40 @@ def FindCatkinResource(package, relative_path):
697697

698698
def IsAtTrajectoryStart(robot, trajectory):
699699
"""
700-
Check if robot's active DOFs match the start configuration of a trajectory.
700+
Check if robot's DOFs match the start configuration of a trajectory.
701701
702-
Examines the current active DOF values of the specified robot and compares
703-
these values to the first waypoint of the specified trajectory. If every
704-
DOF value differs by less than the DOF resolution of the specified
705-
joint/axis, then the function returns True. Otherwise, it returns False.
702+
This function examines the current DOF values of the specified robot and
703+
compares these values to the first waypoint of the specified trajectory.
704+
If every DOF value specified in the trajectory differs by less than the
705+
DOF resolution of the specified joint/axis then it will return True.
706+
Otherwise, it returns False.
706707
707708
@param robot: the robot whose active DOFs will be checked
708709
@param trajectory: the trajectory whose start configuration will be checked
709710
@returns: True if the robot's active DOFs match the given trajectory
710711
False if one or more active DOFs differ by DOF resolution
711712
"""
712-
# Get current active configuration of robot.
713-
dof_indices = robot.GetActiveDOFIndices()
714-
dof_values = robot.GetActiveDOFValues()
715-
dof_resolutions = robot.GetActiveDOFResolutions()
716-
717-
# Get starting configuration from trajectory.
713+
# Get used indices and starting configuration from trajectory.
718714
cspec = trajectory.GetConfigurationSpecification()
719-
start_values = cspec.ExtractJointValues(
715+
dof_indices, _ = cspec.ExtractUsedIndices(robot)
716+
traj_values = cspec.ExtractJointValues(
720717
trajectory.GetWaypoint(0), robot, dof_indices)
721718

722-
# Check deviation in each DOF, using OpenRAVE's SubtractValue function.
723-
for i, dof_index in enumerate(dof_indices):
719+
# Get current configuration of robot for used indices.
720+
robot_values = robot.GetDOFValues(dof_indices)
721+
dof_resolutions = robot.GetDOFResolutions(dof_indices)
724722

723+
# Check deviation in each DOF, using OpenRAVE's SubtractValue function.
724+
dof_infos = zip(dof_indices, traj_values, robot_values, dof_resolutions)
725+
for dof_index, traj_value, robot_value, dof_resolution in dof_infos:
725726
# Look up the Joint and Axis of the DOF from the robot.
726727
joint = robot.GetJointFromDOFIndex(dof_index)
727728
axis = dof_index - joint.GetDOFIndex()
728729

729-
# If any joint deviated too much, return False.
730-
delta_value = abs(joint.SubtractValue(
731-
start_values[i], dof_values[i], axis))
732-
if delta_value > dof_resolutions[i]:
730+
# If any joint deviates too much, return False.
731+
delta_value = abs(joint.SubtractValue(traj_value, robot_value, axis))
732+
if delta_value > dof_resolution:
733733
return False
734734

735-
# If all joints matched, return True.
735+
# If all joints match, return True.
736736
return True

0 commit comments

Comments
 (0)