cgv
Loading...
Searching...
No Matches
vr_info.cxx
1#include "vr_info.h"
2#include "iomanip"
3
4namespace vr {
10 std::ostream& operator << (std::ostream& os, const vr_device_info& di)
11 {
12 os << "serial number = " << di.serial_number << std::endl;
13 os << "model number = " << di.model_number << std::endl;
14 for (const auto& pp : di.variable_parameters)
15 os << pp.first << " = " << pp.second << std::endl;
16 return os;
17 }
26 std::ostream& operator << (std::ostream& os, const vr_trackable_info& TI)
27 {
28 os << static_cast<const vr_device_info&>(TI);
29 os << "device_type = " << TI.device_type << std::endl;
30 os << "device_class = " << TI.device_class << std::endl;
31 if (TI.is_wireless)
32 os << "is wireless" << std::endl;
34 os << "battery charge level = " << TI.battery_charge_level << std::endl;
36 os << "has proximity sensor" << std::endl;
37 return os;
38 }
40 {
43 fps = 60;
44 ipd = 0;
47
48 /*
49 std::fill(camera_to_head_transform[0], camera_to_head_transform[0] + 12, 0.0f);
50 std::fill(camera_to_head_transform[1], camera_to_head_transform[1] + 12, 0.0f);
51 std::fill(imu_to_head_transform, imu_to_head_transform + 12, 0.0f);
52 imu_gyro_bias[0] = imu_gyro_bias[1] = imu_gyro_bias[2] = 0.0f;
53 imu_gyro_scale[0] = imu_gyro_scale[1] = imu_gyro_scale[2] = 1.0f;
54 imu_accelerometer_bias[0]= imu_accelerometer_bias[1]=imu_accelerometer_bias[2]=0.0f;
55 imu_accelerometer_scale[0]= imu_accelerometer_scale[1]= imu_accelerometer_scale[2]=1.0f;
56 */
58 }
59 void stream_vec3(std::ostream& os, const float vec[3])
60 {
61 os << "[";
62 for (int i = 0; i < 3; ++i) {
63 if (i > 0)
64 os << ", ";
65 os << vec[i];
66 }
67 os << "]" << std::endl;
68 }
69 void stream_pose(std::ostream& os, const float mat[12])
70 {
71 os << "\n";
72 for (int i = 0; i < 3; ++i) {
73 os << " |";
74 for (int j = 0; j < 4; ++j)
75 os << std::setw(9) << std::setprecision(3) << mat[i + 3 * j];
76 os << "|\n";
77 }
78 }
79 std::ostream& operator << (std::ostream& os, const vr_hmd_info& HI)
80 {
81 os << static_cast<const vr_trackable_info&>(HI);
83 os << "reports time since vsynch with " << HI.seconds_vsynch_to_photons << " seconds to photons" << std::endl;
84 os << "fps = " << HI.fps << std::endl;
85 os << "ipd = " << HI.ipd << std::endl;
86 if (HI.number_cameras > 0)
87 os << "number cameras = " << HI.number_cameras << std::endl;
88 /*
89 os << "head_to_eye_distance = " << HI.head_to_eye_distance << std::endl;
90 if (HI.number_cameras == 1)
91 os << "camera to head transform = "; stream_pose(os, HI.camera_to_head_transform[0]);
92 if (HI.number_cameras == 2) {
93 os << "left camera to head transform = "; stream_pose(os, HI.camera_to_head_transform[0]);
94 os << "right camera to head transform = "; stream_pose(os, HI.camera_to_head_transform[1]);
95 }
96 os << "" << HI.imu_to_head_transform[12] << std::endl;
97 os << "imu gyro bias = "; stream_vec3(os, HI.imu_gyro_bias);
98 os << "imu gyro scale = "; stream_vec3(os, HI.imu_gyro_scale);
99 os << "imu accel bias = "; stream_vec3(os, HI.imu_accelerometer_bias);
100 os << "imu accel scale = "; stream_vec3(os, HI.imu_accelerometer_scale);
101 */
103 os << "has lighthouse 2.0 features" << std::endl;
104 return os;
105 }
108 {
109 type = VRC_NONE;
110 nr_inputs = 0;
111 std::fill(input_type, input_type + max_nr_controller_inputs, VRI_NONE);
112 nr_axes = 0;
113 std::fill(axis_type, axis_type + max_nr_controller_axes, VRA_NONE);
115 }
116 std::ostream& operator << (std::ostream& os, const vr_controller_info& CI)
117 {
118 const char* controller_type_strings[] = { "none", "controller", "tracker" };
119 const char* input_type_strings[] = { "none", "trigger", "pad", "strick" };
120 const char* axis_type_strings[] = { "none", "trigger", "pad_x", "pad_y", "strick_x", "stick_y" };
121 os << "type = " << controller_type_strings[CI.type] << std::endl;
122 os << static_cast<const vr_trackable_info&>(CI);
123 if (CI.nr_inputs == 0)
124 os << "no inputs provided" << std::endl;
125 else {
126 os << "input types = [";
127 for (int i = 0; i < CI.nr_inputs; ++i) {
128 if (i > 0)
129 os << ",";
130 os << input_type_strings[CI.input_type[i]];
131 }
132 os << "]" << std::endl;
133 os << "axis types = [";
134 for (int ai = 0; ai < CI.nr_axes; ++ai) {
135 if (ai > 0)
136 os << ",";
137 os << axis_type_strings[CI.axis_type[ai]];
138 }
139 os << "]" << std::endl;
140 }
141 os << "button support = " << get_state_flag_string(CI.supported_buttons) << std::endl;
142 return os;
143 }
147
148 std::ostream& operator << (std::ostream& os, const vr_kit_info& VI)
149 {
150 os << "VR KIT\n->HMD\n" << VI.hmd;
151 for (int ci = 0; ci < max_nr_controllers; ++ci)
152 os << "->CONTROLLER[" << ci << "]\n" << VI.controller[ci];
153 return os;
154 }
155
158 {
159 mode = "undef";
160 z_near = 0.1f;
161 z_far = 4.0f;
162 frustum[0] = -0.1f;
163 frustum[1] = 0.1f;
164 frustum[2] = -0.1f;
165 frustum[3] = 0.1f;
166 }
167
168 std::ostream& operator << (std::ostream& os, const vr_tracking_reference_info& TI)
169 {
170 os << static_cast<const vr_trackable_info&>(TI);
171 os << "tracking mode = " << TI.mode << std::endl;
172 os << "z range = [" << TI.z_near << ", " << TI.z_far << "]" << std::endl;
173 os << "frustum = [" << TI.frustum[0] << ", " << TI.frustum[1] << ", "
174 << TI.frustum[2] << ", " << TI.frustum[3] << "]" << std::endl;
175 return os;
176 }
177
181 std::ostream& operator << (std::ostream& os, const vr_tracking_system_info& TSI)
182 {
183 os << "tracking system name = " << TSI.name << std::endl;
184 for (const auto& rr : TSI.references) {
185 os << "tracking reference " << rr.first << " {" << std::endl;
186 os << rr.second << "}" << std::endl;
187 }
188 return os;
189 }
190}
the vr namespace for virtual reality support
VRButtonStateFlags
one flag for each vr controller button
Definition vr_state.h:62
const unsigned max_nr_controller_axes
maximum number of axes per controller
Definition vr_state.h:23
const unsigned max_nr_controllers
maximum number of attachable controller and tracker devices
Definition vr_state.h:19
std::string get_state_flag_string(VRButtonStateFlags flags)
convert flags to string
Definition vr_state.cxx:110
std::ostream & operator<<(std::ostream &os, const vr_device_info &di)
stream out operator for device infos
Definition vr_info.cxx:10
const unsigned max_nr_controller_inputs
maximum number of inputs per controller
Definition vr_state.h:21
information provided for controller devices
Definition vr_info.h:120
vr_controller_info()
construct with default
Definition vr_info.cxx:107
int32_t nr_axes
total number of axes provided by all inputs
Definition vr_info.h:130
VRControllerType type
controller type
Definition vr_info.h:122
VRButtonStateFlags supported_buttons
one flag per button telling whether it is supported
Definition vr_info.h:137
VRInputType input_type[max_nr_controller_inputs]
type of up to 5vr::max_nr_controller_inputs inputs built into the controller
Definition vr_info.h:128
VRAxisType axis_type[max_nr_controller_axes]
axis type for each of the vr::max_nr_controller_axes axes in the state
Definition vr_info.h:135
int32_t nr_inputs
number of used inputs
Definition vr_info.h:126
information provided for any device type
Definition vr_info.h:16
std::string serial_number
unique identifier of device
Definition vr_info.h:18
vr_device_info()
construct empty info
Definition vr_info.cxx:6
std::string model_number
number describing the device type
Definition vr_info.h:20
std::map< std::string, std::string > variable_parameters
a map from parameter name to parameter value used for all device parameters that are not explicitly d...
Definition vr_info.h:22
information provided for hmd device
Definition vr_info.h:54
float fps
frame rate
Definition vr_info.h:60
bool reports_time_since_vsynch
whether time since vsynch is reported
Definition vr_info.h:56
float ipd
interpupilar distance measured in meters
Definition vr_info.h:62
bool lighthouse_2_0_features
whether lighthouse 2.0 features are supported
Definition vr_info.h:80
vr_hmd_info()
construct with default values
Definition vr_info.cxx:39
float seconds_vsynch_to_photons
seconds from vsynch to photons
Definition vr_info.h:58
float head_to_eye_distance
distance from head origin to eye centers in meters
Definition vr_info.h:64
int32_t number_cameras
number of cameras
Definition vr_info.h:66
information provided for a vr kit
Definition vr_info.h:146
vr_kit_info()
construct with default values
Definition vr_info.cxx:144
vr_hmd_info hmd
information for head mounted display
Definition vr_info.h:150
vr_controller_info controller[max_nr_controllers]
information for attached controllers and trackers
Definition vr_info.h:152
information provided for trackable devices
Definition vr_info.h:32
bool provides_battery_charge_level
whether one can query battery charge level
Definition vr_info.h:40
bool has_proximity_sensor
whether device has proximity sensor
Definition vr_info.h:44
float battery_charge_level
battery charge level in percentage (0 .. empty, 1 .. full)
Definition vr_info.h:42
std::string device_type
type name of device
Definition vr_info.h:34
int32_t device_class
index of device class
Definition vr_info.h:36
bool is_wireless
whether device is wireless
Definition vr_info.h:38
vr_trackable_info()
construct with default values
Definition vr_info.cxx:18
information provided for a base station / tracking reference
Definition vr_info.h:161
vr_tracking_reference_info()
construct with default values
Definition vr_info.cxx:157
float frustum[4]
frustum relative to z_near in the order left, right, bottom, up
Definition vr_info.h:167
float z_near
near and far clipping planes of tracking frustum in meters
Definition vr_info.h:165
std::string mode
tracking mode string
Definition vr_info.h:163
information provided for tracking system
Definition vr_info.h:176
vr_tracking_system_info()
construct with default values
Definition vr_info.cxx:178
std::string name
name of tracking system
Definition vr_info.h:178
std::map< std::string, vr_tracking_reference_info > references
map from serial number to info of corresponding tracking reference
Definition vr_info.h:180