Skip to content

Commit ca6c003

Browse files
committed
Merge pull request #171 from personalrobotics/bugfix/ExecutionOptions
Fixed MoveUntilTouch on HERB.
2 parents a28c91c + 04bbce7 commit ca6c003

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

src/prpy/base/robot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,13 @@ def do_postprocess():
340340
cloned_robot, shortcut_path, defer=False,
341341
**smoothing_options)
342342

343-
return CopyTrajectory(traj, env=self.GetEnv())
343+
# Copy the trajectory into the output environment.
344+
output_traj = CopyTrajectory(traj, env=self.GetEnv())
345+
346+
# Copy meta-data from the path to the output trajectory.
347+
output_traj.SetDescription(path.GetDescription())
348+
349+
return output_traj
344350

345351
if defer is True:
346352
from trollius.executor import get_default_executor

src/prpy/base/wam.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, sim, owd_namespace,
5555
if sim:
5656
from prpy.simulation import ServoSimulator
5757
self.servo_simulator = ServoSimulator(
58-
self, rate=20, watchdog_timeout=0.1)
58+
self, rate=20, watchdog_timeout=0.1)
5959

6060
def CloneBindings(self, parent):
6161
Manipulator.CloneBindings(self, parent)
@@ -90,6 +90,30 @@ def SetStiffness(manipulator, stiffness):
9090
if not manipulator.simulated:
9191
manipulator.controller.SendCommand('SetStiffness {0:f}'.format(stiffness))
9292

93+
def SetTrajectoryExecutionOptions(self, traj, stop_on_stall=False,
94+
stop_on_ft=False, force_magnitude=None, force_direction=None,
95+
torque=None):
96+
"""Set OWD's trajectory execution options on trajectory.
97+
@param stop_on_stall aborts the trajectory if the arm stalls
98+
@param stop_on_ft aborts the trajectory if the force/torque
99+
sensor reports a force or torque that exceeds
100+
threshold specified by the force_magnitude,
101+
force_direction, and torque options
102+
@param force_magnitude force threshold value, in Newtons
103+
@param force_direction unit vector in the force/torque coordinate
104+
frame, which is int he same orientation as the
105+
hand frame.
106+
@param torque vector of the three torques
107+
"""
108+
util.SetTrajectoryTags(traj, {
109+
'owd_options': {
110+
'stop_on_stall': bool(stop_on_stall),
111+
'stop_on_ft': bool(stop_on_ft),
112+
'force_magnitude': float(force_magnitude),
113+
'force_direction': list(force_direction),
114+
'torque': list(torque),
115+
}}, append=True)
116+
93117
def Servo(manipulator, velocities):
94118
"""Servo with a vector of instantaneous joint velocities.
95119
@param velocities joint velocities, in radians per second
@@ -261,19 +285,20 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
261285
traj = manipulator.PlanToEndEffectorOffset(direction, distance, max_distance=max_distance,
262286
execute=False, **kw_args)
263287

264-
collided_with_obj = False
288+
collided_with_obj = False
265289
try:
266290
if not manipulator.simulated:
291+
manipulator.SetTrajectoryExecutionOptions(traj, stop_on_ft=True,
292+
force_direction=force_direction, force_magnitude=max_force,
293+
torque=max_torque)
294+
267295
manipulator.hand.TareForceTorqueSensor()
268-
#manipulator.GetRobot().ExecuteTrajectory(traj, execute=True, retime=True, blend=False)
269-
manipulator.GetRobot().ExecuteTrajectory(traj, execute=True, retime=True, blend=True, stop_on_ft=True,
270-
force_direction=force_direction, force_magnitude=max_force, torque=max_torque)
296+
manipulator.GetRobot().ExecutePath(traj)
297+
271298
for (ignore_col_with, oldstate) in zip(ignore_collisions, ignore_col_obj_oldstate):
272299
ignore_col_with.Enable(oldstate)
273300
else:
274-
traj = manipulator.GetRobot().BlendTrajectory(traj)
275-
traj = manipulator.GetRobot().RetimeTrajectory(traj, stop_on_ft=True, force_direction=force_direction,
276-
force_magnitude=max_force, torque=max_torque)
301+
277302
traj_duration = traj.GetDuration()
278303
delta_t = 0.01
279304

@@ -313,8 +338,6 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
313338
new_traj.Insert(int(waypoint_ind), waypoint, path_config_spec)
314339
waypoint_ind += 1
315340

316-
#new_traj = manipulator.GetRobot().BlendTrajectory(new_traj)
317-
#new_traj = manipulator.GetRobot().RetimeTrajectory(new_traj)
318341
manipulator.GetRobot().ExecuteTrajectory(new_traj, execute = True, retime=True, blend=True)
319342

320343
return collided_with_obj

0 commit comments

Comments
 (0)