Skip to content

Commit aad7889

Browse files
Re #45 Sync arm and gripper trajectory playback
In RSDK 1.1.1, the amount of time required to move to the initial position for trajectory playback was not taken into account when calculating when to start gripper playback. By subtracting this amount of time from gripper playback start, we end up with synchronized (or nearly) gripper movements with respect to the robot's arm movements.
1 parent 085af63 commit aad7889

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/joint_trajectory_file_playback.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(self):
113113
# Timing offset to prevent gripper playback before trajectory has started
114114
self._slow_move_offset = 0.0
115115
self._trajectory_start_offset = rospy.Duration(0.0)
116+
self._trajectory_actual_offset = rospy.Duration(0.0)
116117

117118
#param namespace
118119
self._param_ns = '/rsdk_joint_trajectory_action_server/'
@@ -121,7 +122,7 @@ def __init__(self):
121122
self._gripper_rate = 20.0 # Hz
122123

123124
def _execute_gripper_commands(self):
124-
start_time = rospy.get_time()
125+
start_time = rospy.get_time() - self._trajectory_actual_offset.to_sec()
125126
r_cmd = self._r_grip.trajectory.points
126127
l_cmd = self._l_grip.trajectory.points
127128
pnt_times = [pnt.time_from_start.to_sec() for pnt in r_cmd]
@@ -261,6 +262,7 @@ def _feedback(self, data):
261262
if (not self._get_trajectory_flag() and
262263
data.actual.time_from_start >= self._trajectory_start_offset):
263264
self._set_trajectory_flag(value=True)
265+
self._trajectory_actual_offset = data.actual.time_from_start
264266

265267
def _set_trajectory_flag(self, value=False):
266268
with self._lock:

0 commit comments

Comments
 (0)