ETrobocon2017 - 片山研究所モデルベース開発推進事業部
RightNormalCourse.cpp
[詳解]
1 
7 #include "RightNormalCourse.h"
8 
11  status = old_status = RightStatus::STRAIGHT;
12 }
13 
15  switch(status){
17  lineTracerWalker.speedControl.setPid ( 2.0, 4.8, 0.024, 150.0 );
18  lineTracerWalker.turnControl.setPid ( 2.0, 1.0, 0.048, 40.0 );
19  break;
20 
22  lineTracerWalker.speedControl.setPid ( 2.0, 4.8, 0.024, 150.0 );
23  lineTracerWalker.turnControl.setPid ( 4.0, 2.0, 0.09, 40.0 );
24  //lineTracerWalker.turnControl.setPid ( 4.0, 2.0, 0.096, 40.0 );
25  break;
26 
28  lineTracerWalker.speedControl.setPid ( 4.0, 0.8, 0.1, 130.0 );
29  lineTracerWalker.turnControl.setPid ( 2.0, 0.5, 0.048, 35.0 );
30  break;
31 
33  lineTracerWalker.speedControl.setPid ( 4.0, 0.8, 0.1, 100.0 );
34  lineTracerWalker.turnControl.setPid ( 4.0, 2.0, 0.096, 35.0 );
35  break;
36 
37  case RightStatus::STOP: stop(); break;
38  default: stop();
39  }
40  if (status == RightStatus::STOP) return false;
41  return true;
42 }
43 
44 bool RightNormalCourse::statusCheck(int32_t countL, int32_t countR){
45  distanse_total = distance.getDistanceTotal(countL, countR);
46  old_status = status;
47  if(distanse_total < 3240)status = RightStatus::STRAIGHT;
48  else if(distanse_total < 7500)status = RightStatus::CURVE_RIGHT;
49  else if(distanse_total < 9200)status = RightStatus::CURVE_LEFT_SHORT;
50  else if(distanse_total < 10800)status = RightStatus::CURVE_LEFT;
51  else if(distanse_total < 12800)status = RightStatus::CURVE_RIGHT;
52  else if(distanse_total < 16000)status = RightStatus::STRAIGHT;
53  else status = RightStatus::STOP;
54  if(old_status != status) return true;
55  return false;
56 }
57 
59  return (int)status;
60 }
RコースのNormalCourseの処理を行うクラス
void isLeftsideLine(bool b)
bool statusCheck(int32_t countL, int32_t countR)
Distance distance
Definition: NormalCourse.h:13
void setPid(double _p_gain, double _i_gain, double _d_gain, double _target)
Definition: Pid.cpp:40
LineTracerWalker lineTracerWalker
Definition: NormalCourse.h:10
std::int32_t getDistanceTotal(std::int32_t countL, std::int32_t countR)
Definition: Distance.cpp:9
TurnControl turnControl
int32_t distanse_total
Definition: NormalCourse.h:16
SpeedControl speedControl