Exemple #1
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;
}
Exemple #2
0
int vrpn_Tracker_InterSense::set_sensor_output_format(int station)
{
  char errStr[1024];

		//Get the info about the station
        ISD_GetStationConfig(m_Handle,&m_StationInfo[station],station+1,0);

    	//ISD_ResetHeading(m_Handle,station+1); //Not sure if this is needed
		// [email protected] - 
		if (m_reset_at_start)
		  ISD_Boresight(m_Handle, station+1, true); // equivalent to ISD_ResetHeading for itrax, see isense.h


	    // First, try to set the orientation reporting format to quaternions if possible.
		// But, some models of intersense trackers (like the intertrax series) will only report
		// in euler angles

	    // Try to set the tracker to report in quaternion format
		// (to avoid gimbal lock)
		// [email protected] : Let's try, even if we are not a precision series
		// It seems that this is OK with Intertrax2, what would happen to old Intertrax ?
//		if (m_TrackerInfo.TrackerType == ISD_PRECISION_SERIES &&
		if (
			m_StationInfo[station].AngleFormat == ISD_EULER)
	    {
			m_StationInfo[station].AngleFormat = ISD_QUATERNION;
			if(!ISD_SetStationConfig(m_Handle,&m_StationInfo[station],station+1,FALSE))
		    {
				sprintf(errStr,"Warning: Your tracker doesn't seem to support the quaternion format - couldn't set station config for Station%d. ",station+1);
				vrpn_gettimeofday(&timestamp, NULL);
				VRPN_MSG_WARNING(errStr);

				m_StationInfo[station].AngleFormat = ISD_EULER;
			}
		}

		// do is900 special things
	    // IS900 states (timestamp, button, analog).
		if(m_TrackerInfo.TrackerModel == ISD_IS900) {
			if (do_is900_timestamps) {
				m_StationInfo[station].TimeStamped = TRUE;
				if(!ISD_SetStationConfig(m_Handle,&m_StationInfo[station],station+1,FALSE))
			    {
					sprintf(errStr,"Warning: Your tracker doesn't seem to support the IS900 timestamps - couldn't set station config for Station%d. ",station+1);
					vrpn_gettimeofday(&timestamp, NULL);
					VRPN_MSG_WARNING(errStr);
					m_StationInfo[station].TimeStamped = FALSE;
				}
			}

			if (is900_buttons[station] || is900_analogs[station]) {
				m_StationInfo[station].GetInputs = TRUE;
				if(!ISD_SetStationConfig(m_Handle,&m_StationInfo[station],station+1,FALSE))
			    {
					sprintf(errStr,"Warning: Your tracker doesn't seem to support the IS900 buttons/analogs - couldn't set station config for Station%d. ",station+1);
					vrpn_gettimeofday(&timestamp, NULL);
					VRPN_MSG_WARNING(errStr);
					m_StationInfo[station].GetInputs = FALSE;
				}
			}
		}
		return 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;
    }
  }
}