etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
Distinguisher.h
[詳解]
1 
7 #ifndef __DISTINGUISHER_H__
8 #define __DISTINGUISHER_H__
9 
10 #include "Controller.h"
11 #include <algorithm>
12 #include <array>
13 #include <cstdint>
14 #include <map>
15 
16 enum struct Color { NONE, BLACK, WHITE, RED, BLUE, YELLOW, GREEN };
17 
21 struct Hsv {
22  explicit Hsv(Color color_, double h_, double s_, double v_, double threshold_distance_,
23  double start_h_, double end_h_)
24  : color(color_),
25  h(h_),
26  s(s_),
27  v(v_),
28  threshold_distance(threshold_distance_),
29  start_h(start_h_),
30  end_h(end_h_)
31  {
32  }
34  double h;
35  double s;
36  double v;
38  double start_h;
39  double end_h;
40 };
41 
42 struct Rgb {
43  std::uint16_t r = 0;
44  std::uint16_t g = 0;
45  std::uint16_t b = 0;
46 };
47 
48 namespace etrobocon2018_test {
49  class DistinguisherTest;
50 }
51 
57 
58  public:
61  explicit Distinguisher(Controller& controller_) : controller(controller_) {}
62 
65  Color getColor();
66 
68  double last_distance = 0.0;
69 
71  double threshold_distance = 400;
72 
73  Hsv hsv{ Color::NONE, 0, 0, 0, 400, 0, 0 };
74 
75  private:
76  void setRawColor2Rgb();
77  void convertRgbToHsv(Rgb rgb_);
78  void distingishColor();
79  void judgement(const Hsv& hsv_, double& min);
80  double distanceColor(Hsv target_color);
81 
83  Color color = Color::NONE;
84  Rgb rgb;
85  const Hsv RED{ Color::RED, 0, 92, 35, 400, 0, 60 };
86  const Hsv AltRED{ Color::RED, 0, 92, 35, 400, 290, 360 };
87  const Hsv BLUE{ Color::BLUE, 190, 75, 19, 400, 160, 240 };
88  const Hsv GREEN{ Color::GREEN, 111, 70, 26, 400, 90, 150 };
89  const Hsv YELLOW{ Color::YELLOW, 63, 88, 46, 400, 50, 80 };
90  const Hsv WHITE{ Color::WHITE, 86, 41, 53, 400, 40, 80 };
91  const Hsv BLACK{ Color::BLACK, 80, 42, 6, 400, 0, 20 };
92  const Hsv GREY{ Color::BLACK, 83, 15, 20, 400, 10, 30 };
93 };
94 
95 #endif
Hsv(Color color_, double h_, double s_, double v_, double threshold_distance_, double start_h_, double end_h_)
Definition: Distinguisher.h:22
double start_h
Definition: Distinguisher.h:38
double threshold_distance
Definition: Distinguisher.h:71
double s
Definition: Distinguisher.h:35
Color
Definition: Distinguisher.h:16
double end_h
Definition: Distinguisher.h:39
std::uint16_t g
Definition: Distinguisher.h:44
double v
Definition: Distinguisher.h:36
double threshold_distance
Definition: Distinguisher.h:37
std::uint16_t r
Definition: Distinguisher.h:43
走行体のカラーセンサを用いて、RGB情報より色を推定するクラス。
Definition: Distinguisher.h:55
Distinguisher(Controller &controller_)
Definition: Distinguisher.h:61
double last_distance
Definition: Distinguisher.h:68
色とHsv情報を保持するクラス。
Definition: Distinguisher.h:21
Color getColor()
double h
Definition: Distinguisher.h:34
Color color
Definition: Distinguisher.h:33
std::uint16_t b
Definition: Distinguisher.h:45