@@ -75,13 +75,8 @@ def CloseEnough():
75
75
return True
76
76
return False
77
77
78
- qtraj , terminate = self .FollowVectorField (robot , vf_geodesic ,
79
- timelimit , CloseEnough )
80
-
81
- if not terminate :
82
- raise PlanningError ('Local minimum: unable to reach goal pose: ' )
83
-
84
- return qtraj
78
+ return self .FollowVectorField (robot , vf_geodesic ,
79
+ CloseEnough , timelimit )
85
80
86
81
@PlanningMethod
87
82
def PlanToEndEffectorOffset (self , robot , direction , distance ,
@@ -139,7 +134,7 @@ def TerminateMove():
139
134
'''
140
135
Tnow = manip .GetEndEffectorTransform ()
141
136
error = prpy .util .GeodesicError (Tstart , Tnow )
142
- if error [3 ] > angular_tolerance :
137
+ if numpy . fabs ( error [3 ]) > angular_tolerance :
143
138
raise PlanningError ('Deviated from orientation constraint.' )
144
139
distance_moved = numpy .dot (error [0 :3 ], direction )
145
140
position_deviation = numpy .linalg .norm (error [0 :3 ] -
@@ -151,19 +146,14 @@ def TerminateMove():
151
146
return True
152
147
return False
153
148
154
- qtraj , terminate = self .FollowVectorField (robot , vf_straightline ,
155
- timelimit , TerminateMove )
156
-
157
- if not terminate :
158
- raise PlanningError ('Local minimum: unable to reach goal pose: ' )
159
-
160
- return qtraj
149
+ return self .FollowVectorField (robot , vf_straightline ,
150
+ TerminateMove , timelimit )
161
151
162
152
@PlanningMethod
163
- def FollowVectorField (self , robot , fn_vectorfield , timelimit = 5.0 ,
164
- fn_terminate = None , dq_tol = 0.0001 , ** kw_args ):
153
+ def FollowVectorField (self , robot , fn_vectorfield , fn_terminate ,
154
+ timelimit = 5.0 , dq_tol = 0.0001 , ** kw_args ):
165
155
"""
166
- Follow a joint space vectorfield to local minimum or termination.
156
+ Follow a joint space vectorfield to termination.
167
157
168
158
@param robot
169
159
@param fn_vectorfield a vectorfield of joint velocities
@@ -176,10 +166,6 @@ def FollowVectorField(self, robot, fn_vectorfield, timelimit=5.0,
176
166
"""
177
167
start_time = time .time ()
178
168
179
- if fn_terminate is None :
180
- def fn_terminate ():
181
- return False
182
-
183
169
with robot :
184
170
manip = robot .GetActiveManipulator ()
185
171
robot .SetActiveDOFs (manip .GetArmIndices ())
@@ -216,10 +202,11 @@ def fn_terminate():
216
202
waypoint = numpy .concatenate (waypoint )
217
203
qtraj .Insert (qtraj .GetNumWaypoints (), waypoint )
218
204
dqout = fn_vectorfield ()
219
- terminate = fn_terminate ()
220
- if (numpy .linalg .norm (dqout ) < dq_tol ) or terminate :
205
+ if (numpy .linalg .norm (dqout ) < dq_tol ):
206
+ raise PlanningError ('Local minimum, unable to progress' )
207
+ if fn_terminate ():
221
208
break
222
209
qnew = q_curr + dqout * dt
223
210
robot .SetActiveDOFValues (qnew )
224
211
225
- return qtraj , terminate
212
+ return qtraj
0 commit comments