31
31
import copy , functools , numpy , openravepy
32
32
from .. import bind
33
33
from prpy .clone import Clone
34
- from ..planning .retimer import OpenRAVEAffineRetimer
35
34
36
35
def create_affine_trajectory (robot , poses ):
37
36
doft = openravepy .DOFAffine .X | openravepy .DOFAffine .Y | openravepy .DOFAffine .RotationAxis
@@ -51,8 +50,6 @@ def __init__(self, sim, robot):
51
50
self .simulated = sim
52
51
self .robot = robot
53
52
54
- self .retimer = OpenRAVEAffineRetimer ()
55
-
56
53
def __dir__ (self ):
57
54
# Add planning methods to the tab-completion list.
58
55
method_names = set (self .__dict__ .keys ())
@@ -95,9 +92,9 @@ def Forward(self, meters, execute=True, direction=None, **kw_args):
95
92
offset_pose [0 :3 , 3 ] = meters * direction
96
93
goal_pose = numpy .dot (start_pose , offset_pose )
97
94
98
- traj = create_affine_trajectory (self .robot , [ start_pose , goal_pose ])
95
+ path = create_affine_trajectory (self .robot , [ start_pose , goal_pose ])
99
96
if execute :
100
- return self .ExecuteBasePath ( traj , ** kw_args )
97
+ return self .robot . ExecutePath ( path , ** kw_args )
101
98
else :
102
99
return traj
103
100
else :
@@ -116,9 +113,9 @@ def Rotate(self, angle_rad, execute=True, **kw_args):
116
113
relative_pose = openravepy .matrixFromAxisAngle ([ 0. , 0. , angle_rad ])
117
114
goal_pose = numpy .dot (start_pose , relative_pose )
118
115
119
- traj = create_affine_trajectory (self .robot , [ start_pose , goal_pose ])
116
+ path = create_affine_trajectory (self .robot , [ start_pose , goal_pose ])
120
117
if execute :
121
- return self .ExecuteBasePath ( traj , ** kw_args )
118
+ return self .robot . ExecutePath ( path , ** kw_args )
122
119
else :
123
120
return traj
124
121
else :
@@ -147,6 +144,7 @@ def DriveStraightUntilForce(self, direction, velocity=0.1, force_threshold=3.0,
147
144
raise NotImplementedError ('DriveStraightUntilForce is not implemented' )
148
145
149
146
def _BasePlanWrapper (self , planning_method , args , kw_args ):
147
+
150
148
robot = self .robot
151
149
with Clone (robot .GetEnv ()) as cloned_env :
152
150
cloned_robot = cloned_env .Cloned (robot )
@@ -169,41 +167,7 @@ def _BasePlanWrapper(self, planning_method, args, kw_args):
169
167
170
168
# Optionally execute the trajectory.
171
169
if 'execute' not in kw_args or kw_args ['execute' ]:
172
- return self .ExecuteBasePath (traj , ** kw_args )
170
+ return self .robot . ExecutePath (traj , ** kw_args )
173
171
else :
174
172
return traj
175
-
176
- def ExecuteBasePath (self , path , defer = False , ** kwargs ):
177
-
178
- def do_execute (path , ** kwargs ):
179
- robot = self .robot
180
- with Clone (robot .GetEnv ()) as cloned_env :
181
-
182
- cloned_robot = cloned_env .Cloned (robot )
183
- cloned_robot .SetActiveDOFs (
184
- [],
185
- affine = (openravepy .DOFAffine .X |
186
- openravepy .DOFAffine .Y |
187
- openravepy .DOFAffine .RotationAxis )
188
- )
189
-
190
- cloned_timed_traj = self .retimer .RetimeTrajectory (cloned_robot , path , defer = False , ** kwargs )
191
-
192
- # Copy the trajectory back to the original environment.
193
- from ..util import CopyTrajectory
194
- timed_traj = CopyTrajectory (cloned_timed_traj , env = robot .GetEnv ())
195
-
196
- return robot .ExecuteTrajectory (timed_traj , defer = False , ** kwargs )
197
-
198
- if defer :
199
- from trollius .executor import get_default_executor
200
- from trollius .futures import wrap_future
201
-
202
- executor = kwargs .get ('executor' ) or get_default_executor ()
203
- return wrap_future (
204
- executor .submit (do_execute ,
205
- path , ** kwargs
206
- )
207
- )
208
- else :
209
- return do_execute (path , ** kwargs )
173
+
0 commit comments