Skip to content

Commit a964cd2

Browse files
committed
Merge pull request #136 from personalrobotics/feature/timing_tags
Adding tags for capturing trajectory timing data
2 parents 23f59e4 + 0b882e0 commit a964cd2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/prpy/base/robot.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
from .. import bind, named_config, planning, util
3434
from ..clone import Clone, Cloned
3535
from ..tsr.tsrlibrary import TSRLibrary
36-
from ..planning.base import Sequence
36+
from ..planning.base import Sequence, Tags
3737
from ..planning.ompl import OMPLSimplifier
3838
from ..planning.retimer import HauserParabolicSmoother, OpenRAVEAffineRetimer, ParabolicRetimer
3939
from ..planning.mac_smoother import MacSmoother
40+
from ..util import SetTrajectoryTags
4041

4142
logger = logging.getLogger('robot')
4243

@@ -377,6 +378,7 @@ def do_execute():
377378

378379
with Timer() as timer:
379380
traj = self.PostProcessPath(path, defer=False, **kwargs)
381+
SetTrajectoryTags(traj, {Tags.POSTPROCESS_TIME: timer.get_duration()}, append=True)
380382

381383
logger.info('Post-processing took %.3f seconds and produced a path'
382384
' with %d waypoints and a duration of %.3f seconds.',
@@ -385,7 +387,10 @@ def do_execute():
385387
traj.GetDuration()
386388
)
387389

388-
return self.ExecuteTrajectory(traj, defer=False, **kwargs)
390+
with Timer() as timer:
391+
exec_traj = self.ExecuteTrajectory(traj, defer=False, **kwargs)
392+
SetTrajectoryTags(exec_traj, {Tags.EXECUTION_TIME: timer.get_duration()}, append=True)
393+
return exec_traj
389394

390395
if defer is True:
391396
from trollius.executor import get_default_executor
@@ -541,7 +546,10 @@ def _PlanWrapper(self, planning_method, args, kw_args):
541546
config_spec = self.GetActiveConfigurationSpecification('linear')
542547

543548
# Call the planner.
544-
result = planning_method(self, *args, **kw_args)
549+
from ..util import Timer
550+
with Timer() as timer:
551+
result = planning_method(self, *args, **kw_args)
552+
SetTrajectoryTags(result, {Tags.PLAN_TIME: timer.get_duration()}, append=True)
545553

546554
def postprocess_trajectory(traj):
547555
# Strip inactive DOFs from the trajectory.

src/prpy/planning/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class Tags(object):
4343
CONSTRAINED = 'constrained'
4444
PLANNER = 'planner'
4545
METHOD = 'planning_method'
46+
PLAN_TIME = 'planning_time'
47+
POSTPROCESS_TIME = 'postprocess_time'
48+
EXECUTION_TIME = 'execution_time'
4649

4750
class PlanningError(Exception):
4851
pass

0 commit comments

Comments
 (0)