|
29 | 29 | # POSSIBILITY OF SUCH DAMAGE.
|
30 | 30 |
|
31 | 31 | import functools, logging, openravepy, numpy
|
32 |
| -import prpy.util |
33 |
| -from .. import bind, named_config, planning, util |
| 32 | +from .. import bind, named_config, exceptions, util |
34 | 33 | from ..clone import Clone, Cloned
|
35 | 34 | from ..tsr.tsrlibrary import TSRLibrary
|
36 | 35 | from ..planning.base import Sequence, Tags
|
@@ -281,7 +280,7 @@ def do_postprocess():
|
281 | 280 | # Extract active DOFs from teh trajectory and set them as active.
|
282 | 281 | dof_indices, _ = cspec.ExtractUsedIndices(self)
|
283 | 282 |
|
284 |
| - if prpy.util.HasAffineDOFs(cspec): |
| 283 | + if util.HasAffineDOFs(cspec): |
285 | 284 | affine_dofs = (DOFAffine.X | DOFAffine.Y | DOFAffine.RotationAxis)
|
286 | 285 |
|
287 | 286 | # Bug in OpenRAVE ExtractUsedIndices function makes
|
@@ -438,18 +437,33 @@ def ExecuteTrajectory(self, traj, defer=False, timeout=None, period=0.01, **kwar
|
438 | 437 | @param period poll rate, in seconds, for checking trajectory status
|
439 | 438 | @return trajectory executed on the robot
|
440 | 439 | """
|
| 440 | + # Don't execute trajectories that don't have at least one waypoint. |
| 441 | + if traj.GetNumWaypoints() <= 0: |
| 442 | + raise ValueError('Trajectory must contain at least one waypoint.') |
| 443 | + |
| 444 | + # Check that the current configuration of the robot matches the |
| 445 | + # initial configuration specified by the trajectory. |
| 446 | + if not util.IsAtTrajectoryStart(self, traj): |
| 447 | + raise exceptions.TrajectoryAborted( |
| 448 | + 'Trajectory started from different configuration than robot.') |
| 449 | + |
| 450 | + # If there was only one waypoint, at this point we are done! |
| 451 | + if traj.GetNumWaypoints() == 1: |
| 452 | + return traj |
441 | 453 |
|
442 |
| - # TODO: Verify that the trajectory is timed. |
443 |
| - # TODO: Check if this trajectory contains the base. |
| 454 | + # Verify that the trajectory is timed. |
| 455 | + if traj.GetDuration() <= 0.0: |
| 456 | + raise ValueError('Attempted to execute untimed trajectory.') |
444 | 457 |
|
| 458 | + # TODO: Check if this trajectory contains the base. |
445 | 459 | needs_base = util.HasAffineDOFs(traj.GetConfigurationSpecification())
|
446 | 460 |
|
447 | 461 | self.GetController().SetPath(traj)
|
448 | 462 |
|
449 | 463 | active_manipulators = self.GetTrajectoryManipulators(traj)
|
450 | 464 | active_controllers = [
|
451 |
| - active_manipulator.controller \ |
452 |
| - for active_manipulator in active_manipulators \ |
| 465 | + active_manipulator.controller |
| 466 | + for active_manipulator in active_manipulators |
453 | 467 | if hasattr(active_manipulator, 'controller')
|
454 | 468 | ]
|
455 | 469 |
|
@@ -485,8 +499,8 @@ def do_poll():
|
485 | 499 | util.WaitForControllers(active_controllers, timeout=timeout)
|
486 | 500 | return traj
|
487 | 501 | else:
|
488 |
| - raise ValueError('Received unexpected value "{:s}" for defer.'.format(str(defer))) |
489 |
| - |
| 502 | + raise ValueError('Received unexpected value "{:s}" for defer.' |
| 503 | + .format(str(defer))) |
490 | 504 |
|
491 | 505 | def ViolatesVelocityLimits(self, traj):
|
492 | 506 | """
|
|
0 commit comments