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  "X.**....*........" // 5
109  , "X....**...*......" // 6
110  , ".*...**........." // 3
111  , ".........*....**" // 4
112  , "..*.....**......" // 1
113  , "*......**......." // 2
114  , "....*.*..*......" // 10
115  , ".*.*.*.........." // 8
116  , ".........*.**..." // 9
117  , "X**...........*.." // 7
118  , "....*.*......*.." // 11
119  , "X*.......*.*....." // 28
120  , "X.*........*.*..." // 27
121  , "X.*.........*.*.." // 25
122  , "..*..*.*........" // 15
123  , "....*...*.*....." // 16
124  , "...*.*........*." // 17
125  , "...*.....*.*...." // 18
126  , "....*......*..*." // 19
127  , "....*..*....*..." // 20
128  , "X..*...*........*" // 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 =
175  OsvrHdkLedIdentifier_SENSOR0_PATTERNS;
176  patterns.insert(end(patterns),
177  begin(OsvrHdkLedIdentifier_SENSOR1_PATTERNS),
178  end(OsvrHdkLedIdentifier_SENSOR1_PATTERNS));
179  ret = createHDKLedIdentifier(patterns);
180  return ret;
181  }
182 
183  LedIdentifierPtr createHDKLedIdentifierSimulated(uint8_t sensor) {
184  LedIdentifierPtr ret;
185  switch (sensor) {
186  case 0:
187  ret = createHDKLedIdentifier(
188  OsvrHdkLedIdentifier_SENSOR0_PATTERNS_ORIGINAL);
189  break;
190  case 1:
191  ret = createHDKLedIdentifier(
192  OsvrHdkLedIdentifier_SENSOR1_PATTERNS_ORIGINAL);
193  default:
194  BOOST_ASSERT_MSG(sensor < 2, "Valid sensors are only 0 or 1!");
195  break;
196  }
197  return ret;
198  }
199 
200  // clang-format off
203  static const std::vector<std::string>
204  OsvrHdkLedIdentifier_RANDOM_IMAGES_PATTERNS = {
205  "..*....." // 7
206  , "...*...." // 8
207  , ".......*" // 9
208  , "......*." // 10
209  , ".......*" // 11
210  , "..*....." // 12
211  , "....*..." // 13
212  , "....*..*" // 14
213  , "********" // 15
214  , "........" // 16
215  , "********" // 17
216  , "....*..." // 18
217  , "...*.*.." // 19
218  , "...*...." // 20
219  , "....*.*." // 21
220  , "...*.***" // 22
221  , ".*......" // 23
222  , "..*...*." // 24
223  , "....*.*." // 25
224  , ".*.*.*.." // 26
225  , "........" // 27
226  , "**......" // 28
227  , ".*...**." // 29
228  , "........" // 30
229  , "..*....." // 31
230  , "*......*" // 32
231  , "...*...." // 33
232  , "...**..." // 34
233  , ".......*" // 35
234  , "*..*..*." // 36
235  , "*......." // 37
236  , "......**" // 38
237  , "........" // 39
238  , "........" // 40
239  };
240  // clang-format on
241  LedIdentifierPtr createRandomHDKLedIdentifier() {
242  return createHDKLedIdentifier(
243  OsvrHdkLedIdentifier_RANDOM_IMAGES_PATTERNS);
244  }
245 } // End namespace vbtracker
246 } // End namespace osvr