コード例 #1
0
ファイル: poapi.c プロジェクト: Fperdreau/Poapi
int main(){
	// Function to retrieve OAPI version
	size_t len = LEN;
	size_t read;
	char *line = malloc(len);
	assert(line);
	// return variables
	char s0[1024];
	int i0;
	int nFrameOld = -1;

	
	while ((read = getline(&line, &len, stdin)) != -1) {
		//fprintf(stderr, "INFO: Retrieved line of length %zu (including NULL): %s", read, line);
		if (cmp(line, "OAPIGetVersionString")){
			i0 = OAPIGetVersionString(s0, len);
			printf("'%s'\n", s0);
		} else if (cmp(line, "OptoGetLastError")){
			i0 = OptoGetLastError(s0, len);
			printf("'%s'\n", s0);
		} else if (cmp(line, "OptotrakGetErrorString")){
			i0 = OptotrakGetErrorString(s0, len);
			printf("'%s'\n", s0);
		} else if (cmp(line, "OptoGetExtendedErrorCode")){
			i0 = OptoGetExtendedErrorCode();
			printf("%d\n", i0);
		} else if (cmp(line, "TransputerLoadSystem")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			i0 = TransputerLoadSystem(s);
			//i0 = TransputerLoadSystem("/opt/NDIoapi/ndigital/realtime/system.nif");
			printf("%d\n", i0);
		} else if (cmp(line, "TransputerInitializeSystem")){
			i0 = TransputerInitializeSystem(OPTO_LOG_ERRORS_FLAG);
			printf("%d\n", i0);
		} else if (cmp(line, "TransputerShutdownSystem")){
			i0 = TransputerShutdownSystem();
			printf("%d\n", i0);
		} else if (cmp(line, "TransputerDetermineSystemCfg")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			i0 = TransputerDetermineSystemCfg(s);
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakLoadCameraParameters")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			OptotrakLoadCameraParameters(s);
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakLoadAutoScale")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			OptotrakLoadAutoScale(s);
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakLockTemperatures")){
			i0 = OptotrakLockTemperatures();
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakSetCollectionFile")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			OptotrakSetCollectionFile(s);
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakSetupCollectionFromFile")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\""); // may be null
			OptotrakSetupCollectionFromFile(s);
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakSetupCollection")){
			float fFrameFrequency, fMarkerFrequency;
			int nThreshold, nMinimumGain, nStreamData;
			float fDutyCycle, fVoltage, fCollectionTime, fPreTriggerTime;
			int nFlags;
			
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			int i = sscanf(s, "%d, %f, %f, %d, %d, %d, %f, %f, %f, %f, %d", 
				&nMarkers, 
				&fFrameFrequency, &fMarkerFrequency,
				&nThreshold, &nMinimumGain, &nStreamData,
				&fDutyCycle, &fVoltage, &fCollectionTime, &fPreTriggerTime,
				&nFlags);
			if(i==11){
				i0 = OptotrakSetupCollection(nMarkers, 
					fFrameFrequency, fMarkerFrequency, 
					nThreshold, nMinimumGain, nStreamData,
					fDutyCycle, fVoltage, fCollectionTime, fPreTriggerTime, 
					nFlags);
				printf("%d\n", i0);
				
				allocSpace(nMarkers);
			} else
				printf("ERROR: %d arguments read (11 expected)\n", i);
		} else if (cmp(line, "OptotrakActivateMarkers")){
			i0 = OptotrakActivateMarkers();
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakDeActivateMarkers")){
			i0 = OptotrakDeActivateMarkers();
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakGetStatus")){
			int nNumSensors, nNumOdaus, nNumRigidBodies, nMarkers;
			float fFrameFrequency, fMarkerFrequency;
			int nThreshold, nMinimumGain, nStreamData;
			float fDutyCycle, fVoltage, fCollectionTime, fPreTriggerTime;
			int nFlags;
			i0 = OptotrakGetStatus(&nNumSensors, &nNumOdaus, &nNumRigidBodies, &nMarkers,
				&fFrameFrequency, &fMarkerFrequency,
				&nThreshold, &nMinimumGain, &nStreamData, 
				&fDutyCycle, &fVoltage, &fCollectionTime, &fPreTriggerTime,
				&nFlags);
			printf("(%d, %d, %d, %d, %f, %f, %d, %d, %d, %f, %f, %f, %f, 0x%x)\n", 
				nNumSensors, nNumOdaus, nNumRigidBodies, nMarkers,
				fFrameFrequency, fMarkerFrequency,
				nThreshold, nMinimumGain, nStreamData, 
				fDutyCycle, fVoltage, fCollectionTime, fPreTriggerTime,
				nFlags);
		} else if (cmp(line, "OptotrakSetStroberPortTable")){
			int nPort1, nPort2, nPort3, nPort4;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %d, %d, %d", &nPort1, &nPort2, &nPort3, &nPort4) == 4){
				i0 = OptotrakSetStroberPortTable(nPort1, nPort2, nPort3, nPort4);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 4 arguments\n");
		} else if (cmp(line, "OptotrakSaveCollectionToFile")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\"");
			if (s)
				i0 = OptotrakSaveCollectionToFile(s);
			else
				i0 = OptotrakSaveCollectionToFile("");
			printf("%d\n", i0);
		} else if (cmp(line, "OptotrakSetCameraParameters")){
			int nMarkerType, nWaveLength, nModelType;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %d, %d", &nMarkerType, &nWaveLength, &nModelType) == 3){
				i0 = OptotrakSetCameraParameters(nMarkerType, nWaveLength, nModelType);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 3 arguments\n");
		} else if (cmp(line, "OptotrakGetCameraParameterStatus")){
			int curMarkerType, nCurWaveLength, nCurModelType;
			char szStatus[len];
			i0 = OptotrakGetCameraParameterStatus(&curMarkerType, &nCurWaveLength, &nCurModelType, szStatus, len);
			printf("(%d, %d, %d, '%s')\n", curMarkerType, nCurWaveLength, nCurModelType, szStatus);
		} else if (cmp(line, "OdauSaveCollectionToFile")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\"");
			if (s){
				i0 = OptotrakSaveCollectionToFile(s);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading filename\n");
		} else if (cmp(line, "OdauSetupCollectionFromFile")){
			strtok(line, "\"");
			char* s = strtok(NULL, "\"");
			if (s){
				i0 = OdauSetupCollectionFromFile(s);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading filename\n");
		} else if (cmp(line, "OdauSetTimer")){
			//int OdauSetTimer( int nOdauId, unsigned uTimer, unsigned uMode, unsigned long ulVal );
			int nOdauId;
			unsigned uTimer, uMode;
			unsigned long ulVal;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %u, %u, %lu", &nOdauId, &uTimer, &uMode, &ulVal) == 4){
				i0 = OdauSetTimer(ODAU1+nOdauId-1, uMode, uTimer, ulVal);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 4 arguments\n");
		} else if (cmp(line, "OdauSetAnalogOutputs")){
			//int OdauSetAnalogOutputs( int nOdauId, float *pfVoltage1, float *pfVoltage2, unsigned uChangeMask );
			int nOdauId; // 1-4 -> ODAU1-ODAU4
			float fVoltage1;
			float fVoltage2;
			unsigned uChangeMask;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %f, %f, %u", &nOdauId, &fVoltage1, &fVoltage2, &uChangeMask) == 4){
				i0 = OdauSetAnalogOutputs(ODAU1+nOdauId-1, &fVoltage1, &fVoltage2, uChangeMask);
				printf("(%f, %f)\n", fVoltage1, fVoltage1);
			} else
				printf("ERROR: reading 4 arguments\n");
		} else if (cmp(line, "OdauSetDigitalOutputs")){
			//int OdauSetDigitalOutputs( int nOdauId, unsigned *puDigitalOut, unsigned uUpdateMask );
			int nOdauId; // 1-4 -> ODAU1-ODAU4
			unsigned uDigitalOut, uUpdateMask;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %u, %u", &nOdauId, &uDigitalOut, &uUpdateMask) == 4){
				i0 = OdauSetDigitalOutputs(ODAU1+nOdauId-1, &uDigitalOut, uUpdateMask);
				printf("0x%x\n", uDigitalOut);
			} else
				printf("ERROR: reading 3 arguments\n");
		} else if (cmp(line, "OdauSetupCollection")){
			//OdauSetupCollection( int nOdauId, int nChannels, int nGain, int nDigitalMode, float fFrameFreq, float fScanFreq, int nStreamData, float fCollectionTime, float fPreTriggerTime, unsigned uFlags );
			int nOdauId, nChannels, nGain, nDigitalMode;
			float fFrameFreq, fScanFreq;
			int nStreamData;
			float fCollectionTime, fPreTriggerTime;
			unsigned uFlags;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %d, %d, %d, %f, %f, %d, %f, %f, %u", 
					&nOdauId, &nChannels, &nGain, &nDigitalMode, 
					&fFrameFreq, &fScanFreq, &nStreamData,
					&fCollectionTime, &fPreTriggerTime, &uFlags) == 10){
				i0 = OdauSetupCollection(ODAU1+nOdauId-1, nChannels, nGain, nDigitalMode, 
					fFrameFreq, fScanFreq, nStreamData,
					fCollectionTime, fPreTriggerTime, uFlags);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 10 arguments\n");
		} else if (cmp(line, "OptotrakStopCollection")){
			i0 = OptotrakStopCollection();
			printf("%d\n", i0);
		} else if (cmp(line, "OdauGetStatus")){
			 //int OdauGetStatus( int nOdauId, int *pnChannels, int *pnGain, int *pnDigitalMode, float *pfFrameFrequency, float *pfScanFrequency, int *pnStreamData, float *pfCollectionTime, float *pfPreTriggerTime, unsigned  *puCollFlags, int *pnFlags );
			int nOdauId, nChannels, nGain, nDigitalMode;
			float fFrameFrequency, fScanFrequency;
			int nStreamData;
			float fCollectionTime, fPreTriggerTime;
			unsigned  uCollFlags;
			int nFlags;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d", &nOdauId) == 1){
				i0 = OdauGetStatus(ODAU1+nOdauId-1, &nChannels, &nGain, &nDigitalMode, 
					&fFrameFrequency, &fScanFrequency, &nStreamData, &fCollectionTime, &fPreTriggerTime, 
					&uCollFlags, &nFlags);
				printf("(%d, %d, %d, %f, %f, %d, %f, %f, 0x%04x, %d)\n", 
					nChannels, nGain, nDigitalMode, 
					fFrameFrequency, fScanFrequency, nStreamData, fCollectionTime, fPreTriggerTime, 
					uCollFlags, nFlags);
			} else
				printf("ERROR: reading argument\n");
		} else if (cmp(line, "RigidBodyAddFromFile")){
			int nRigidBodyId, nStartMarker;
			char szRigFile[len];
			int nFlags;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %d, %s, %d", &nRigidBodyId, &nStartMarker, szRigFile, &nFlags) != 4){
				i0 = RigidBodyAddFromFile(nRigidBodyId, nStartMarker, szRigFile, nFlags);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 4 arguments\n");
		} else if (cmp(line, "RigidBodyAdd")){
			//int ( int nRigidBodyId, int nStartMarker, int nNumMarkers, float *pRigidCoordinates, float *pNormalCoordinates, int nFlags );
			int nRigidBodyId, nStartMarker, nNumMarkers;
			float *rigidCoordinates, *normalCoordinates;
			int nFlags;
			char* s = strtok(line, "(");
			
			if(s && sscanf(line+strlen(s)+1, "%d, %d, %d", &nRigidBodyId, &nStartMarker, &nNumMarkers)==3){
				rigidCoordinates = calloc(3*nNumMarkers, sizeof(float));
				normalCoordinates = calloc(3*nNumMarkers, sizeof(float));
				s = strtok(NULL, "[("); // up to first list/tuple
				if(!s){
					printf("ERROR: reading rigid values\n");
					goto end;
				}
				for(int i=0; i<3*nNumMarkers; i++){
					char* s = strtok(NULL, ",");
					if(!s){
						printf("ERROR: reading rigid value %d\n", i);
						goto end;
					}
					if(sscanf(s, "%f", (float*)&rigidCoordinates[i]) != 1){
						printf("ERROR: parsing rigid value %d\n", i);
						goto end;
					}
				}

				s = strtok(NULL, "[("); // up to first list/tuple
				if(!s){
					printf("ERROR: reading normal values\n");
					goto end;
				}
				for(int i=0; i<3*nNumMarkers; i++){
					char* s = strtok(NULL, ",");
					if(!s){
						printf("ERROR: reading normal value %d\n", i);
						goto end;
					}
					if(sscanf(s, "%f", (float*)&normalCoordinates[i]) != 1){
						printf("ERROR: parsing normal value %d\n", i);
						goto end;
					}
				}
				s = strtok(NULL, "],) ");
				//s = strtok(NULL, ")");
				if(s && sscanf(s, "%d", &nFlags)==1){
					i0 = RigidBodyAdd(nRigidBodyId, nStartMarker, nNumMarkers, rigidCoordinates, normalCoordinates, nFlags);
					printf("%d\n", i0);
				} else
					printf("ERROR: reading last argument\n");
			} else
				printf("ERROR: reading first 3 arguments\n");
			//int RigidBodyAddFromFile( int nRigidBodyId, int nStartMarker, char *pszRigFile, int nFlags );
			//int RigidBodyChangeSettings( int nRigidBodyId, int nMinMarkers, int nMaxMarkersAngle, float fMax3dError, float fMaxSensorError, float fMax3dRmsError, float fMaxSensorRmsError, int nFlags );
			//int RigidBodyDelete( int nRigidBodyId );
			//int RigidBodyChangeFOR( int nRigidId, int nRotationMethod );
		} else if (cmp(line, "RigidBodyChangeSettings")){
			int nRigidBodyId, nMinMarkers, nMaxMarkersAngle;
			float fMax3dError, fMaxSensorError, fMax3dRmsError, fMaxSensorRmsError;
			int nFlags;
			strtok(line, "(");
			char* s = strtok(NULL, ")");
			if(s && sscanf(s, "%d, %d, %d, %f, %f, %f, %f, %d", 
				&nRigidBodyId, &nMinMarkers, &nMaxMarkersAngle, 
				&fMax3dError, &fMaxSensorError, &fMax3dRmsError, &fMaxSensorRmsError, &nFlags) != 4){
				i0 = RigidBodyChangeSettings(nRigidBodyId, nMinMarkers, nMaxMarkersAngle,
				fMax3dError, fMaxSensorError, fMax3dRmsError, fMaxSensorRmsError, nFlags);
				printf("%d\n", i0);
			} else
				printf("ERROR: reading 8 arguments\n");
		} else if (cmp(line, "DataGetLatestRaw")){
			uint uFrameNumber=999, uElements=999, uFlags=999;
			i0 = DataGetLatestRaw(&uFrameNumber, &uElements, &uFlags, pFullRawData);
			printf("Frame Number: %8u\n", uFrameNumber);
			printf("Elements    : %8u\n", uElements);
			printf("Flags       :     0x%04x\n", uFlags);
			for(uint uMarkerCnt=0; uMarkerCnt<nMarkers; uMarkerCnt++){
				// Print out the current marker number.
				fprintf( stdout, "Marker %u, ", uMarkerCnt + 1 );
				//Print out the information for each sensor.
				for(uint uSensorCnt = 0; uSensorCnt<NUM_SENSORS; ++uSensorCnt ){
					//Print out the current sensor number.
					fprintf( stdout, "Sensor %u, ", uSensorCnt + 1 );
					// Print out the centroid. If it is bad print out *the string	'missing'.
					//if( pFullRawData[uMarkerCnt].fCentroid[uSensorCnt] < MAX_NEGATIVE )
						//printf("data missing, " );
					//else 
						printf("data: %8.2g, ", (float)pFullRawData[uMarkerCnt].fCentroid[uSensorCnt] );
					//Print out the rest of this sensor’s information.
					printf("peak: %4d, DRC: %4d, sensorCode: %u\n",
						pFullRawData[uMarkerCnt].SensorData[uSensorCnt].ucPeak,
						pFullRawData[uMarkerCnt].SensorData[uSensorCnt].ucDRC,
						(uint)pFullRawData[uMarkerCnt].SensorData[uSensorCnt].ucCode);
				} /* for */
			} /* for */
		} else if (cmp(line, "DataGetLatest3D")){
			//int DataGetLatest3D( unsigned *pnFrame, unsigned *pElems, unsigned *pFlags, void *pDataDest );
			uint nFrame=999, elems=999, flags=999;
			//Position3d dataDest[NUM_MARKERS];
			i0 = DataGetLatest3D(&nFrame, &elems, &flags, pPosition3d);
			printf("(%d, %u, %u, 0x%X, (", i0, nFrame, elems, flags);
			for(uint i=0; i<nMarkers; i++){
				printf("  (%10.3g, %10.3g, %10.3g),", pPosition3d[i].x, pPosition3d[i].y, pPosition3d[i].z);
			}
			printf("))\n");
		} else if (cmp(line, "RequestLatest3D")){
			i0 = RequestLatest3D();
			printf("%d\n", i0);
		} else if (cmp(line, "DataIsReady")){
			i0 = DataIsReady();
			printf("%d\n", i0);
		} else if (cmp(line, "DataReceiveLatest3D")){
			// alle markers 3d 
			uint nFrame=999, elems=999, flags=999;
			Position3d dataDest;
			i0 = DataReceiveLatest3D(&nFrame, &elems, &flags, &dataDest);
			printf("(%d, %u, %u, 0x%X, (", i0, nFrame, elems, flags);
			for(uint i=0; i<nMarkers; i++){
				printf("  (%10.3g, %10.3g, %10.3g),", pPosition3d[i].x, pPosition3d[i].y, pPosition3d[i].z);
			}
			printf("))\n");
		} else if (cmp(line, "DataReceiveLatestRaw")){
			uint nFrame, elems, flags;
			void *dataDest; // todo allocate!
			i0 = DataReceiveLatestRaw(&nFrame, &elems, &flags, &dataDest);
			printf("(%d, %u, 0x%x)\n", i0, nFrame, flags);
		} else if (cmp(line, "DataBufferInitializeFile")){
			//unsigned uDataId;
			char pszFileName[len];
			strtok(line, "\"");
			char* s = strtok(NULL, "\"");
			if(sscanf(s, "%s", pszFileName)==1){
				i0 = DataBufferInitializeFile(OPTOTRAK, s);
				printf("%d\n", i0);
			} else
				printf("ERROR: could not read filename\n");
		} else if (cmp(line, "DataBufferSpoolData")){
			int i = 999;
			i0 = DataBufferSpoolData(&i);
			printf("(%d, %d)\n", i0, i);
		} else if (cmp(line, "DataBufferStart")){
			i0 = DataBufferStart();
			printf("%d\n", i0);
		} else if (cmp(line, "DataBufferStop")){
			i0 = DataBufferStop();
			printf("%d\n", i0);
		} else if (cmp(line, "DataBufferWriteData")){
			unsigned uRealtimeData=999, uSpoolComplete=0, uSpoolStatus=999;
			unsigned long ulFramesBuffered=999;
			i0 = DataBufferWriteData(&uRealtimeData, &uSpoolComplete, &uSpoolStatus, &ulFramesBuffered);
			printf("(%d, %u, %u, %u, %lu)\n", i0, uRealtimeData, uSpoolComplete, uSpoolStatus, ulFramesBuffered);
		} else if (cmp(line, "DataBufferAbortSpooling")){
			i0 = DataBufferAbortSpooling();
			printf("%d\n", i0);
		} else {
			printf("ERROR: no such command: %s\n", line);
		}
		end:
		fflush(stdout);
	}
	exit(EXIT_SUCCESS);
}
コード例 #2
0
/*****************************************************************
Name:               main

Input Values:
    int
        argc        :Number of command line parameters.
    unsigned char
        *argv[]     :Pointer array to each parameter.

Output Values:
    None.

Return Value:
    None.

Description:

    Main program routine performs all steps listed in the above
    program description.

*****************************************************************/
void main( int argc, unsigned char *argv[] )
{
    unsigned int
        uFlags,
        uElements,
        uFrameCnt,
        uRigidCnt,
        uMarkerCnt,
        uFrameNumber;
    RigidBodyDataType
        RigidBodyData;
    char
        szNDErrorString[MAX_ERROR_STRING_LENGTH + 1];

    /*
     * Load the system of transputers.
     */
    if( TransputerLoadSystem( "system" ) )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Wait one second to let the system finish loading.
     */
    sleep( 1 );

    /*
     * Initialize the transputer system.
     */
    if( TransputerInitializeSystem( OPTO_LOG_ERRORS_FLAG ) )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Load the standard camera parameters.
     */
    if( OptotrakLoadCameraParameters( "standard" ) )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Set up a collection for the OPTOTRAK.
     */
    if( OptotrakSetupCollection(
            NUM_MARKERS,        /* Number of markers in the collection. */
            FRAME_RATE,         /* Frequency to collect data frames at. */
            (float)2500.0,      /* Marker frequency for marker maximum on-time. */
            30,                 /* Dynamic or Static Threshold value to use. */
            160,                /* Minimum gain code amplification to use. */
            1,                  /* Stream mode for the data buffers. */
            (float)0.4,         /* Marker Duty Cycle to use. */
            (float)7.5,         /* Voltage to use when turning on markers. */
            COLLECTION_TIME,    /* Number of seconds of data to collect. */
            (float)0.0,         /* Number of seconds to pre-trigger data by. */
            OPTOTRAK_BUFFER_RAW_FLAG ) )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Wait one second to let the camera adjust.
     */
    sleep( 1 );

    /*
     * Activate the markers.
     */
    if( OptotrakActivateMarkers() )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Add rigid body 1 for tracking to the OPTOTRAK system from a .RIG file.
     */
    if( RigidBodyAddFromFile(
            RIGID_BODY_1,   /* ID associated with this rigid body. */
            1,              /* First marker in the rigid body.*/
            "plate",        /* RIG file containing rigid body coordinates.*/
            0 ) )           /* flags */
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Change the default settings for this rigid body 1.
     */
    if( RigidBodyChangeSettings(
            RIGID_BODY_1,   /* ID associated with this rigid body. */
            4,              /* Minimum number of markers which must be seen
                               before performing rigid body calculations.*/
            60,             /* Cut off angle for marker inclusion in calcs.*/
            (float)0.25,    /* Maximum 3-D marker error for this rigid body. */
            (float)1.0,     /* Maximum raw sensor error for this rigid body. */
            (float)1.0,     /* Maximum 3-D RMS marker error for this rigid body. */
            (float)1.0,     /* Maximum raw sensor RMS error for this rigid body. */
            OPTOTRAK_QUATERN_RIGID_FLAG | OPTOTRAK_RETURN_QUATERN_FLAG ) )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Get and display ten frames of rigid body data.
     */
    fprintf( stdout, "Rigid Body Data Display\n" );
    for( uFrameCnt = 0; uFrameCnt < 10; ++uFrameCnt )
    {

        /*
         * Get a frame of data.
         */
        if( DataGetLatestTransforms( &uFrameNumber, &uElements, &uFlags,
                                     &RigidBodyData ) )
        {
            goto ERROR_EXIT;
        } /* if */

        /*
         * Print out the rigid body transformation data.
         */
        fprintf( stdout, "\n" );
        fprintf( stdout, "Rigid Body Transformation Data\n\n" );
        fprintf( stdout, "Frame Number: %8u\n", uFrameNumber );
        fprintf( stdout, "Transforms  : %8u\n", uElements );
        fprintf( stdout, "Flags       :   0x%04x\n", uFlags );
        for( uRigidCnt = 0; uRigidCnt < uElements; ++uRigidCnt )
        {
            fprintf( stdout, "Rigid Body %u\n",
                     RigidBodyData.pRigidData[ uRigidCnt].RigidId );
            fprintf( stdout, "XT = %8.2f YT = %8.2f ZT = %8.2f\n",
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.translation.x,
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.translation.y,
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.translation.z );
            fprintf( stdout, "Q0 = %8.2f QX = %8.2f QY = %8.2f QZ = %8.2f\n",
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.rotation.q0,
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.rotation.qx,
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.rotation.qy,
                     RigidBodyData.pRigidData[ uRigidCnt].transformation.
                         quaternion.rotation.qz );
        } /* for */

        /*
         * Print out the 3D data.
         */
        fprintf( stdout, "\nAssociated 3D Marker Data\n\n" );
        for( uMarkerCnt = 0; uMarkerCnt < NUM_MARKERS; ++uMarkerCnt )
        {
            fprintf( stdout, "Marker %u X %f Y %f Z %f\n",
                     uMarkerCnt + 1,
                     RigidBodyData.p3dData[ uMarkerCnt].x,
                     RigidBodyData.p3dData[ uMarkerCnt].y,
                     RigidBodyData.p3dData[ uMarkerCnt].z );
        } /* for */
    } /* for */

    /*
     * De-activate the markers.
     */
    if( OptotrakDeActivateMarkers() )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Shutdown the transputer message passing system.
     */
    if( TransputerShutdownSystem() )
    {
        goto ERROR_EXIT;
    } /* if */

    /*
     * Exit the program.
     */
    fprintf( stdout, "\nProgram execution complete.\n" );
    exit( 0 );

ERROR_EXIT:
    if( OptotrakGetErrorString( szNDErrorString,
                                MAX_ERROR_STRING_LENGTH + 1 ) == 0 )
    {
        fprintf( stdout, szNDErrorString );
    } /* if */
    OptotrakDeActivateMarkers();
    TransputerShutdownSystem();
    exit( 1 );

} /* main */