Skip to content

Commit 6ab391d

Browse files
committed
Changed retimers to only Simplify untimed trajectories.
1 parent 0a327fc commit 6ab391d

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/prpy/planning/mac_smoother.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31-
from ..util import CopyTrajectory, SimplifyTrajectory, SetTrajectoryTags
31+
from ..util import (CopyTrajectory, SimplifyTrajectory, SetTrajectoryTags,
32+
IsTimedTrajectory)
3233
from base import (BasePlanner, PlanningError, PlanningMethod,
3334
UnsupportedPlanningError, Tags)
3435
from openravepy import (Planner, PlannerStatus, RaveCreatePlanner,
@@ -45,7 +46,7 @@ def __init__(self):
4546
'Unable to create PrSplineMacBlender planner. Is or_pr_spline'
4647
' installed and in your OPENRAVE_PLUGIN path?'
4748
)
48-
49+
4950
self.retimer = RaveCreatePlanner(self.env, 'PrSplineMacTimer')
5051
if self.retimer is None:
5152
raise UnsupportedPlanningError(
@@ -59,7 +60,11 @@ def RetimeTrajectory(self, robot, path):
5960
# necessary for two reasons: (1) the input trajectory may be in another
6061
# environment and/or (2) the retimer modifies the trajectory in-place.
6162
output_traj = CopyTrajectory(path, env=self.env)
62-
output_traj = SimplifyTrajectory(output_traj, robot)
63+
64+
# Remove co-linear waypoints. Some of the default OpenRAVE retimers do
65+
# not perform this check internally (e.g. ParabolicTrajectoryRetimer).
66+
if not IsTimedTrajectory(output_traj):
67+
output_traj = SimplifyTrajectory(output_traj, robot)
6368

6469
# Blend the piecewise-linear input trajectory. The blender outputs a
6570
# collision-free path, consisting of piecewise-linear segments and

src/prpy/planning/retimer.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

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
3540

3641
logger = logging.getLogger(__name__)
3742

@@ -56,11 +61,8 @@ def __str__(self):
5661

5762
@PlanningMethod
5863
def RetimeTrajectory(self, robot, path, options=None, **kw_args):
59-
from ..util import (CreatePlannerParametersString, CopyTrajectory,
60-
SimplifyTrajectory, HasAffineDOFs)
6164
from openravepy import CollisionOptions, CollisionOptionsStateSaver
6265
from copy import deepcopy
63-
from openravepy import Planner
6466

6567
# Validate the input path.
6668
cspec = path.GetConfigurationSpecification()
@@ -91,11 +93,12 @@ def RetimeTrajectory(self, robot, path, options=None, **kw_args):
9193
# Copy the input trajectory into the planning environment. This is
9294
# necessary for two reasons: (1) the input trajectory may be in another
9395
# 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)
9597

9698
# Remove co-linear waypoints. Some of the default OpenRAVE retimers do
9799
# 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)
99102

100103
# Only collision check the active DOFs.
101104
dof_indices, _ = cspec.ExtractUsedIndices(robot)
@@ -104,13 +107,12 @@ def RetimeTrajectory(self, robot, path, options=None, **kw_args):
104107
# Compute the timing. This happens in-place.
105108
self.planner.InitPlan(None, params_str)
106109

107-
108110
with CollisionOptionsStateSaver(self.env.GetCollisionChecker(),
109111
CollisionOptions.ActiveDOFs):
110112
status = self.planner.PlanPath(output_traj, releasegil=True)
111113

112-
if status not in [ PlannerStatus.HasSolution,
113-
PlannerStatus.InterruptedWithSolution ]:
114+
if status not in [PlannerStatus.HasSolution,
115+
PlannerStatus.InterruptedWithSolution]:
114116
raise PlanningError(
115117
'Retimer returned with status {:s}.'.format(str(status)))
116118

@@ -182,8 +184,6 @@ def RetimeTrajectory(self, robot, path, **kw_args):
182184
if not found:
183185
raise UnsupportedPlanningError('OpenRAVEAffineRetimer only supports untimed paths with affine DOFs. Found group: %s' % group.name)
184186

185-
186-
187187
# Copy the input trajectory into the planning environment. This is
188188
# necessary for two reasons: (1) the input trajectory may be in another
189189
# environment and/or (2) the retimer modifies the trajectory in-place.
@@ -197,8 +197,8 @@ def RetimeTrajectory(self, robot, path, **kw_args):
197197
status = RetimeTrajectory(output_traj, max_velocities, max_accelerations,
198198
False)
199199

200-
if status not in [ PlannerStatus.HasSolution,
201-
PlannerStatus.InterruptedWithSolution ]:
200+
if status not in [PlannerStatus.HasSolution,
201+
PlannerStatus.InterruptedWithSolution]:
202202
raise PlanningError('Retimer returned with status {0:s}.'.format(
203203
str(status)))
204204

0 commit comments

Comments
 (0)