28
28
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
29
# POSSIBILITY OF SUCH DAMAGE.
30
30
31
- import logging , numpy , openravepy , os , tempfile
32
- from ..util import CopyTrajectory , SimplifyTrajectory , HasAffineDOFs
33
- from base import BasePlanner , PlanningError , PlanningMethod , UnsupportedPlanningError
34
- from openravepy import PlannerStatus
31
+ import logging
32
+ import openravepy
33
+ from ..util import (CreatePlannerParametersString , CopyTrajectory ,
34
+ SimplifyTrajectory , HasAffineDOFs , IsTimedTrajectory )
35
+ from base import (BasePlanner ,
36
+ PlanningError ,
37
+ PlanningMethod ,
38
+ UnsupportedPlanningError )
39
+ from openravepy import PlannerStatus , Planner
35
40
36
41
logger = logging .getLogger (__name__ )
37
42
@@ -56,11 +61,8 @@ def __str__(self):
56
61
57
62
@PlanningMethod
58
63
def RetimeTrajectory (self , robot , path , options = None , ** kw_args ):
59
- from ..util import (CreatePlannerParametersString , CopyTrajectory ,
60
- SimplifyTrajectory , HasAffineDOFs )
61
64
from openravepy import CollisionOptions , CollisionOptionsStateSaver
62
65
from copy import deepcopy
63
- from openravepy import Planner
64
66
65
67
# Validate the input path.
66
68
cspec = path .GetConfigurationSpecification ()
@@ -91,11 +93,12 @@ def RetimeTrajectory(self, robot, path, options=None, **kw_args):
91
93
# Copy the input trajectory into the planning environment. This is
92
94
# necessary for two reasons: (1) the input trajectory may be in another
93
95
# environment and/or (2) the retimer modifies the trajectory in-place.
94
- input_path = CopyTrajectory (path , env = self .env )
96
+ output_traj = CopyTrajectory (path , env = self .env )
95
97
96
98
# Remove co-linear waypoints. Some of the default OpenRAVE retimers do
97
99
# not perform this check internally (e.g. ParabolicTrajectoryRetimer).
98
- output_traj = SimplifyTrajectory (input_path , robot )
100
+ if not IsTimedTrajectory (output_traj ):
101
+ output_traj = SimplifyTrajectory (output_traj , robot )
99
102
100
103
# Only collision check the active DOFs.
101
104
dof_indices , _ = cspec .ExtractUsedIndices (robot )
@@ -104,13 +107,12 @@ def RetimeTrajectory(self, robot, path, options=None, **kw_args):
104
107
# Compute the timing. This happens in-place.
105
108
self .planner .InitPlan (None , params_str )
106
109
107
-
108
110
with CollisionOptionsStateSaver (self .env .GetCollisionChecker (),
109
111
CollisionOptions .ActiveDOFs ):
110
112
status = self .planner .PlanPath (output_traj , releasegil = True )
111
113
112
- if status not in [ PlannerStatus .HasSolution ,
113
- PlannerStatus .InterruptedWithSolution ]:
114
+ if status not in [PlannerStatus .HasSolution ,
115
+ PlannerStatus .InterruptedWithSolution ]:
114
116
raise PlanningError (
115
117
'Retimer returned with status {:s}.' .format (str (status )))
116
118
@@ -182,8 +184,6 @@ def RetimeTrajectory(self, robot, path, **kw_args):
182
184
if not found :
183
185
raise UnsupportedPlanningError ('OpenRAVEAffineRetimer only supports untimed paths with affine DOFs. Found group: %s' % group .name )
184
186
185
-
186
-
187
187
# Copy the input trajectory into the planning environment. This is
188
188
# necessary for two reasons: (1) the input trajectory may be in another
189
189
# environment and/or (2) the retimer modifies the trajectory in-place.
@@ -197,8 +197,8 @@ def RetimeTrajectory(self, robot, path, **kw_args):
197
197
status = RetimeTrajectory (output_traj , max_velocities , max_accelerations ,
198
198
False )
199
199
200
- if status not in [ PlannerStatus .HasSolution ,
201
- PlannerStatus .InterruptedWithSolution ]:
200
+ if status not in [PlannerStatus .HasSolution ,
201
+ PlannerStatus .InterruptedWithSolution ]:
202
202
raise PlanningError ('Retimer returned with status {0:s}.' .format (
203
203
str (status )))
204
204
0 commit comments