etrobocon2019 feat.KatLab  ece30a9a007fff7d3ad48592c0d09a74643377bb
BlockBingo.h
[詳解]
1 
6 #ifndef BLOCKBINGO_H
7 #define BLOCKBINGO_H
8 
9 #include <array>
10 #include "Controller.h"
11 #include "Navigator.h"
12 
13 enum class Order { MOVE, SPIN, COLOR };
14 
20 struct OrderProperty {
21  Order orderName; //命令の内容
22  double paramValue; // Navigator.spinの引数で使用する
23  Color paramColor; // Navigator.moveToSpecifiedColorの引数で使用する
24 };
25 
26 class BlockBingo {
27  private:
28  Controller& controller;
29 
30  public:
35  explicit BlockBingo(Controller& controller_);
36 
42  void moveCircle4OfL();
43 
48  template <int N>
49  void execOrder(std::array<OrderProperty, N>& propertys)
50  {
51  Navigator navigator(controller);
52 
53  for(const auto& property : propertys) {
54  if(property.orderName == Order::MOVE) {
55  navigator.move(350.0, 10, 0.6);
56  } else if(property.orderName == Order::SPIN) {
57  navigator.spin(property.paramValue, (property.paramValue > 0));
58  } else if(property.orderName == Order::COLOR) {
59  navigator.moveToSpecifiedColor(property.paramColor, 10);
60  } else {
61  controller.stopMotor();
62  controller.speakerPlayToneFS6(100);
63  }
64  }
65  }
66 };
67 
68 #endif
void stopMotor()
Definition: Controller.cpp:272
Order
Definition: BlockBingo.h:13
double paramValue
Definition: BlockBingo.h:22
void spin(double angle, bool clockwise=true, int pwm=10)
走行体を回頭させる(yawing)
Definition: Navigator.cpp:97
static void speakerPlayToneFS6(int duration)
Definition: Controller.cpp:21
Color paramColor
Definition: BlockBingo.h:23
void moveToSpecifiedColor(Color specifiedColor, int pwm=30)
Definition: Navigator.cpp:74
void move(double specifiedDistance, int pwm=30, const double pGain=0.0)
specifiedDistanceの値でbackwardかforwardを呼び出す。
Definition: Navigator.cpp:20
void execOrder(std::array< OrderProperty, N > &propertys)
Definition: BlockBingo.h:49
Order orderName
Definition: BlockBingo.h:21
Color
Definition: Controller.h:32
直進と後進できるクラス