Skip to main content

PolhemusSerialConfig

Namespace: UTILSLIB  ·  Library: Utilities Library

#include <utils/polhemus_connection.h>

struct UTILSLIB::PolhemusSerialConfig

Settings used to open a real Polhemus serial connection.

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();

Example​

Used in examples​

ex_utils​

Utilities library: buffers, observers, logging, file formats, montages, layouts and reports.

src/examples/ex_utils/main.cpp, line 275
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

Authors of this file​