SR Research Support Site
Macros | Functions
Online velocity and acceleration calculation

Macros

#define FIVE_SAMPLE_MODEL   1
 
#define NINE_SAMPLE_MODEL   2
 
#define SEVENTEEN_SAMPLE_MODEL   3
 
#define EL1000_TRACKER_MODEL   4
 

Functions

int eyelink_calculate_velocity_x_y (int slen, float xvel[2], float yvel[2], FSAMPLE *vel_sample)
 
int eyelink_calculate_velocity (int slen, float vel[2], FSAMPLE *vel_sample)
 
int eyelink_calculate_overallvelocity_and_acceleration (int slen, float vel[2], float acc[2], FSAMPLE *vel_sample)
 

Detailed Description

Function Documentation

int eyelink_calculate_overallvelocity_and_acceleration ( int  slen,
float  vel[2],
float  acc[2],
FSAMPLE vel_sample 
)

Calculates overall velocity and acceleration for left and right eyes separately.

Parameters
[in]slenSample model to use for velocity calculation. Acceptable models are FIVE_SAMPLE_MODEL, NINE_SAMPLE_MODEL, SEVENTEEN_SAMPLE_MODEL and EL1000_TRACKER_MODEL.
[out]velA float array of 2 to fill in the calculated velocity results. Upon return of this function, vel[0] will contain overall velocity for left eye and vel[1] will contain overall velocity for right eye. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity.
[out]accA float array of 2 to fill in the calculated acceleration results. Upon return of this function, acc[0] will contain overall acceleration for left eye and acc[1] will contain overall acceleration for right eye. If acceleration cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given acceleration.
[out]vel_sampleVelocity for sample. Expects a FSAMPLE structure to fill in the sample, the velocity is calculated for.
int eyelink_calculate_velocity ( int  slen,
float  vel[2],
FSAMPLE vel_sample 
)

Calculates overall velocity for left and right eyes separately.

Parameters
[in]slenSample model to use for velocity calculation. Acceptable models are FIVE_SAMPLE_MODEL, NINE_SAMPLE_MODEL, SEVENTEEN_SAMPLE_MODEL and EL1000_TRACKER_MODEL.
[out]velA float array of 2 to fill in the calculated results. Upon return of this function, vel[0] will contain overall velocity for left eye and vel[1] will contain overall velocity for right eye. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity.
[out]vel_sampleVelocity for sample. Expects a FSAMPLE structure to fill in the sample, the velocity is calculated for.
int eyelink_calculate_velocity_x_y ( int  slen,
float  xvel[2],
float  yvel[2],
FSAMPLE vel_sample 
)

Calculates left x velocity, left y velocity, right x velocity and right y velocity from queue of samples.

Parameters
[in]slenSample model to use for velocity calculation. Acceptable models are FIVE_SAMPLE_MODEL, NINE_SAMPLE_MODEL, SEVENTEEN_SAMPLE_MODEL and EL1000_TRACKER_MODEL.
[out]xvelLeft and right x velocity. Expects an array of 2 elements of floats. The array is filled with left and right velocity values. Upon return of this function xvel[0] contains the left x velocity data and xvel[1] contains right x velocity data. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity.
[out]yvelLeft and right y velocity. Expects an array of 2 elements of floats. The array is filled with left and right velocity values. Upon return of this function yvel[0] contains the left y velocity data and xvel[1] contains right y velocity data. If velocity cannot be calculated for any reason(eg. insufficient samples, no data) MISSING_DATA is filled for the given velocity.
[out]vel_sampleVelocity for sample. Expects a FSAMPLE structure to fill in the sample, the velocity is calculated for.

Example:

1 #include <stdio.h>
2 #include <core_expt.h>
3 
4 int main(int argc, char ** argv)
5 {
6  if(open_eyelink_connection(0)) // connect to tracker
7  {
8  return -1;
9  }
10 
11  eyecmd_printf("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS"); // tell the tracker to stuff the sample with
12  if(start_recording(0,0,1,0)) // start recording failed.
13  {
14  close_eyelink_connection();
15  return -1;
16  }
17 
18  if(!eyelink_wait_for_block_start(100, 1, 0)) // wait for block start
19  {
20  stop_recording();
21  close_eyelink_connection();
22  return -1;
23  }
24  else
25  {
26  UINT32 st = current_time();
27  while(current_time()-st<10000) // record for 10 seconds
28  {
29  FSAMPLE fs;
30  float xvel[2];
31  float yvel[2];
32  if(check_recording()!=0)
33  {
34  close_eyelink_connection();
35  return -4; // recording aborted.
36  }
37  eyelink_calculate_velocity_x_y(FIVE_SAMPLE_MODEL,xvel,yvel,&fs);
38  printf("%lu %f %f %f %f\n",fs.time,xvel[0],yvel[0], xvel[1], yvel[1]);
39  pump_delay(100); // we check the velocity every 100 ms.
40  }
41  stop_recording();
42  close_eyelink_connection();
43  return 0;
44  }
45 }

Copyright ©2002-2024, SR Research Ltd.