Skip to content

Commit db1b40c

Browse files
committed
Merge pull request #173 from sjavdani/moveuntiltouch_sim
Fix for simulation of move until touch.
2 parents ca6c003 + a6eefa1 commit db1b40c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/prpy/base/wam.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
254254
@param max_distance maximum distance in meters
255255
@param max_force maximum force in Newtons
256256
@param max_torque maximum torque in Newton-Meters
257-
@param execute optionally execute the trajectory
258-
@param ignore_collisions collisions with these objects are ignored in simulation
257+
@param ignore_collisions collisions with these objects are ignored when planning the path, e.g. the object you think you will touch
259258
@param **kw_args planner parameters
260259
@return felt_force flag indicating whether we felt a force.
261260
"""
@@ -299,21 +298,14 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
299298
ignore_col_with.Enable(oldstate)
300299
else:
301300

301+
traj = manipulator.GetRobot().PostProcessPath(traj)
302+
302303
traj_duration = traj.GetDuration()
303304
delta_t = 0.01
304305

305306
traj_config_spec = traj.GetConfigurationSpecification()
306-
traj_angle_group = traj_config_spec.GetGroupFromName('joint_values')
307-
path_config_spec = openravepy.ConfigurationSpecification()
308-
# path_config_spec.AddDeltaTimeGroup()
309-
path_config_spec.AddGroup(traj_angle_group.name, traj_angle_group.dof, '')
310-
# path_config_spec.AddDerivativeGroups(1, False);
311-
# path_config_spec.AddDerivativeGroups(2, False);
312-
# path_config_spec.AddGroup('owd_blend_radius', 1, 'next')
313-
path_config_spec.ResetGroupOffsets()
314-
315307
new_traj = openravepy.RaveCreateTrajectory(manipulator.GetRobot().GetEnv(), '')
316-
new_traj.Init(path_config_spec)
308+
new_traj.Init(traj_config_spec)
317309

318310
for (ignore_col_with, oldstate) in zip(ignore_collisions, ignore_col_obj_oldstate):
319311
ignore_col_with.Enable(oldstate)
@@ -326,19 +318,26 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
326318

327319
waypoint = traj_config_spec.ExtractJointValues(traj_sample, manipulator.GetRobot(), manipulator.GetArmIndices())
328320
manipulator.SetDOFValues(waypoint)
329-
#if manipulator.GetRobot().GetEnv().CheckCollision(manipulator.GetRobot()):
321+
322+
# Check collision with each body on the robot
330323
for body in manipulator.GetRobot().GetEnv().GetBodies():
331324
if manipulator.GetRobot().GetEnv().CheckCollision(manipulator.GetRobot(), body):
332325
collided_with_obj = True
333326
break
334327
if collided_with_obj:
335328
break
336329
else:
337-
#waypoint = numpy.append(waypoint,t)
338-
new_traj.Insert(int(waypoint_ind), waypoint, path_config_spec)
330+
#set timing on new sampled waypoint
331+
if waypoint_ind == 0:
332+
traj_config_spec.InsertDeltaTime(traj_sample, 0.)
333+
else:
334+
traj_config_spec.InsertDeltaTime(traj_sample, delta_t)
335+
336+
new_traj.Insert(int(waypoint_ind), traj_sample)
339337
waypoint_ind += 1
340338

341-
manipulator.GetRobot().ExecuteTrajectory(new_traj, execute = True, retime=True, blend=True)
339+
340+
manipulator.GetRobot().ExecuteTrajectory(new_traj)
342341

343342
return collided_with_obj
344343
# Trajectory is aborted by OWD because we felt a force.

0 commit comments

Comments
 (0)