OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
HDKLedIdentifierFactory.cpp
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 // Internal Includes
27 #include "HDKLedIdentifier.h"
28 
29 // Library/third-party includes
30 #include <boost/assert.hpp>
31 
32 // Standard includes
33 // - none
34 
35 namespace osvr {
36 namespace vbtracker {
37 
39  static inline LedIdentifierPtr
40  createHDKLedIdentifier(const PatternStringList &patterns) {
41  LedIdentifierPtr ret{new OsvrHdkLedIdentifier(patterns)};
42  return ret;
43  }
44 
45  // clang-format off
51  static const std::vector<std::string>
52  OsvrHdkLedIdentifier_SENSOR0_PATTERNS_ORIGINAL = {
53  "..*.....*...*..." // 7 1
54  , "...*......*...*." // 8 2
55  , ".......*...*...*" // 9 3
56  , "......*...*..*.." // 10 4
57  , ".......*....*..*" // 11 5
58  , "..*.....*..*...." // 12 6
59  , "....*......*..*." // 13 7
60  , "....*..*....*..." // 14 8
61  , "..*...*........*" // 15 9
62  , "........*..*..*." // 16 10
63  , "..*..*.*........" // 17 11
64  , "....*...*.*....." // 18 12
65  , "...*.*........*." // 19 13
66  , "...*.....*.*...." // 20 14
67  , "....*.*......*.." // 21 15
68  , "*.......*.*....." // 22 16
69  , ".*........*.*..." // 23 17
70  , ".*.........*.*.." // 24 18
71  , "....*.*..*......" // 25 19
72  , ".*.*.*.........." // 26 20
73  , ".........*.**..." // 27 21
74  , "**...........*.." // 28 22
75  , ".*...**........." // 29 23
76  , ".........*....**" // 30 24
77  , "..*.....**......" // 31 25
78  , "*......**......." // 32 26
79  , "...*.......**..." // 33 27
80  , "...**.....*....." // 34 28
81  , ".**....*........" // 35 29
82  , "....**...*......" // 36 30
83  , "*...........**.." // 37 31
84  , "......**.*......" // 38 32
85  , ".............***" // 39 33
86  , "..........*....." // 40 34
87  };
88 
92  static const std::vector<std::string>
93  OsvrHdkLedIdentifier_SENSOR1_PATTERNS_ORIGINAL = {
94  "***...*........*" // 1 1
95  , "...****..*......" // 2 2
96  , "*.*..........***" // 3 3
97  , "**...........***" // 4 4
98  , "*....*....*....." // 5 5
99  , "...*....*...*..." // 6 6
100  };
101 
106  static const std::vector<std::string>
107  OsvrHdkLedIdentifier_SENSOR0_PATTERNS = {
108  ".**....*........" // 5
109  , "....**...*......" // 6
110  , ".*...**........." // 3
111  , ".........*....**" // 4
112  , "..*.....**......" // 1
113  , "*......**......." // 2
114  , "....*.*..*......" // 10
115  , ".*.*.*.........." // 8
116  , ".........*.**..." // 9
117  , "**...........*.." // 7
118  , "....*.*......*.." // 11
119  , "*.......*.*....." // 28
120  , ".*........*.*..." // 27
121  , ".*.........*.*.." // 25
122  , "..*..*.*........" // 15
123  , "....*...*.*....." // 16
124  , "...*.*........*." // 17
125  , "...*.....*.*...." // 18
126  , "....*......*..*." // 19
127  , "....*..*....*..." // 20
128  , "..*...*........*" // 21
129  , "........*..*..*." // 22
130  , ".......*...*...*" // 23
131  , "......*...*..*.." // 24
132  , ".......*....*..*" // 14
133  , "..*.....*..*...." // 26
134  , "*....*....*....." // 13
135  , "...*....*...*..." // 12
136  , "..*.....*...*..." // 29
137  , "...*......*...*." // 30
138  , "***...*........*" // 31
139  , "...****..*......" // 32
140  , "*.*..........***" // 33
141  , "**...........***" // 34
142  };
143 
146  static const std::vector<std::string>
147  OsvrHdkLedIdentifier_SENSOR1_PATTERNS = {
148  "X............**.." // 37 31 // never actually turns on in production
149  , "......**.*......" // 38 32
150  , ".............***" // 39 33
151  , "X..........*....." // 40 34 // never actually turns on in production
152  , "...*.......**..." // 33 27
153  , "...**.....*....." // 34 28
154  };
155  // clang-format on
156 
157  LedIdentifierPtr createHDKLedIdentifier(uint8_t sensor) {
158  LedIdentifierPtr ret;
159  switch (sensor) {
160  case 0:
161  ret = createHDKLedIdentifier(OsvrHdkLedIdentifier_SENSOR0_PATTERNS);
162  break;
163  case 1:
164  ret = createHDKLedIdentifier(OsvrHdkLedIdentifier_SENSOR1_PATTERNS);
165  default:
166  BOOST_ASSERT_MSG(sensor < 2, "Valid sensors are only 0 or 1!");
167  break;
168  }
169  return ret;
170  }
171 
172  LedIdentifierPtr createHDKUnifiedLedIdentifier() {
173  LedIdentifierPtr ret;
174  std::vector<std::string> patterns = OsvrHdkLedIdentifier_SENSOR0_PATTERNS;
175  patterns.insert(end(patterns),
176  begin(OsvrHdkLedIdentifier_SENSOR1_PATTERNS),
177  end(OsvrHdkLedIdentifier_SENSOR1_PATTERNS));
178  ret = createHDKLedIdentifier(patterns);
179  return ret;
180  }
181 
182  LedIdentifierPtr createHDKLedIdentifierSimulated(uint8_t sensor) {
183  LedIdentifierPtr ret;
184  switch (sensor) {
185  case 0:
186  ret = createHDKLedIdentifier(OsvrHdkLedIdentifier_SENSOR0_PATTERNS_ORIGINAL);
187  break;
188  case 1:
189  ret = createHDKLedIdentifier(OsvrHdkLedIdentifier_SENSOR1_PATTERNS_ORIGINAL);
190  default:
191  BOOST_ASSERT_MSG(sensor < 2, "Valid sensors are only 0 or 1!");
192  break;
193  }
194  return ret;
195  }
196 
197  // clang-format off
200  static const std::vector<std::string>
201  OsvrHdkLedIdentifier_RANDOM_IMAGES_PATTERNS = {
202  "..*....." // 7
203  , "...*...." // 8
204  , ".......*" // 9
205  , "......*." // 10
206  , ".......*" // 11
207  , "..*....." // 12
208  , "....*..." // 13
209  , "....*..*" // 14
210  , "********" // 15
211  , "........" // 16
212  , "********" // 17
213  , "....*..." // 18
214  , "...*.*.." // 19
215  , "...*...." // 20
216  , "....*.*." // 21
217  , "...*.***" // 22
218  , ".*......" // 23
219  , "..*...*." // 24
220  , "....*.*." // 25
221  , ".*.*.*.." // 26
222  , "........" // 27
223  , "**......" // 28
224  , ".*...**." // 29
225  , "........" // 30
226  , "..*....." // 31
227  , "*......*" // 32
228  , "...*...." // 33
229  , "...**..." // 34
230  , ".......*" // 35
231  , "*..*..*." // 36
232  , "*......." // 37
233  , "......**" // 38
234  , "........" // 39
235  , "........" // 40
236  };
237  // clang-format on
238  LedIdentifierPtr createRandomHDKLedIdentifier() {
239  return createHDKLedIdentifier(
240  OsvrHdkLedIdentifier_RANDOM_IMAGES_PATTERNS);
241  }
242 } // End namespace vbtracker
243 } // End namespace osvr