@@ -890,16 +890,20 @@ def ComputeUnitTiming(robot, traj, env=None):
890
890
if env is None :
891
891
env = traj .GetEnv ()
892
892
893
- cspec = traj .GetConfigurationSpecification ()
894
- cspec .AddDeltaTimeGroup ()
895
- dof_indices , _ = cspec .ExtractUsedIndices (robot )
893
+ old_cspec = traj .GetConfigurationSpecification ()
894
+ dof_indices , _ = old_cspec .ExtractUsedIndices (robot )
895
+
896
+ with robot .CreateRobotStateSaver (robot ):
897
+ robot .SetActiveDOFs (dof_indices )
898
+ new_cspec = robot .GetActiveConfigurationSpecification ('linear' )
899
+ new_cspec .AddDeltaTimeGroup ()
896
900
897
901
new_traj = RaveCreateTrajectory (env , '' )
898
- new_traj .Init (cspec )
902
+ new_traj .Init (new_cspec )
899
903
900
904
for i in range (traj .GetNumWaypoints ()):
901
- waypoint = traj .GetWaypoint (i , cspec )
902
- dof_values = cspec .ExtractJointValues (waypoint , robot , dof_indices )
905
+ old_waypoint = traj .GetWaypoint (i )
906
+ dof_values = old_cspec .ExtractJointValues (old_waypoint , robot , dof_indices )
903
907
904
908
if i == 0 :
905
909
deltatime = 0.
@@ -908,8 +912,11 @@ def ComputeUnitTiming(robot, traj, env=None):
908
912
909
913
dof_values_prev = dof_values
910
914
911
- cspec .InsertDeltaTime (waypoint , deltatime )
912
- new_traj .Insert (i , waypoint )
915
+ new_waypoint = numpy .zeros (new_cspec .GetDOF ())
916
+
917
+ new_cspec .InsertJointValues (new_waypoint , dof_values , robot , dof_indices , 0 )
918
+ new_cspec .InsertDeltaTime (new_waypoint , deltatime )
919
+ new_traj .Insert (i , new_waypoint )
913
920
914
921
return new_traj
915
922
0 commit comments