Skip to content

Commit 9489e4e

Browse files
author
Siddhartha Srinivasa
committed
More code refactoring and testing of end effector offset
1 parent 3c531a8 commit 9489e4e

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/prpy/planning/vectorfield.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,8 @@ def CloseEnough():
7575
return True
7676
return False
7777

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)
8580

8681
@PlanningMethod
8782
def PlanToEndEffectorOffset(self, robot, direction, distance,
@@ -139,7 +134,7 @@ def TerminateMove():
139134
'''
140135
Tnow = manip.GetEndEffectorTransform()
141136
error = prpy.util.GeodesicError(Tstart, Tnow)
142-
if error[3] > angular_tolerance:
137+
if numpy.fabs(error[3]) > angular_tolerance:
143138
raise PlanningError('Deviated from orientation constraint.')
144139
distance_moved = numpy.dot(error[0:3], direction)
145140
position_deviation = numpy.linalg.norm(error[0:3] -
@@ -151,19 +146,14 @@ def TerminateMove():
151146
return True
152147
return False
153148

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)
161151

162152
@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):
165155
"""
166-
Follow a joint space vectorfield to local minimum or termination.
156+
Follow a joint space vectorfield to termination.
167157
168158
@param robot
169159
@param fn_vectorfield a vectorfield of joint velocities
@@ -176,10 +166,6 @@ def FollowVectorField(self, robot, fn_vectorfield, timelimit=5.0,
176166
"""
177167
start_time = time.time()
178168

179-
if fn_terminate is None:
180-
def fn_terminate():
181-
return False
182-
183169
with robot:
184170
manip = robot.GetActiveManipulator()
185171
robot.SetActiveDOFs(manip.GetArmIndices())
@@ -216,10 +202,11 @@ def fn_terminate():
216202
waypoint = numpy.concatenate(waypoint)
217203
qtraj.Insert(qtraj.GetNumWaypoints(), waypoint)
218204
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():
221208
break
222209
qnew = q_curr + dqout*dt
223210
robot.SetActiveDOFValues(qnew)
224211

225-
return qtraj, terminate
212+
return qtraj

0 commit comments

Comments
 (0)