etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
MotorAngle.cpp
[詳解]
1 
6 #include "MotorAngle.h"
7 
14 void MotorAngle::update(std::int32_t left_motor, std::int32_t right_motor)
15 {
16  // 左モータ角度の過去値を更新
17  pre_left_motor = left_motor;
18  // 右モータ角度の過去値を更新
19  pre_right_motor = right_motor;
20 }
21 
27 {
28  pre_left_motor = 0;
29  pre_right_motor = 0;
30 }
31 
39 float MotorAngle::absoluteAngleMean(std::int32_t left_motor, std::int32_t right_motor)
40 {
41  return (left_motor + right_motor) / 2.0f;
42 }
43 
51 float MotorAngle::relativeAngleMean(std::int32_t current_left_motor,
52  std::int32_t current_right_motor)
53 {
54  // 左モータの相対角度を求める
55  float left_motor = current_left_motor - pre_left_motor;
56  // 右モータの相対角度を求める
57  float right_motor = current_right_motor - pre_right_motor;
58 
59  // 左右モータの過去値を現在値に更新
60  update(current_left_motor, current_right_motor);
61 
62  return (left_motor + right_motor) / 2.0f;
63 }
64 
72 float MotorAngle::angularDifference(std::int32_t left_motor, std::int32_t right_motor)
73 {
74  return static_cast<float>(right_motor - left_motor);
75 }
76 
83 std::int32_t MotorAngle::absoluteValueOfAngle(std::int32_t motor)
84 {
85  return (motor > 0) ? motor : -motor;
86 }
float relativeAngleMean(std::int32_t current_left_motor, std::int32_t current_right_motor)
左右モータの相対角度の平均値を計算する
Definition: MotorAngle.cpp:51
void reset()
左右モータ角度の過去値を0にリセットする
Definition: MotorAngle.cpp:26
float angularDifference(std::int32_t left_motor, std::int32_t right_motor)
左右モータ角度の差を計算する(右手系/反時計回りが正)
Definition: MotorAngle.cpp:72
std::int32_t absoluteValueOfAngle(std::int32_t motor)
モータ角度の絶対値を計算する
Definition: MotorAngle.cpp:83
float absoluteAngleMean(std::int32_t left_motor, std::int32_t right_motor)
左右モータの絶対角度の平均値を計算する
Definition: MotorAngle.cpp:39
左右モータの回転角に関するクラス(旧Distance.h, SelfLocalization内のMotorAngle)
void update(std::int32_t left_motor, std::int32_t right_motor)
左右モータ角度の過去値を現在値へ更新する
Definition: MotorAngle.cpp:14