[IGSTK-Users] RequestAttachToTracker PHRQ error

Bérangère Giroud giroud.berangere at gmail.com
Fri Mar 18 13:56:30 EDT 2011


Hi,

I try to communicate with a polaris NDI. For that, I want to use IGSTK. I
take the example Testing\igstkPolarisTrackerTest.cxx and I have problem at
the command line trackerTool2->RequestAttachToTracker( tracker );  The
stream of the polaris is :

24589414713.185219  :    (INFO) 0. receive[10] RESETBE6F\x0D
24589414713.185768  :    (INFO) 1. command[10] INIT:E3A5\x0D
24589414713.286034  :    (INFO) 1. receive[9] OKAYA896\x0D
24589414713.286579  :    (INFO) 2. command[10] VER:065EE\x0D
24589414713.472214  :    (INFO) 2. receive[156] Polaris Control
Firmware\x0ANDI S/N: P4-01519\x0ACharacterization Date: 03/18/08\x0AFreeze
Tag: POLARIS Rev 015\x0AFreeze Date: 10/11/00\x0A(C) Northern Digital
Inc.\x0AD722\x0D
24589414713.472832  :    (INFO) 3. command[15] COMM:40000C075\x0D
24589414713.518955  :    (INFO) 3. receive[9] OKAYA896\x0D
24589414713.536888  :    (INFO) 4. command[24] PHRQ:*********1****A4C1\x0D
24589414713.558434  :    (INFO) 4. receive[12] ERROR016BC2\x0D

I don't understand why the tracker don't want to attach my tool.

I hope you can help me.
Thanks.

This is my entire code :

  igstk::RealTimeClock::Initialize();

  typedef igstk::Object::LoggerType     LoggerType;
  typedef itk::StdStreamLogOutput       LogOutputType;
  typedef igstk::TransformObserver      ObserverType;

  if( argc < 4 )
    {
    std::cerr << " Usage: " << argv[0] << "\t"
                            << "Logger_Output_filename "
                            << "Wireless_SROM_filename "
                            << "Port_Number"
                            << std::endl;
    return EXIT_FAILURE;
    }


  igstk::PolarisTrackerTool::Pointer tool =
igstk::PolarisTrackerTool::New();

  igstk::SerialCommunication::Pointer
                     serialComm = igstk::SerialCommunication::New();

  PolarisTrackerTestCommand::Pointer
                                my_command =
PolarisTrackerTestCommand::New();

  ObserverType::Pointer coordSystemAObserver = ObserverType::New();
  ObserverType::Pointer coordSystemAObserver2 = ObserverType::New();

  std::string filename = argv[1];
  std::cout << "Logger output saved here:\n";
  std::cout << filename << "\n";

  std::ofstream loggerFile;
  loggerFile.open( filename.c_str() );
  std::cout<<"filename.c_str "<<filename<<std::endl;
  LoggerType::Pointer   logger = LoggerType::New();
  LogOutputType::Pointer logOutput = LogOutputType::New();
  logOutput->SetStream( loggerFile );
  logger->AddLogOutput( logOutput );
  logger->SetPriorityLevel( itk::Logger::DEBUG);

  serialComm->AddObserver( itk::AnyEvent(), my_command);

  serialComm->SetLogger( logger );

  typedef igstk::SerialCommunication::PortNumberType PortNumberType;
  unsigned int portNumberIntegerValue = atoi(argv[3]);
  PortNumberType  polarisPortNumber =
PortNumberType(portNumberIntegerValue);
  serialComm->SetPortNumber( polarisPortNumber );
  serialComm->SetParity( igstk::SerialCommunication::NoParity );
  serialComm->SetBaudRate( igstk::SerialCommunication::BaudRate57600 );
  serialComm->SetDataBits( igstk::SerialCommunication::DataBits8 );
  serialComm->SetStopBits( igstk::SerialCommunication::StopBits1 );
  serialComm->SetHardwareHandshake( igstk::SerialCommunication::HandshakeOff
);

  serialComm->SetCaptureFileName( "RecordedStreamByPolarisTrackerTest.txt"
);
  serialComm->SetCapture( true );

  serialComm->OpenCommunication();

  igstk::PolarisTracker::Pointer  tracker;

  tracker = igstk::PolarisTracker::New();

  tracker->AddObserver( itk::AnyEvent(), my_command);

  tracker->SetLogger( logger );
  tracker->RequestSetFrequency(20);
  std::cout << "SetCommunication()" << std::endl;
  tracker->SetCommunication( serialComm );

  std::cout << "RequestOpen()" << std::endl;
  tracker->RequestOpen();

  typedef igstk::PolarisTrackerTool         TrackerToolType;
  typedef TrackerToolType::TransformType    TransformType;

  // instantiate and attach wireless tracker tool
  std::cout << "Instantiate the tracker tool: " << std::endl;
  TrackerToolType::Pointer trackerTool2 = TrackerToolType::New();
  trackerTool2->SetLogger( logger );
  //Select wireless tracker tool
  trackerTool2->RequestSelectWirelessTrackerTool();
  ////Set the port number
  unsigned int portNumber2 = atoi(argv[3]);
  //trackerTool2->RequestSetPortNumber( portNumber2 );
  //Set the SROM file
  std::string romFile = argv[2];
  std::cout << "SROM file: " << romFile << std::endl;
  trackerTool2->RequestSetSROMFileName( romFile );
 //Configure
  trackerTool2->RequestConfigure();
   trackerTool2->AddObserver( itk::AnyEvent(), my_command);
  //Attach to the tracker
  trackerTool2->RequestAttachToTracker( tracker );
  //Add observer to listen to events throw by the tracker tool
  coordSystemAObserver2->ObserveTransformEventsFrom( trackerTool2 );

  //start tracking
  tracker->RequestStartTracking();

  typedef igstk::Transform            TransformType;
  typedef ::itk::Vector<double, 3>    VectorType;
  typedef ::itk::Versor<double>       VersorType;


  for(unsigned int i=0; i<100; i++)
    {
    igstk::PulseGenerator::CheckTimeouts();

    TransformType             transform;
    VectorType                position;

 /*   coordSystemAObserver->Clear();
    trackerTool->RequestGetTransformToParent();
    if (coordSystemAObserver->GotTransform())
      {
      transform = coordSystemAObserver->GetTransform();
      if ( transform.IsValidNow() )
        {
        position = transform.GetTranslation();
        std::cout << "Trackertool :"
                << trackerTool->GetTrackerToolIdentifier()
                << "\t\t  Position = (" << position[0]
                << "," << position[1] << "," << position[2]
                << ")" << std::endl;
        }
      }*/

    coordSystemAObserver2->Clear();
    trackerTool2->RequestGetTransformToParent();
    if (coordSystemAObserver2->GotTransform())
      {
      transform = coordSystemAObserver2->GetTransform();
      if ( transform.IsValidNow() )
        {
        position = transform.GetTranslation();
        std::cout << "Trackertool2:"
                << trackerTool2->GetTrackerToolIdentifier()
                << "\t\t  Position = (" << position[0]
                << "," << position[1] << "," << position[2]
                << ")" << std::endl;
        }
      }
    }

  std::cout << "RequestStopTracking()" << std::endl;
  tracker->RequestStopTracking();

  std::cout << "RequestClose()" << std::endl;
  tracker->RequestClose();

  std::cout << "CloseCommunication()" << std::endl;
  serialComm->CloseCommunication();


-- 
Bérangère Giroud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20110318/43f9ccde/attachment.html>


More information about the IGSTK-Users mailing list