@@ -55,7 +55,7 @@ def __init__(self, sim, owd_namespace,
55
55
if sim :
56
56
from prpy .simulation import ServoSimulator
57
57
self .servo_simulator = ServoSimulator (
58
- self , rate = 20 , watchdog_timeout = 0.1 )
58
+ self , rate = 20 , watchdog_timeout = 0.1 )
59
59
60
60
def CloneBindings (self , parent ):
61
61
Manipulator .CloneBindings (self , parent )
@@ -90,6 +90,30 @@ def SetStiffness(manipulator, stiffness):
90
90
if not manipulator .simulated :
91
91
manipulator .controller .SendCommand ('SetStiffness {0:f}' .format (stiffness ))
92
92
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
+
93
117
def Servo (manipulator , velocities ):
94
118
"""Servo with a vector of instantaneous joint velocities.
95
119
@param velocities joint velocities, in radians per second
@@ -261,19 +285,20 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
261
285
traj = manipulator .PlanToEndEffectorOffset (direction , distance , max_distance = max_distance ,
262
286
execute = False , ** kw_args )
263
287
264
- collided_with_obj = False
288
+ collided_with_obj = False
265
289
try :
266
290
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
+
267
295
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
+
271
298
for (ignore_col_with , oldstate ) in zip (ignore_collisions , ignore_col_obj_oldstate ):
272
299
ignore_col_with .Enable (oldstate )
273
300
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
+
277
302
traj_duration = traj .GetDuration ()
278
303
delta_t = 0.01
279
304
@@ -313,8 +338,6 @@ def MoveUntilTouch(manipulator, direction, distance, max_distance=float('+inf'),
313
338
new_traj .Insert (int (waypoint_ind ), waypoint , path_config_spec )
314
339
waypoint_ind += 1
315
340
316
- #new_traj = manipulator.GetRobot().BlendTrajectory(new_traj)
317
- #new_traj = manipulator.GetRobot().RetimeTrajectory(new_traj)
318
341
manipulator .GetRobot ().ExecuteTrajectory (new_traj , execute = True , retime = True , blend = True )
319
342
320
343
return collided_with_obj
0 commit comments