ILLIXR: Illinois Extended Reality Testbed
global_module_defs.hpp
1 // Common parameters. Ultimately, these need to be moved to a yaml file.
2 #pragma once
3 
4 #include "relative_clock.hpp"
5 
6 #include <algorithm>
7 #include <cmath>
8 #include <stdexcept>
9 #include <string>
10 
11 namespace ILLIXR {
12 
15  // Display width in pixels
16  static constexpr unsigned width_pixels = 2560;
17 
18  // Display height in pixels
19  static constexpr unsigned height_pixels = 1440;
20 
21  // Display width in meters
22  static constexpr float width_meters = 0.11047f;
23 
24  // Display height in meters
25  static constexpr float height_meters = 0.06214f;
26 
27  // Separation between lens centers in meters
28  static constexpr float lens_separation = width_meters / 2.0f;
29 
30  // Vertical position of the lens in meters
31  static constexpr float lens_vertical_position = height_meters / 2.0f;
32 
33  // Display horizontal field-of-view in degrees
34  static constexpr float fov_x = 90.0f;
35 
36  // Display vertical field-of-view in degrees
37  static constexpr float fov_y = 90.0f;
38 
39  // Meters per tangent angle at the center of the HMD (required by timewarp_gl's distortion correction)
40  static constexpr float meters_per_tan_angle = width_meters / (2 * (fov_x * M_PI / 180.0f));
41 
42  // Inter-pupilary distance (ipd) in meters
43  static constexpr float ipd = 0.064f;
44 
45  // Display refresh rate in Hz
46  static constexpr float frequency = 120.0f;
47 
48  // Display period in nanoseconds
49  static constexpr duration period = freq2period(frequency);
50 
51  // Chromatic aberration constants
52  static constexpr float aberration[4] = {-0.016f, 0.0f, 0.024f, 0.0f};
53 };
54 
57  // Near plane distance in meters
58  static constexpr float near_z = 0.1f;
59 
60  // Far plane distance in meters
61  static constexpr float far_z = 20.0f;
62 };
63 
67 inline bool str_to_bool(const std::string& var) {
68  std::string temp = var;
69  std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper);
70  return (temp == "TRUE") ? true
71  : (temp == "FALSE") ? false
72  : throw std::runtime_error("Invalid conversion from std::string to bool");
73 }
74 
76 inline std::string getenv_or(const std::string& var, std::string default_) {
77  if (std::getenv(var.c_str())) {
78  return {std::getenv(var.c_str())};
79  } else {
80  return default_;
81  }
82 }
83 
84 } // namespace ILLIXR
RAC_ERRNO_MSG.
Definition: data_format.hpp:15
std::string getenv_or(const std::string &var, std::string default_)
Temporary environment variable getter. Not needed once #198 is merged.
Definition: global_module_defs.hpp:76
bool str_to_bool(const std::string &var)
Convert a string containing a (python) boolean to the bool type.
Definition: global_module_defs.hpp:67
Display parameters.
Definition: global_module_defs.hpp:14
Rendering parameters.
Definition: global_module_defs.hpp:56