PolhemusCoregistration
Namespace: UTILSLIB · Library: Utilities Library
#include <utils/polhemus_coregistration.h>
class UTILSLIB::PolhemusCoregistration
Head–device coregistration engine driven by a Polhemus Fastrak.
The class wires itself to a PolhemusConnection and maintains:
- A continuously updated device-to-world transform (from the tracker station + user-supplied calibration offset).
- An
AcquiredPointsstore filled by explicit capture calls or automatically on pen-button press. - The computed head–device transform after
computeRegistration.
src/examples/ex_utils/main.cpp
PolhemusConnection connection;
PolhemusSerialConfig serial; // 115200 baud, inches; the hemisphere and stream command a Fastrak needs
connection.open(QString(), serial); // empty port name = mock backend sweeping a 10 cm sphere; e.g. "/dev/tty.usbserial" for a Fastrak
PolhemusCoregistration coreg;
coreg.setConnection(&connection); // station 1 = pen, station 2 = head tracker
// Model fiducials are the pen fiducials turned 90 deg about z and moved 5 cm in x; the registration must find that transform
QMatrix4x4 truth;
truth.translate(0.05f, 0.0f, 0.0f);
truth.rotate(90.0f, 0.0f, 0.0f, 1.0f);
const QList<FiducialId> fiducials = {FiducialId::NAS, FiducialId::LPA, FiducialId::RPA};
QList<QVector3D> penAt;
for (const FiducialId id : fiducials) {
QEventLoop wait; // let the next mock pen sample arrive, as the user would move the pen
QTimer::singleShot(350, &wait, &QEventLoop::quit);
wait.exec();
coreg.captureCurrentPenPositionAsFiducial(id);
penAt.append(coreg.penPosition());
coreg.setModelFiducial(id, truth.map(coreg.penPosition()));
}
const bool registered = coreg.computeRegistration();
connection.close();
Inheritance
Public Methods
PolhemusCoregistration(parent)
~PolhemusCoregistration()
setTrackerStation(station)
setPenStation(station)
setProbeStation(station)
trackerStation()
penStation()
probeStation()
setPenTipOffset(offset)
penTipOffset()
setTipOffsetEnabled(on)
tipOffsetEnabled()
setAxisMirror(mirrorX, mirrorY)
Negate X and/or Y of incoming Polhemus positions.
The Polhemus Fastrak coordinate system depends on the physical placement and orientation of the transmitter. When the transmitter is oriented such that its axes are mirrored relative to the expected neuroscience convention, enable the corresponding mirror flags here.
Parameters:
-
mirrorX : bool True to negate the X coordinate of incoming positions.
-
mirrorY : bool True to negate the Y coordinate of incoming positions.