Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to L2 DOF resolution in VectorField and GreedyIk #332

Merged
merged 7 commits into from
Jul 27, 2016
14 changes: 8 additions & 6 deletions src/prpy/planning/vectorfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def FollowVectorField(self, robot, fn_vectorfield, fn_terminate,
SelfCollisionPlanningError,
)
from openravepy import CollisionReport, RaveCreateTrajectory
from ..util import GetCollisionCheckPts
from ..util import GetLinearCollisionCheckPts
import time
import scipy.integrate

Expand Down Expand Up @@ -526,11 +526,13 @@ def fn_callback(t, q):
if path.GetNumWaypoints() == 1:
checks = [(t, q)]
else:
# TODO: This should start at t_check. Unfortunately, a bug
# in GetCollisionCheckPts causes this to enter an infinite
# loop.
checks = GetCollisionCheckPts(robot, path,
include_start=False)
# TODO: This will recheck the entire trajectory
# Ideally should just check the new portion of the trajectory
from prpy.util import VanDerCorputSampleGenerator
vdc = VanDerCorputSampleGenerator
checks = GetLinearCollisionCheckPts(robot, path,
norm_order=2,
sampling_func=vdc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you modify FollowVectorField to accept a sampling_func? The default can still be VanDerCorputSampleGenerator. This is the convention we've followed in other planners to allow the user to configure this option.

# start_time=nonlocals['t_check'])

for t_check, q_check in checks:
Expand Down
20 changes: 15 additions & 5 deletions src/prpy/planning/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def PlanToEndEffectorOffset(self, robot, direction, distance,

@ClonedPlanningMethod
def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
min_waypoint_index=None, **kw_args):
min_waypoint_index=None, norm_order=2, **kw_args):
"""
Plan a configuration space path given a workspace path.
All timing information is ignored.
Expand All @@ -150,6 +150,11 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
represented as OpenRAVE AffineTrajectory
@param min_waypoint_index minimum waypoint index to reach
@param timelimit timeout in seconds
@param norm_order: 1 ==> The L1 norm
2 ==> The L2 norm
inf ==> The L_infinity norm
Used to determine the resolution of collision checked waypoints
in the trajectory
@return qtraj configuration space path
"""
from .exceptions import (
Expand Down Expand Up @@ -179,6 +184,8 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
t = 0.
dt = traj.GetDuration()

q_resolutions = robot.GetActiveDOFResolutions()

# Smallest CSpace step at which to give up
min_step = min(robot.GetActiveDOFResolutions()) / 100.
ik_options = openravepy.IkFilterOptions.CheckEnvCollisions
Expand Down Expand Up @@ -206,11 +213,14 @@ def PlanWorkspacePath(self, robot, traj, timelimit=5.0,
infeasible_step = True
if qnew is not None:
# Found an IK
step = abs(qnew - qcurr)
if (max(step) < min_step) and qtraj:
steps = abs(qnew - qcurr) / q_resolutions;
norm = numpy.linalg.norm(steps, ord=norm_order)

if (norm < min_step) and qtraj:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this dramatically changed the scaling on min_step since the norm is now scaled by DOF resolution. Can you adjust the value of that constant accordingly?

raise PlanningError('Not making progress.')
infeasible_step = \
any(step > robot.GetActiveDOFResolutions())

infeasible_step = norm > 1.0

if infeasible_step:
# Backtrack and try half the step
dt = dt / 2.0
Expand Down