etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
Distance.cpp
[詳解]
1 
7 #include "Distance.h"
8 
9 int32_t Distance::getDistanceTotal(int32_t countL, int32_t countR)
10 {
11  leftMotorDegTotal = countL;
12  rightMotorDegTotal = countR;
13  return (leftMotorDegTotal + rightMotorDegTotal) / 2;
14 }
15 
16 int32_t Distance::getDistanceCurrent(int32_t countL, int32_t countR)
17 {
18  int32_t leftMotorDeg = countL - leftMotorDegOld;
19  int32_t rightMotorDeg = countR - rightMotorDegOld;
20 
21  return (leftMotorDeg + rightMotorDeg) / 2;
22 }
23 
24 void Distance::resetDistance(int32_t countL, int32_t countR)
25 {
26  getDistanceTotal(countL, countR);
27  leftMotorDegOld = leftMotorDegTotal;
28  rightMotorDegOld = rightMotorDegTotal;
29 }