Example of C / C++ Code using the Atracsys Tracking Library API

// Create a LED callback. This routine is called each time the
// easyTrack device acquires a new LED position
void myLedCallback (etkDevice* pDevice, unsigned uLEDID, double* adVector3)
  {
    // Retrieve 3D position of the LED
    if (adVector3)
      printf ("Led: %u, Position (%lf, %lf, %lf)\n", uLEDID,
      adVector3 [0], adVector3 [1], adVector3 [2]);
    else
      printf ("Invalid LED position");
  }


// The following POSIX thread will regularily check
// and process new data coming from the easyTrack device
void* processingThread (void* arg)
  {
    while (!siQuitThread)
      if (etkProcessNextDataFrames (handle, 50) != 50)
        etkSleep (100);
    pthread_exit (NULL);
  }


// Main program
void main ()
  {
    // Open easyTrack library
    etkHandle handle = etkOpen ();

    // Set LED callback
    etkSetLedCallback (handle, myLedCallback);

    // Initialize library with default values
    etkInitialize (handle, NULL);

    // Get default device
    etkDevice device = getDevice (handle, ETK_MASTER);

    // Start the POSIX thread
    pthread_t* pThread = new pthread_t;
    (void) pthread_create (pThread, NULL, processingThread, NULL);

    // Acquires LED position from marker 1 and marker 3
    etkAcquireContinuously (device, ETK_MARKER1 | ETK_MARKER3, 0);

    // Wait until QUIT ...

    // Close library
    etkClose (handle);
  }
"Be ready in an hour". easyTrack sample code to acquire LEDs positions from markers one and three and display their position in the console window.

Back to FAQ



Home | About Us | Contact Us | Legal
© 2005-2009 Atracsys LLC. All rights reserved.