Skip to content

Commit 09b69a8

Browse files
Fixed move-to-start-pose speed for file playback
Added an initial pose to the trajectory calculated for file playback. In addition to calculating the amount of time required to move slowly to the initial pose, this change prevents potentially fast movements at the beginning of trajectory playback. Resolves Trac #11843
1 parent 01df198 commit 09b69a8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/joint_trajectory_file_playback.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def __init__(self):
110110
self._l_grip = FollowJointTrajectoryGoal()
111111
self._r_grip = FollowJointTrajectoryGoal()
112112

113+
# Timing offset to prevent gripper playback before trajectory has started
114+
self._trajectory_start_offset = rospy.Duration(0.0)
113115
#param namespace
114116
self._param_ns = '/rsdk_joint_trajectory_action_server/'
115117

@@ -228,7 +230,18 @@ def find_start_offset(pos):
228230
cmd, values = self._clean_line(values, joint_names)
229231
#find allowable time offset for move to start position
230232
if idx == 0:
233+
# Set the initial position to be the current pose.
234+
# This ensures we move slowly to the starting point of the
235+
# trajectory from the current pose - The user may have moved
236+
# arm since recording
237+
cur_cmd = [self._l_arm.joint_angle(jnt) for jnt in self._l_goal.trajectory.joint_names]
238+
self._add_point(cur_cmd, 'left', 0.0)
239+
cur_cmd = [self._r_arm.joint_angle(jnt) for jnt in self._r_goal.trajectory.joint_names]
240+
self._add_point(cur_cmd, 'right', 0.0)
231241
start_offset = find_start_offset(cmd)
242+
# Gripper playback won't start until the starting movement's
243+
# duration has passed, and the actual trajectory playback begins
244+
self._trajectory_start_offset = rospy.Duration(start_offset + values[0])
232245
#add a point for this set of commands with recorded time
233246
cur_cmd = [cmd[jnt] for jnt in self._l_goal.trajectory.joint_names]
234247
self._add_point(cur_cmd, 'left', values[0] + start_offset)
@@ -240,7 +253,10 @@ def find_start_offset(pos):
240253
self._add_point(cur_cmd, 'right_gripper', values[0] + start_offset)
241254

242255
def _feedback(self, data):
243-
if not self._get_trajectory_flag():
256+
# Test to see if the actual playback time has exceeded
257+
# the move-to-start-pose timing offset
258+
if (not self._get_trajectory_flag() and
259+
data.actual.time_from_start >= self._trajectory_start_offset):
244260
self._set_trajectory_flag(value=True)
245261

246262
def _set_trajectory_flag(self, value=False):

0 commit comments

Comments
 (0)