def calculate_time_offset_from_signals(times_A, signal_A,
                                       times_B, signal_B,
                                       plot=False, block=True):
  """ Calculates the time offset between signal A and signal B. """
  convoluted_signals = signal.correlate(signal_B, signal_A)
  dt_A = np.mean(np.diff(times_A))
  offset_indices = np.arange(-len(signal_A) + 1, len(signal_B))
  max_index = np.argmax(convoluted_signals)
  offset_index = offset_indices[max_index]
  time_offset = dt_A * offset_index + times_B[0] - times_A[0]
  if plot:
    plot_results(times_A, times_B, signal_A, signal_B, convoluted_signals,
                 time_offset, block=block)
  return time_offset
 Calculates the time offset between signal A and signal B. 
hand_eye_calibration/python/hand_eye_calibration/time_alignment.py