etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
公開メンバ関数 | 全メンバ一覧
WheelOdometry クラス

#include <WheelOdometry.h>

WheelOdometry 連携図
Collaboration graph

公開メンバ関数

 WheelOdometry (float diameter=99.0, float tread=147.5, float cycle=0.04)
 
float velocity (std::int32_t left_motor, std::int32_t right_motor)
 走行体の旋回速度を求める [詳解]
 
float angularVelocity (std::int32_t left_motor, std::int32_t right_motor)
 走行体の旋回角速度を求める [詳解]
 
const Coordinatereset ()
 走行体の位置情報を初期化する [詳解]
 
const Coordinateupdate (std::int32_t left_motor, std::int32_t right_motor)
 走行体の位置情報を更新する [詳解]
 
float getRotationAngle (std::int32_t left_motor, std::int32_t right_motor)
 走行体の回転角度を返す [詳解]
 
const CoordinategetCoordinate ()
 走行体の位置情報を返す [詳解]
 
float getPointX ()
 走行体の位置x座標を返す [詳解]
 
float getPointY ()
 走行体の位置y座標を返す [詳解]
 

詳解

WheelOdometry.h28 行目に定義があります。

構築子と解体子

WheelOdometry::WheelOdometry ( float  diameter = 99.0,
float  tread = 147.5,
float  cycle = 0.04 
)
inline

WheelOdometry.h35 行目に定義があります。

36  : motor_angle(), property(diameter, tread, cycle), coordinate()
37  {
38  }

関数詳解

float WheelOdometry::angularVelocity ( std::int32_t  left_motor,
std::int32_t  right_motor 
)

走行体の旋回角速度を求める

左右モータの回転角から走行体の角速度を求める

[WheelOdometry::angularVelocity]

引数
left_motor左モータの回転角
right_motor右モータの回転角
戻り値
走行体の角速度 [deg / sec]

WheelOdometry.cpp60 行目に定義があります。

61 {
62  // 回転速度から角速度へ変換するときに必要な係数
63  float transform = property.radius_wheel / property.between_wheels;
64 
65  // 走行体の回転角の差を求める(右モータ - 左モータ), LPF処理つき
66  float angle = motor_angle.angularDifference(left_motor, right_motor);
67 
68  return transform * angle / property.dt;
69 }
float angularDifference(std::int32_t left_motor, std::int32_t right_motor)
左右モータ角度の差を計算する(右手系/反時計回りが正)
Definition: MotorAngle.cpp:72

呼び出し関係図:

被呼び出し関係図:

const Coordinate & WheelOdometry::getCoordinate ( )

走行体の位置情報を返す

[WheelOdometry::getCoordinate]

WheelOdometry.cpp126 行目に定義があります。

127 {
128  return coordinate;
129 }

被呼び出し関係図:

float WheelOdometry::getPointX ( )

走行体の位置x座標を返す

[WheelOdometry::getPointX]

WheelOdometry.cpp135 行目に定義があります。

136 {
137  return coordinate.x;
138 }

被呼び出し関係図:

float WheelOdometry::getPointY ( )

走行体の位置y座標を返す

[WheelOdometry::getPointY]

WheelOdometry.cpp144 行目に定義があります。

145 {
146  return coordinate.y;
147 }

被呼び出し関係図:

float WheelOdometry::getRotationAngle ( std::int32_t  left_motor,
std::int32_t  right_motor 
)

走行体の回転角度を返す

[WheelOdometry::getRotationAngle]

引数
left_motor左モータの回転角
right_motor右モータの回転角
戻り値
走行体の回転角度 [deg]

WheelOdometry.cpp107 行目に定義があります。

108 {
109  // モータの角度から回転角度へ変換するときに必要な係数
110  float transform = 2.0f * property.radius_wheel / property.between_wheels;
111 
112  // モータの角度を絶対値で取得する
113  left_motor = motor_angle.absoluteValueOfAngle(left_motor);
114  right_motor = motor_angle.absoluteValueOfAngle(right_motor);
115 
116  // モータの角度の平均値を求める
117  float mean = motor_angle.absoluteAngleMean(left_motor, right_motor);
118 
119  return transform * mean;
120 }
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

呼び出し関係図:

被呼び出し関係図:

const Coordinate & WheelOdometry::reset ( void  )

走行体の位置情報を初期化する

[WheelOdometry::reset]

WheelOdometry.cpp75 行目に定義があります。

76 {
77  coordinate.reset();
78  motor_angle.reset();
79  return coordinate;
80 }
void reset()
左右モータ角度の過去値を0にリセットする
Definition: MotorAngle.cpp:26
void reset()
走行体の位置情報を初期化する

呼び出し関係図:

被呼び出し関係図:

const Coordinate & WheelOdometry::update ( std::int32_t  left_motor,
std::int32_t  right_motor 
)

走行体の位置情報を更新する

[WheelOdometry::update]

引数
left_motor左モータの回転角
right_motor右モータの回転角
戻り値
走行体の位置情報

WheelOdometry.cpp89 行目に定義があります。

90 {
91  // 走行体の移動距離を計算する
92  float distance = velocity(left_motor, right_motor) * property.dt;
93  // 走行体の旋回角度を計算する
94  float angle = angularVelocity(left_motor, right_motor) * property.dt;
95  // 走行体の位置情報を更新する
96  coordinate.update(distance, angle);
97  return coordinate;
98 }
float angularVelocity(std::int32_t left_motor, std::int32_t right_motor)
走行体の旋回角速度を求める
float velocity(std::int32_t left_motor, std::int32_t right_motor)
走行体の旋回速度を求める
void update(float distance, float angle)
走行体の位置情報を更新する

呼び出し関係図:

被呼び出し関係図:

float WheelOdometry::velocity ( std::int32_t  left_motor,
std::int32_t  right_motor 
)

走行体の旋回速度を求める

左右モータの回転角から走行体の速度を算出する

[WheelOdometry::velocity]

引数
left_motor左モータの回転角
right_motor右モータの回転角
戻り値
走行体の前進速度 [mm / sec]

WheelOdometry.cpp43 行目に定義があります。

44 {
45  // 回転速度から走行体の速度へ変換するときに必要な係数
46  float transform = 3.14f * property.radius_wheel / 180.0f;
47  // 走行体の回転角の差を求める(LPF処理つき)
48  float angle = motor_angle.relativeAngleMean(left_motor, right_motor);
49 
50  return transform * angle / property.dt;
51 }
float relativeAngleMean(std::int32_t current_left_motor, std::int32_t current_right_motor)
左右モータの相対角度の平均値を計算する
Definition: MotorAngle.cpp:51

呼び出し関係図:

被呼び出し関係図:


このクラス詳解は次のファイルから抽出されました: