cgv
Loading...
Searching...
No Matches
vr_driver.h
Go to the documentation of this file.
1#pragma once
2
3#include "vr_kit.h"
4#include <string>
5#include <map>
6
17
25
26#include "lib_begin.h"
27
29namespace vr {
32
33 class CGV_API vr_driver;
34
36 class CGV_API vr_calibration_base
37 {
38 protected:
40 void set_driver_calibration_matrix(vr_driver* driver, const float calibration_matrix[12]) const;
41 public:
44 };
45
47
56 class CGV_API vr_driver
57 {
58 private:
60 unsigned driver_index;
61 protected:
63 void set_index(unsigned _idx);
64 friend void CGV_API register_driver(vr_driver* vrd);
66 void register_vr_kit(void* handle, vr_kit* kit);
68 void replace_vr_kit(void* handle, vr_kit* kit);
69 private:
71 std::map<std::string, vr_trackable_state> tracking_reference_states;
73 mutable std::map<std::string, vr_trackable_state> calibrated_tracking_reference_states;
74 protected:
76 friend class vr_kit;
80 vr_trackable_state& ref_tracking_reference_state(const std::string& serial_nummer);
85 private:
87 float calibration_matrix[12];
89 bool use_calibration_matrix;
90 protected:
92 void set_calibration_transformation(const float new_transformation_matrix[12]);
93 friend class vr_calibration_base;
95 vr_driver();
96 public:
98 virtual ~vr_driver();
100 virtual std::string get_driver_name() const = 0;
102 virtual bool is_installed() const = 0;
104 virtual std::vector<void*> scan_vr_kits() = 0;
106 virtual vr_kit* replace_by_index(int& index, vr_kit* new_kit_ptr) = 0;
108 virtual bool replace_by_pointer(vr_kit* old_kit_ptr, vr_kit* new_kit_ptr) = 0;
109
111 void put_x_direction(float* x_dir) const;
113 virtual void put_up_direction(float* up_dir) const = 0;
115 virtual float get_floor_level() const = 0;
117 virtual float get_action_zone_height() const = 0;
119 virtual void put_action_zone_bounary(std::vector<float>& boundary) const = 0;
120
122 void put_calibration_transformation(float transformation_matrix[12]) const;
124 void calibrate_pose(float(&pose)[12]) const;
131
132
134 virtual const std::map<std::string, vr_trackable_state>& get_tracking_reference_states() const;
137 };
138
139 extern CGV_API std::vector<vr_driver*>& get_vr_drivers();
141 extern CGV_API void register_driver(vr_driver* vrd);
143 template <typename T>
144 struct driver_registry
145 {
146 driver_registry(const std::string& options)
147 {
148 register_driver(new T(options));
149 }
150 };
151
152
155
156 extern CGV_API std::vector<void*> scan_vr_kits();
158 extern CGV_API vr_kit* replace_by_index(int vr_kit_index, vr_kit* new_kit_ptr);
160 extern CGV_API bool replace_by_pointer(vr_kit* old_kit_ptr, vr_kit* new_kit_ptr);
161
163 extern CGV_API vr_kit* get_vr_kit(void* vr_kit_handle);
165 extern CGV_API bool unregister_vr_kit(void* vr_kit_handle, vr_kit* vr_kit_ptr);
167}
169
170#include <cgv/config/lib_end.h>
void set_driver_calibration_matrix(vr_driver *driver, const float calibration_matrix[12]) const
single point of write access to calibration transformation of vr drivers
Definition vr_driver.cxx:6
vr_calibration_base()
nothing to be done in contructor
Definition vr_driver.cxx:11
interface class for vr drivers.
Definition vr_driver.h:57
void set_index(unsigned _idx)
write access to driver index is restricted to the register_driver() function
void clear_tracking_reference_states()
remove all tracking reference states
Definition vr_driver.cxx:28
void mark_tracking_references_as_untracked()
mark all tracking reference states as untracked
Definition vr_driver.cxx:34
void set_calibration_transformation(const float new_transformation_matrix[12])
write access to calibration transformation is reserved to classes derived from vr_calibration_base
Definition vr_driver.cxx:79
virtual float get_action_zone_height() const =0
return height of action zone in meters
void calibrate_pose(float(&pose)[12]) const
in case calibration matrix is enabled, transform given pose in place
Definition vr_driver.cxx:55
void put_calibration_transformation(float transformation_matrix[12]) const
read access to calibration transformation stored as 3x4-matrix
Definition vr_driver.cxx:50
vr_tracking_system_info tracking_system_info
store tracking system info to be filled by driver implementations
Definition vr_driver.h:78
virtual const std::map< std::string, vr_trackable_state > & get_tracking_reference_states() const
provide read only access to tracking reference states
Definition vr_driver.cxx:99
bool is_calibration_transformation_enabled() const
check whether calibration transformation is enabled; false after construction and typically set to tr...
Definition vr_driver.cxx:94
void replace_vr_kit(void *handle, vr_kit *kit)
call this method during replacement of vr kits. In case vr kit handle had been registered before it i...
friend void CGV_API register_driver(vr_driver *vrd)
register a new driver
void register_vr_kit(void *handle, vr_kit *kit)
call this method during scanning of vr kits. In case vr kit handle had been registered before,...
vr_trackable_state & ref_tracking_reference_state(const std::string &serial_nummer)
provide reference to tracking reference states
Definition vr_driver.cxx:22
virtual const vr_tracking_system_info & get_tracking_system_info() const
provide information on tracking system
virtual float get_floor_level() const =0
return the floor level relativ to the world origin
virtual bool replace_by_pointer(vr_kit *old_kit_ptr, vr_kit *new_kit_ptr)=0
scan all connected vr kits and return a vector with their ids
virtual std::string get_driver_name() const =0
return name of driver
vr_driver()
protected constructor
Definition vr_driver.cxx:41
void enable_calibration_transformation()
enable use of calibration transformation
Definition vr_driver.cxx:84
void put_x_direction(float *x_dir) const
put a 3d x direction into passed array
virtual void put_action_zone_bounary(std::vector< float > &boundary) const =0
return a vector of floor points defining the action zone boundary as a closed polygon
friend class vr_kit
allow vr_kit access to ref_reference_state and tracking_system_info
Definition vr_driver.h:76
virtual bool is_installed() const =0
return whether driver is installed
void disable_calibration_transformation()
disable use of calibration transformation
Definition vr_driver.cxx:89
virtual void put_up_direction(float *up_dir) const =0
put a 3d up direction into passed array
virtual std::vector< void * > scan_vr_kits()=0
scan all connected vr kits and return a vector with their ids
virtual vr_kit * replace_by_index(int &index, vr_kit *new_kit_ptr)=0
scan all connected vr kits and return a vector with their ids
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
Definition vr_kit.h:69
the vr namespace for virtual reality support
vr_kit * get_vr_kit(void *handle)
query a pointer to a vr kit by its device handle, function can return null pointer in case that no vr...
bool unregister_vr_kit(void *handle, vr_kit *vr_kit_ptr)
unregister a previously registered vr kit by handle and pointer
std::vector< vr_driver * > & get_vr_drivers()
return a vector with all registered vr drivers
void register_driver(vr_driver *vrd)
register a new driver
std::vector< void * > scan_vr_kits()
iterate all registered vr drivers to scan for vr kits and return vector of vr kit handles
bool replace_by_pointer(vr_kit *old_kit_ptr, vr_kit *new_kit_ptr)
scan vr kits and if one with given pointer exists, replace it by passed kit; return whether replaceme...
vr_kit * replace_by_index(int vr_kit_index, vr_kit *new_kit_ptr)
scan vr kits and if one of given index exists replace it by passed kit and return index to replaced k...
a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format
Definition vr_state.h:94
information provided for tracking system
Definition vr_info.h:176