@@ -697,40 +697,40 @@ def FindCatkinResource(package, relative_path):
697
697
698
698
def IsAtTrajectoryStart (robot , trajectory ):
699
699
"""
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.
701
701
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.
706
707
707
708
@param robot: the robot whose active DOFs will be checked
708
709
@param trajectory: the trajectory whose start configuration will be checked
709
710
@returns: True if the robot's active DOFs match the given trajectory
710
711
False if one or more active DOFs differ by DOF resolution
711
712
"""
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.
718
714
cspec = trajectory .GetConfigurationSpecification ()
719
- start_values = cspec .ExtractJointValues (
715
+ dof_indices , _ = cspec .ExtractUsedIndices (robot )
716
+ traj_values = cspec .ExtractJointValues (
720
717
trajectory .GetWaypoint (0 ), robot , dof_indices )
721
718
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 )
724
722
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 :
725
726
# Look up the Joint and Axis of the DOF from the robot.
726
727
joint = robot .GetJointFromDOFIndex (dof_index )
727
728
axis = dof_index - joint .GetDOFIndex ()
728
729
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 :
733
733
return False
734
734
735
- # If all joints matched , return True.
735
+ # If all joints match , return True.
736
736
return True
0 commit comments