NCSA libTrCalibr 2.00

Volodymyr Kindratenko
Visualization and Virtual Environments group
National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign

[Read Software Copyright] [Download the Source Code] [ReadREADME]
[back to Electromagnetic Tracker Calibration Page]


Library Description

libTrCalibr 2.00 implements two different techniques to calibrateelectromagnetic tracking systems: high order polynomial fit and interpolation on anirregularly spaced tracked grid.  This is in contrast to EVL's approach where the measurements for the calibrationtable need to be done on the regular grid in the tracked space.  Both techniquesperform calibration of both position and rotation distortions.  Please refer to thefollowing publications for more details regarding these techniques:

  1. V. Kindratenko, Calibration of electromagnetic tracking devices, Virtual Reality: Research, Development, and Applications, vol. 4, 1999, pp. 139-150. postscript
  2. V. Kindratenko, and A. Bennett, Evaluation of Rotation Correction Techniques for Electromagnetic Position Tracking Systems, submitted to Virtual Environments 2000 Eurographics Workshop. pdf

The library also includes utilities to assist with making calibrationmeasurements and to visualize them in a virtual reality environment.  If you have anyquestions regarding the software, please contact me at kindr@ncsa.uiuc.edu.

 

List of included files

README - license, API documentation, etc.

Makefile - SGI make file for the library and example applications

calibfile.h - calibration file IO
calibfile.c - calibration file IO
caltable.dat - an example of a calibration file
valtable.dat - an example of a validation file

polyfit.h - polynomial fit-based calibration
polyfit.c - polynomial fit-based calibration
trCalibrTest_polyfit.c - example application
polyfit_validation.c - fit quality validation tool

interpolation.h - interpolation-based calibration
interpolation.c - interpolation-based calibration
trCalibrTest_interpol.c - example application
interpol_validation.c - interpolation quality validation tool

quaternions.h - quaternions algebra
quaternions.c - quaternions algebra

stat.h - fit/interpolation quality statistics
stat.c - fit/interpolation quality statistics

cavecubes.c - utility to assist in data collection
datacollect.c - CAVE/IDesk data collecting application
collect.sh - script to simplify running datacollect
visualerror.c - calibration table visualization
filter.sh - utility to assist in visualizing calibration results

 

API

CALIBRATION FILE I/O

int readcalibfile(char *fname, struct calibdata *cdata, int rotunits)

This function reads data from the calibration file fname and stores it into cdatastructure which is declared in calibfile.h. Calibration file hasthe following structure:

line 1: total number of records m
line 2: record 1
line 3: record 2
.........
line m+1: record m

where each record contains true x, y, z, azimuth, elevation, and roll followed bymeasured x, y, z, and measured azimuth, elevation, roll. Angles can be measured in degrees(rotunits = DEGREES) or radians (rotunits = RADIANS). It does not matterwhat units are used for x, y, and z as long as they are everywhere the same. The functionreturns the actual number of records if data was read, otherwise it returns 0. The cdatastructure must exist before calling the function, but the memory needed to store the datafrom the file will be allocated by the function.

void deletecalibdata(struct calibdata *cdata)

This function frees the memory allocated by readcalibfile in cdata.

 

POLYNOMIAL FIT

int fit_initialize(struct calibdata *cdata, int porder, struct fpolynomials*fpol)

This function takes the calibration table loaded by the readcalibfile in cdataand computes the fitting polynomials of the order porder both for position and orientationcomponents. The result is returned in fpol structure which is declared inpolyfit.h. The fpol structure must exist before calling the function, but thememory needed to store the polynomials will be allocated internally by the function.

void fit_evaluate(struct fpolynomials *fpol, float xm, float ym, float zm,float azm, float elm, float rlm, float *xf, float *yf, float *zf, float *azf, float *elf,float *rlf)

Once the polynomials fpol have been computed by fit_initialize, this function can becalled to fit the measured values xm, ym, zm, azm, elm,and rlm. Results are returned in xf, yf, zf, azf,elf, and rlf. Angles must be measured in radians only.

int fit_statistics(struct calibdata *calt, struct calibdata *valt, intorder, FILE *file)

This function takes the calibration table calt loaded by readcalibfile, buildsthe polynomials of the given order, fits the validation table valt loaded byreadcalibfil, and computes the statistics regarding the quality of the fit. Results areoutput to the stream file.

 

INTERPOLATION

int itp_initialize(struct calibdata *cd, struct rotcor *rc);

This function takes the calibration table loaded by the readcalibfile in cd,sorts it out into tetrahedrons and computes error vectors and error quaternions at eachmeasured point. The result is returned in rc structure which is declared ininterpolation.h. The rc structure must exist before calling the function, but thememory needed to store the tetrahedrons will be allocated internally by the function.

int itp_evaluate(struct rotcor *rc, int type, float xm, float ym, float zm,float azm, float elm, float rlm, float *xc, float *yc, float *zc, float *azc, float *elc,float *rlc);

Once the rc structure is initialized by itp_initialize, this function can becalled to interpolate the measured values xm, ym, zm, azm,elm, and rlm. Results are returned in xf, yf, zf,azf, elf, and rlf. Angles must be measured in radians.  Weight type is defined as following: 1 - linear, 2 - squared, or 3 - log.

int itp_statistics(struct calibdata *calt, struct calibdata *valt, inttype, FILE *file)

This function takes the calibration table calt loaded by readcalibfile, sortsit into tetrahedrons and computes the errors, interpolates the validation table valtloaded by readcalibfil, and computes the statistics regarding the quality of theinterpolation. Results are output to the stream file.

 

Utilities User's Guide

trCalibrTest_interpol - example interpolation-based calibration application

Usage: trCalibrTest_interpol callibration.file weight_type
weight_type: 1 - linear, 2 - squared, or 3 - log

 

trCalibrTest_polyfit - example fit-based calibration application

Usage: trCalibrTest_polyfit callibration.file polyorder
polyorder: order of the polynomial to be used

 

polyfit_validation - calculates fit quality statistics

Usage: polyfit_validation callib_file angular_units polyorder valid_file
angular_units: r - radians, d - degree
polyorder: order of the polynomial to be used

 

interpol_validation - calculates interpolation quality statistics

Usage: interpol_validation callib_file angular_units weight_type valid_file
angular_units: r - radians, d - degree
weight_type: type of the weight factor to be used (1-3)

 

cavecubes - CAVE application, draws set of cubes and attaches a cube to a sensor

Usage: cavecubes [sensor]

 

datacollect - CAVE/IDesk data collecting application

Usage: datacollect -trackerDaemonKey <tkey> -controllerDaemonKey <kkey> \-Xoffset <xofs> -Yoffset <yofs> -Zoffset <zofs> \ -Xmin <xmin>-Xmax <xmax> -Xstep <xstep> \ -Ymin <ymin> -Ymax <ymax> -Ystep<ystep> \ -Zmin <zmin> -Zmax <zmax> -Zstep <zstep> \ -Hmin<hmin> -Hmax <hmax> -Hstep <hstep> \ -Pmin <pmin> -Pmax<pmax> -Pstep <pstep> \ -Rmin <rmin> -Rmax <rmax> -Rstep<rstep> \ -sensor <sensor#> -file <file_name>

Where:
- tkey, kkey - shared memory keys, as in cave.config
- (xofs, yofs, zofs) is transmitter location as specified in cave.config
- xmin, ymin, zmin - lower boundaries of the volume to be calibrated
- xmax, ymax, zmax - upper boundaries of the volume to be calibrated
- xstep, ystep, zstep - distance between receiver placement locations
- hmin, pmin, rmin - lover boundaries for azimuth, elevation, and roll
- hmax, pmax, rmax - upper boundaries for azimuth, elevation, and roll
- hstep, pstep, rstep - angular steps between receiver rotation
- sensor# - number of the sensor the readings from each are to be collected
- file_name - output file

 

collect.sh - script to simplify running datacollect

Usage: collect.sh

 

visualerror - calibration table visualization

Usage: visualerror file1 rotatio_type file2 rotatio_type

Where:
- file1 is your original validation table
- file2 is your calibrated validation table filtered with filter.sh
- rotatio_type rotation type is d or r

- left wand button - true coordinates
- middle wand button - measured coordinates
- right wand button - calibrated coordinates
- joystick - navigation

 

filter.sh - takes output of polyfit_validation or interpol_validation stored asa file with removed header, extracts columns that belong to measured and calibrated data,and stores them in filename.filtered file. This is to assist in visualizing fitted datawith visualerror

Usage: filter.sh filename
where filename is the name of the output of polyfit_validation or interpol_validationstored in the filename and edited to remove the header

 

Compiling instructions

Makefile is provided for SGI platform only.

make libs - compiles o32, n32, and 64 bit libraries
make apps - compiles utilities; you'll need CAVElib and TRACKD_API to do this
make - makes all


Acknowledgements

This work was performed at the National Center for SupercomputingApplications (NCSA) and was supported by Caterpillar Inc.  Additional informationregarding the electromagnetic tracking system was provided by Ascension TechnologyCorporation. Division Inc kindly shared the information needed to implement the sensorfilter.


This document was created by VolodymyrKindratenko
Last modified: Thursday, January 13, 2000 12:51:51 PM