Skip to content

Commit 40ac3d5

Browse files
committed
Merge pull request #174 from personalrobotics/bugfix/GreedyIK
Fixed GreedyIK planner in MoveUntilTouch.
2 parents 620a56a + 0ad4618 commit 40ac3d5

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/prpy/base/wam.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31+
import logging
3132
import numpy
3233
import openravepy
34+
import warnings
3335
from manipulator import Manipulator
3436
from prpy.clone import Clone
3537
from .. import util
3638
from .. import exceptions
3739

40+
logger = logging.getLogger('wam')
41+
3842
class WAM(Manipulator):
3943
def __init__(self, sim, owd_namespace,
4044
iktype=openravepy.IkParameterization.Type.Transform6D):
@@ -242,13 +246,14 @@ def ClearTrajectoryStatus(manipulator):
242246
if not manipulator.simulated:
243247
manipulator.controller.SendCommand('ClearStatus')
244248

245-
def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
249+
def MoveUntilTouch(manipulator, direction, distance, max_distance=None,
246250
max_force=5.0, max_torque=None, ignore_collisions=None, **kw_args):
247251
"""Execute a straight move-until-touch action.
248252
This action stops when a sufficient force is is felt or the manipulator
249253
moves the maximum distance. The motion is considered successful if the
250254
end-effector moves at least distance. In simulation, a move-until-touch
251255
action proceeds until the end-effector collids with the environment.
256+
252257
@param direction unit vector for the direction of motion in the world frame
253258
@param distance minimum distance in meters
254259
@param max_distance maximum distance in meters
@@ -258,6 +263,14 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
258263
@param **kw_args planner parameters
259264
@return felt_force flag indicating whether we felt a force.
260265
"""
266+
267+
if max_distance is None:
268+
max_distance = 1.
269+
warnings.warn(
270+
'MoveUntilTouch now requires the "max_distance" argument.'
271+
' This will be an error in the future.',
272+
DeprecationWarning)
273+
261274
# TODO: Is ignore_collisions a list of names or KinBody pointers?
262275
if max_torque is None:
263276
max_torque = numpy.array([100.0, 100.0, 100.0 ])

src/prpy/logger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31-
import collections, logging, sys
31+
import collections, logging, sys, warnings
3232

3333
class ColoredFormatter(logging.Formatter):
3434
def __init__(self, default):
@@ -80,6 +80,9 @@ def initialize_logging():
8080
spammy_logger = logging.getLogger(spammy_logger_name)
8181
spammy_logger.setLevel(logging.WARNING)
8282

83+
# Enable deprecation warnings, which are off by default in Python 2.7.
84+
warnings.simplefilter('default')
85+
8386
return base_logger
8487

8588
def remove_ros_logger():

src/prpy/planning/workspace.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def PlanToEndEffectorOffset(self, robot, direction, distance,
105105
raise ValueError('Direction must be non-zero')
106106
elif max_distance is not None and max_distance < distance:
107107
raise ValueError('Max distance is less than minimum distance.')
108+
elif max_distance is not None and not numpy.isfinite(max_distance):
109+
raise ValueError('Max distance must be finite.')
108110

109111
# Normalize the direction vector.
110112
direction = numpy.array(direction, dtype='float')
@@ -224,7 +226,7 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
224226
# Otherwise we'll gracefully terminate.
225227
else:
226228
logger.warning('Terminated early at time %f < %f: %s',
227-
t, traj.GetDuration(), e.message)
229+
t, traj.GetDuration(), str(e))
228230

229231
# Return as much of the trajectory as we have solved.
230232
SetTrajectoryTags(qtraj, {Tags.CONSTRAINED: True}, append=True)

0 commit comments

Comments
 (0)