bool IntersenseAPIStandalone::open(const std::string& dsoLocation)
{
   if (!mActive)
   {
      int port_num = convertPort(mPort); 
      mHandle = ISD_OpenTracker((Hwnd) NULL, port_num, true, true,
                                dsoLocation.c_str());
      if (-1 != mHandle) 
      {
         mActive = true;
         const Bool got_config = ISD_GetTrackerConfig(mHandle, &mInfo, true);

         if ( got_config )
         {
/*
            if ( tracker_info.LibVersion < 3.58 )
            {
               vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL)
                  << clrOutBOLD(clrYELLOW, "WARNING")
                  << ": This driver only works with version 3.58 or newer of "
                  << "the InterSense Library." << std::endl << vprDEBUG_FLUSH;
               vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
                  << "Version " << tracker_info.LibVersion << " was loaded.\n"
                  << vprDEBUG_FLUSH;
            }
*/

            printTrackerInfo(mInfo);
         }
      }
   }

   return mActive;
}
Exemplo n.º 2
0
ISTracker::ISTracker(int TrackerPortNr)
    : m_bTrackerFound(false)
{
    //    WORD station = 1;
    Bool verbose = true;

    /* Detect first tracker. If you have more than one InterSense device and
      would like to have a specific tracker, connected to a known port,
      initialized first, then enter the port number instead of 0. Otherwise,
      tracker connected to the rs232 port with lower number is found first */

    handle = ISD_OpenTracker((Hwnd)NULL, TrackerPortNr, FALSE, verbose);

    /* Check value of handle to see if tracker was located */
    if (handle < 1)
    {
        printf("Failed to detect InterSense tracking device\n");
        return;
    }

    /* Get tracker configuration info */
    ISD_GetTrackerConfig(handle, &Tracker, verbose);

    /* Clear station configuration info to make sure GetAnalogData and other flags are FALSE */
    memset((void *)Station, 0, sizeof(Station));

    /* General procedure for changing any setting is to first retrieve current
      configuration, make the change, and then apply it. Calling
      ISD_GetStationConfig is important because you only want to change
      some of the settings, leaving the rest unchanged. */
    /*
       if( Tracker.TrackerType == ISD_PRECISION_SERIES )
       {
           for( station = 1; station <= 4; station++ )
           {
               // fill ISD_STATION_INFO_TYPE structure with current station configuration
               if( !ISD_GetStationConfig( handle,
                   &Station[station-1], station, verbose )) break;

               if( CAMERA_TRACKER && Tracker.TrackerModel == ISD_IS900 )
               {
   Station[station-1].GetCameraData = TRUE;

   // apply new configuration
   if( !ISD_SetStationConfig( handle,
   &Station[station-1], station, verbose )) break;
   }
   }
   }
   */
    // setting angleformat to Euler
    if (ISD_GetStationConfig(handle, &Station[0], 0, verbose))
    {
        Station[0].AngleFormat = ISD_EULER;
        ISD_SetStationConfig(handle, &Station[0], 0, verbose);
    }

    m_bTrackerFound = true;
}
Exemplo n.º 3
0
void vrpn_Tracker_InterSense::reset()
{
#ifdef  VRPN_INCLUDE_INTERSENSE
  char errStr[1024]; 
  int i;
  
  m_Handle = ISD_OpenTracker(NULL,m_CommPort,FALSE,FALSE);

  if(m_Handle == -1)
  {
    sprintf(errStr,"InterSense: Failed to open tracker '%s' on COM%d: ISD_OpenTracker returned -1",d_servicename,m_CommPort);
    fprintf(stderr,errStr);
    vrpn_gettimeofday(&timestamp, NULL);
	VRPN_MSG_ERROR(errStr);

    status = vrpn_TRACKER_FAIL;
  }
  else 
  {

    //--------------------------------------------------------------------
    // Now that the tracker has given a valid status report, set all of
    // the parameters the way we want them. We rely on power-up setting
    // based on the receiver select switches to turn on the receivers that
    // the user wants.
    //--------------------------------------------------------------------

    // Set output format for each of the possible stations.

    for (i = 0; i < ISD_MAX_STATIONS; i++) {
       if (set_sensor_output_format(i)) {
		   return;
       }
    }

    // Send the additional reset commands, if any, to the tracker.
    // These commands come in lines, with character \015 ending each
    // line. 
    if (strlen(add_reset_cmd) > 0) {
		printf("  Intersense writing extended reset commands...\n");
		if(!ISD_SendScript(m_Handle,add_reset_cmd))
	    {
			sprintf(errStr,"Warning: Your tracker failed executing the additional command string. ");
			vrpn_gettimeofday(&timestamp, NULL);
			VRPN_MSG_WARNING(errStr);
		}
	}
  
    // If we are using the IS-900 timestamps, clear the timer on the device and
    // store the time when we cleared it.  First, drain any characters in the output
    // buffer to ensure we're sending right away.  Then, send the reset command and
    // store the time that we sent it, plus the estimated time for the characters to
    // get across the serial line to the device at the current baud rate.
    // Set time units to milliseconds (MT) and reset the time (MZ).
    if (do_is900_timestamps) {
    	char	clear_timestamp_cmd[] = "MT\015MZ\015";
		if(!ISD_SendScript(m_Handle,clear_timestamp_cmd))
	    {
			sprintf(errStr,"Warning: Your tracker failed executing the additional command string. ");
			vrpn_gettimeofday(&timestamp, NULL);
			VRPN_MSG_WARNING(errStr);
		}

		vrpn_gettimeofday(&is900_zerotime, NULL);
    }

    // Done with reset.
    vrpn_gettimeofday(&timestamp, NULL);	// Set watchdog now
    VRPN_MSG_WARNING("Reset Completed (this is good)");

    status = vrpn_TRACKER_SYNCING;	// We're trying for a new reading
  }
#else
  fprintf(stderr,"Intersense library not compiled into this version.  Use Fastrak driver for IS-600/900 or recompile with VRPN_INCLUDE_INTERSENSE defined\n");
  status = vrpn_TRACKER_FAIL;
#endif
}
Exemplo n.º 4
0
vrpn_Tracker_InterSense::vrpn_Tracker_InterSense(const char *name, 
                                         vrpn_Connection *c,
                                         int commPort, const char *additional_reset_commands, 
										 int is900_timestamps, int reset_at_start) :
vrpn_Tracker(name,c), do_is900_timestamps(is900_timestamps), 
m_reset_at_start(reset_at_start)
{
#ifdef  VRPN_INCLUDE_INTERSENSE
  char errStr[1024];
  int i;

  register_server_handlers();

	if (additional_reset_commands == NULL) {
		sprintf(add_reset_cmd, "");
	} else {
		vrpn_strcpy(add_reset_cmd, additional_reset_commands);
	}

	// Initially, set to no buttons or analogs on the stations.  The
	// methods to add buttons and analogs must be called to add them.
	for (i = 0; i < ISD_MAX_STATIONS; i++) {
	    is900_buttons[i] = NULL;
	    is900_analogs[i] = NULL;
	}

  m_CommPort = commPort;
  m_Handle = ISD_OpenTracker(NULL, commPort, FALSE, FALSE);

  if(m_Handle == -1)
  {
    sprintf(errStr,"Failed to open tracker '%s' on COM%d: ISLIB_OpenTracker returned -1",name,commPort);
    status = vrpn_TRACKER_FAIL;
    return;
  }

  //  ISD_TRACKER_INFO_TYPE trackerInfo;

  ISD_GetTrackerConfig(m_Handle,&m_TrackerInfo,FALSE);

  for (i = 0; i < ISD_MAX_STATIONS; i++) {
       if (set_sensor_output_format(i)) {
		    sprintf(errStr,"Failed to reset sensor %d on tracker '%s' on COM%d",i, name,commPort);
			status = vrpn_TRACKER_FAIL;
     		return;
       }
  }


  //what is the update rate of this tracker?
  //we might want to set the update rate of the mainloop to based on this value.
  //for now we just print it out.
  getTrackerInfo(errStr);
  vrpn_gettimeofday(&timestamp, NULL);
  VRPN_MSG_INFO(errStr);
  fprintf(stderr,errStr);	
  
  status =   vrpn_TRACKER_SYNCING;
#else
  fprintf(stderr,"Intersense library not compiled into this version.  Use Fastrak driver for IS-600/900 or recompile with VRPN_INCLUDE_INTERSENSE defined\n");
  status = vrpn_TRACKER_FAIL;
#endif
}
Exemplo n.º 5
0
ISenseDirect::ISenseDirect(
        const Array<std::string>     &trackerEventNames,
        const double                 &trackerUnitsToRoomUnitsScale,
        const CoordinateFrame        &deviceToRoom,
        const Array<CoordinateFrame> &propToTracker,
        const Array<CoordinateFrame> &finalOffset,
        const Array< Array<std::string> > &buttonEventNames
        )
{
  _tEventNames = trackerEventNames;
  _bEventNames = buttonEventNames;
  _trackerUnitsToRoomUnitsScale = trackerUnitsToRoomUnitsScale;
  _deviceToRoom = deviceToRoom;
  _propToTracker = propToTracker;
  _finalOffset = finalOffset;

  for (int i=0;i<ISD_MAX_STATIONS;i++) {
    for (int j=0;j<ISD_MAX_BUTTONS;j++) {
      _btnStatus[i][j] = 0;
    }
  }


  // Detect first tracker. If you have more than one InterSense device and
  // would like to have a specific tracker, connected to a known port, 
  // initialized first, then enter the port number instead of 0. Otherwise, 
  // tracker connected to the rs232 port with lower number is found first 
  _handle = ISD_OpenTracker((Hwnd)NULL, 0, FALSE, TRUE);
    
  // Check value of handle to see if tracker was located 
  if (_handle < 1) {
    printf("Failed to detect InterSense tracking device\n");
    exit(1);
  }


  // Get tracker configuration info 
  ISD_TRACKER_INFO_TYPE           Tracker;
  ISD_GetTrackerConfig( _handle, &Tracker, TRUE );
                
  ISD_HARDWARE_INFO_TYPE          hwInfo;
  memset((void *) &hwInfo, 0, sizeof(hwInfo));
  
  if ( ISD_GetSystemHardwareInfo( _handle, &hwInfo ) ) {
    if( hwInfo.Valid ) {
      _maxStations = hwInfo.Capability.MaxStations;
    }
  }

  // Clear station configuration info to make sure GetAnalogData and other flags are FALSE 
  memset((void *) _stationInfo, 0, sizeof(_stationInfo));

  // General procedure for changing any setting is to first retrieve current 
  // configuration, make the change, and then apply it. Calling 
  // ISD_GetStationConfig is important because you only want to change 
  // some of the settings, leaving the rest unchanged.   
  if ( Tracker.TrackerType == ISD_PRECISION_SERIES ) {
    for (int station = 1; station <= _maxStations; station++ ) {         
      // fill ISD_STATION_INFO_TYPE structure with current station configuration 
      if( !ISD_GetStationConfig( _handle, &_stationInfo[station-1], station, TRUE )) 
        break;
    }
  }
}