Class vicon_transformer::ViconTransformer

class ViconTransformer

Get data from a ViconReceiver and provide poses of subjects relative to an “origin subject”.

Vicon provides positions and orientations of subjects relative to an origin that is defined when calibrating the system. Unfortunately, it is not easy precisely specify this, so the actual origin can be in a not very well defined location and can vary over time if the system is recalibrated.

Instead, this class provides the option to specify a static object which doesn’t move over time (e.g. some markers attached to a wall) as “origin

subject” and provide poses of all other subjects relative to this origin subject. This makes the poses independent of the actual origin used by Vicon and will give repeatable results, even if the system is recalibrated in between (at least as long as the markers of the origin subject are not moved).

Public Functions

ViconTransformer(std::shared_ptr<Receiver> receiver, const std::string &origin_subject_name, std::shared_ptr<spdlog::logger> logger = nullptr)
Parameters:
  • origin_subject_name – Name of the subject that shall be used as origin.

  • logger – A logger instance used for logging output. If not set, a logger with name “ViconTransformer” used.

std::shared_ptr<Receiver> receiver()

Return a pointer to the receiver instance.

std::shared_ptr<const Receiver> receiver() const

Return a const pointer to the receiver instance.

void update()

Update transformations by getting a new frame from the receiver.

void set_frame(const ViconFrame &frame)

Set the Vicon frame that is used by the transformer.

void wait_for_origin_subject_data()

Wait until the receiver provides a valid data for the origin subject.

Calls update() in a loop until a frame is provided in which the origin subject is visible. This is needed, even if the origin subject is always in the scene, because after connecting it takes a bit until the Vicon server provides proper data (in the first frames all subjects are marked as not visible).

If no origin subject has been specified (i.e. origin_subject_name is an empty string), this method returns immediately.

int64_t get_timestamp_ns() const

Get timestamp of the frame in nanoseconds.

std::vector<std::string> get_subject_names() const

Get list with the names of all registered subjects.

bool is_visible(const std::string &subject_name) const

Check if the specified subject is visible.

Parameters:

subject_name – Name of the subject.

Throws:

UnknownSubjectError – if there is no subject with the given name.

Returns:

True if it is visible in the current frame, false if not

Transformation get_transform(const std::string &subject_name) const

Get transformation of a subject relative to the origin subject.

Parameters:

subject_name – Name of the subject

Throws:

SubjectNotVisibleError – if the subject is not visible in the current frame.

Returns:

Transformation from the origin subject to the requested subject.

Transformation get_raw_transform(const std::string &subject_name) const

Get transformation of a subject relative to Vicons global origin.

Note

The Vicon origin can be at an arbitrary pose and can vary over time if the system is recalibrated. For more reliable results, specify a static object as “origin subject” and use get_transform instead of this method.

Parameters:

subject_name – Name of the subject

Throws:

SubjectNotVisibleError – if the subject is not visible in the current frame.

Returns:

Transformation from the Vicon origin to the requested subject.

ViconFrame get_frame() const

Get the whole frame data with all subject poses relative to the origin subject.

ViconTransformer(std::shared_ptr<Receiver> receiver, const std::string &origin_subject_name, std::shared_ptr<spdlog::logger> logger = nullptr)
Parameters:
  • origin_subject_name – Name of the subject that shall be used as origin.

  • logger – A logger instance used for logging output. If not set, a logger with name “ViconTransformer” used.

std::shared_ptr<Receiver> receiver()

Return a pointer to the receiver instance.

std::shared_ptr<const Receiver> receiver() const

Return a const pointer to the receiver instance.

void update()

Update transformations by getting a new frame from the receiver.

void set_frame(const ViconFrame &frame)

Set the Vicon frame that is used by the transformer.

void wait_for_origin_subject_data()

Wait until the receiver provides a valid data for the origin subject.

Calls update() in a loop until a frame is provided in which the origin subject is visible. This is needed, even if the origin subject is always in the scene, because after connecting it takes a bit until the Vicon server provides proper data (in the first frames all subjects are marked as not visible).

If no origin subject has been specified (i.e. origin_subject_name is an empty string), this method returns immediately.

int64_t get_timestamp_ns() const

Get timestamp of the frame in nanoseconds.

std::vector<std::string> get_subject_names() const

Get list with the names of all registered subjects.

bool is_visible(const std::string &subject_name) const

Check if the specified subject is visible.

Parameters:

subject_name – Name of the subject.

Throws:

UnknownSubjectError – if there is no subject with the given name.

Returns:

True if it is visible in the current frame, false if not

Transformation get_transform(const std::string &subject_name) const

Get transformation of a subject relative to the origin subject.

Parameters:

subject_name – Name of the subject

Throws:

SubjectNotVisibleError – if the subject is not visible in the current frame.

Returns:

Transformation from the origin subject to the requested subject.

Transformation get_raw_transform(const std::string &subject_name) const

Get transformation of a subject relative to Vicons global origin.

Note

The Vicon origin can be at an arbitrary pose and can vary over time if the system is recalibrated. For more reliable results, specify a static object as “origin subject” and use get_transform instead of this method.

Parameters:

subject_name – Name of the subject

Throws:

SubjectNotVisibleError – if the subject is not visible in the current frame.

Returns:

Transformation from the Vicon origin to the requested subject.

ViconFrame get_frame() const

Get the whole frame data with all subject poses relative to the origin subject.