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
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);
82 void clear_tracking_reference_states();
84 void mark_tracking_references_as_untracked();
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;
126 void enable_calibration_transformation();
128 void disable_calibration_transformation();
130 bool is_calibration_transformation_enabled() const;
131
132
134 virtual const std::map<std::string, vr_trackable_state>& get_tracking_reference_states() const;
136 virtual const vr_tracking_system_info& get_tracking_system_info() const;
137 };
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>
145 {
146 driver_registry(const std::string& options)
147 {
148 register_driver(new T(options));
149 }
150 };
152
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>
base class with write access to driver calibration matrix
Definition vr_driver.h:37
interface class for vr drivers.
Definition vr_driver.h:57
virtual float get_action_zone_height() const =0
return height of action zone in meters
vr_tracking_system_info tracking_system_info
store tracking system info to be filled by driver implementations
Definition vr_driver.h:78
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
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
virtual bool is_installed() const =0
return whether driver is installed
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...
use this template to register your own driver
Definition vr_driver.h:145
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