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