Skip to content

Virtual markers

Zoltan Derzsi edited this page May 28, 2019 · 31 revisions

What are virtual markers?

Sometimes, it is impossible or impractical to attach a marker to a surface. For these occasions, it is a more sensible approach to use virtual markers.
Virtual markers are coordinates that are calculated with respect to a measurable set of markers that are tracked together; their orientation and distance with respect to each other are constant. The Optotrak system's rigid body management takes care of tracking these markers, the implemented rigid body transform functions (such as DataGetNextTransforms2_as_array()) conveniently return the centroid coordinate and the orientation of these group of markers.
Unfortunately it is possible to assign any coordinate system to a rigid body, which will result in the reported rotations being swapped and/or reversed. The Optotrak system will not give you an error message when the rotations are completely off in a rigid body transform, and it's up to you to make sure that your own rigid body is behaving correctly in your system.

The two types of virtual markers

It is possible to exploit the Optotrak's rigid body feature directly. The first method is faster but it only supports one virtual marker per rigid body. The second method is slower, but there is no limit on the maximum number of virtual markers.

1., Create a custom rigid body on the fly If only a single virtual marker is needed, it is possible to exploit the Optotrak's rigid body tracking directly. All that needs to be done is to programmatically create a rigid body using optotrak_generate_rigid_body_file(), where the origin of the local coordinate system is the desired coordinate of the virtual marker.
Then, later-on, all that needs to be done is to read the translation coordinates from the system. The returned translation coordinates will be the virtual marker coordinates.

2., Use a pre-made rigid body with a virtual marker definition If multiple virtual markers are needed to be attached to a rigid body, the process is a bit more complicated and more computationally intensive. In a nutshell, it has three parts:

  • Load the rigid body the virtual marker should be attached to
  • Create the virtual marker definition
  • Use the created virtual marker definition to get the updated virtual marker coordinates

How to handle virtual markers

To track multiple virtual markers, the best practice is to track rigid bodies using the Optotrak system, and the origin of the rigid body's local coordinate system should be the centroid. ALWAYS validate a virtual marker set-up before you use it in an experiment!

Let's assume that the Optotrak system is properly initialised, a ridid body is loaded using RigidBodyAddFromFile_euler(), and a successful transform was performed by calling DataGetNextTransforms2_as_array(). In Matlab, the variables:

  • translation is a 1-by-3 array, storing the X-Y-Z coordinates of the correctly defined rigid body's centroid
  • rotation is also a 1-by-3 array, which has the Roll-Pitch-Yaw angles (IN RADIANS) of the rigid body ...are loaded and readily available.

1. Assign a virtual marker

To create a virtual marker definition, it is necessary to move the virtual marker to be tracked to a position that is know. Ideally, a visible marker should be used for this purpose, which has the position recorded previously over time. To fetch the position of a single marker, it is possible to select the appropriate coordinate triplet from the return value of DataGetNext3D_as_array. However, for this purpose, the toolbox has
optotrak_get_marker_coords(), which only returns the coordinates of a selected marker. If you already have a set of marker coordinates, you can use optotrak_get_selected_triplet() to extract the coordinates you need. To define a virtual markers, we need to have three variables. For example,

translation = [100, 100, 100]; % The rigid body just happens to be here,
rotation = [0, 0, 0]; % And is so conveniently placed, it's unreal.
known_marker_coordinates = [100, 100, 0]; % X-Y-Z, just like the translation

Now it is possible to assign the virtual marker, the following way:

virtual_marker_definition = optotrak_assign_virtual_marker(known_marker_coordinates, translation, rotation);

The variable virtual_marker_definition will contain the relative location and angles from the rigid body's centroid to the virtual marker. In this example, it should contain:

virtual_marker_definition =

     0     0  -100     0     0     0

The operation of this function is described in detail in here, or by typing help optotrak_assign_virtual_marker in a properly installed toolbox.

Note that optotrak_assign_virtual_marker() only accepts single frames of data. Should averaging of coordinates be required, it must be done prior to calling this function.
It is also possible for this definition to be saved and used elsewhere, so in application where the relative distance of the marker doesn't change (such as robotic arms, probes, etc.) this definition can be done only once. Virtual marker definitions with humans should be done regularly.

2. Restore virtual marker coordinates

Let's assume that the rigid body to which the virtual marker is assigned to have moved, and we have it saved in Matlab as:

recorded_translations = [
    110, 100, 100;
    115, 101, 100;
    100, 100, 100;
]; %this contains three frames of X-Y-Z triplets.

recorded_rotations = [
    0, 0, 0;
    0, 0.2, 0;
    3.14, 0.75, 0;
]; %Note that these are roll-pitch-yaw, in radians.

We also still have virtual_marker_definition loaded in the memory too, so we can execute:

virtual_marker_coords = optotrak_get_virtual_marker_coords(virtual_marker_definition, recorded_translations, recorded_rotations); %This will calculate the new coordinates

Note that while optotrak_get_virtual_marker_coords() can handle multiple frames of data, it can process only one virtual marker definition at a time. The virtual marker coordinates, which are in X-Y-Z triplets should be then:

virtual_marker_coords =

  110.0000  100.0000         0
   95.1331  101.0000    1.9933
  168.1638   99.8914   26.8311

Virtual markers without rigid bodies

Tracking virtual markers can only be as accurate as the tracking of the rigid body it is tied with. However, in certain cases, it might be difficult or unnecessary to create a working rigid body file just for this purpose. For these cases, the toolbox has optotrak_calculate_centroid_and_orientation(), which will calculate the centroid coordinates of a given set of markers, and the user can specify which marker should be used to calculate the orientation with. However, please consider the following:

  1. The rigid body tracking includes some safeguards, such as:
  • Some markers can be lost without affecting centroid calculation
  • If the distance between the rigid body's markers change for any reason, the Optotrak system will fail transforming the coordinates and will return NaNs
  • Getting the rigid body transforms from the system takes no more time than getting the marker coordinates
  1. In addition to NDI's 6D Architect, the toolbox has its own rigid body file generation function
  • Very simple rigid bodies are adequate for virtual markers
  • The marker coordinates of the rigid body do not need to be transformed
  • Normal vectors are not necessary for simple rigid bodies

Warning

If you choose to handle the markers to which you assign the virtual marker yourself, it is your responsibility to:

  • Make sure the markers don't change location with respect to each other
  • The marker to which you calculate the orientation is always visible
  • You employ sensible error management when restoring marker coordinates (for example by using optotrak_get_distance())
  • Keep the tracking tolerance to an acceptable level

Virtual marker tracking is more error-prone when used together without a loaded rigid body. Use it only as a last resort, and make sure that numerous error and sanity checks are in place!