エンコーダカウント→車輪速度[m/s]の時間微分計算。
[詳解]
#include <VelocityCalculator.hpp>
|
| | VelocityCalculator (double counts_per_rev, double wheel_radius, double dt_sec) |
| | コンストラクタ
|
| void | setWheelRadius (double radius) |
| | 車輪半径を設定
|
| void | setDeltaTime (double dt_sec) |
| | サンプリング周期を設定
|
| double | calculate (int32_t current_count, int32_t &prev_count) |
| | 現在のエンコーダーカウントから速度を計算
|
| double | calculate (int64_t current_count, int64_t &prev_count) |
| | ラップ吸収済み累積カウントから速度を計算(int64版)
|
| void | calculateBothWheels (int32_t current_count_l, int32_t current_count_r, int32_t &prev_count_l, int32_t &prev_count_r, double &vel_l, double &vel_r) |
| | 左右両輪の速度を計算
|
| void | calculateBothWheels (int64_t current_count_l, int64_t current_count_r, int64_t &prev_count_l, int64_t &prev_count_r, double &vel_l, double &vel_r) |
| | 左右両輪の速度を計算(int64累積値版)
|
|
| static int64_t | wrapDelta (int32_t current_count, int32_t last_count) |
| | int32境界のラップを吸収したカウント差分を返す
|
エンコーダカウント→車輪速度[m/s]の時間微分計算。
VelocityCalculator.hpp の 14 行目に定義があります。
◆ VelocityCalculator()
| VelocityCalculator::VelocityCalculator |
( |
double | counts_per_rev, |
|
|
double | wheel_radius, |
|
|
double | dt_sec ) |
コンストラクタ
- 引数
-
| counts_per_rev | エンコーダーの1回転あたりのカウント数 |
| wheel_radius | 車輪半径 [m] |
| dt_sec | サンプリング周期 [s] |
VelocityCalculator.cpp の 12 行目に定義があります。
◆ calculate() [1/2]
| double VelocityCalculator::calculate |
( |
int32_t | current_count, |
|
|
int32_t & | prev_count ) |
現在のエンコーダーカウントから速度を計算
- 引数
-
| current_count | 現在のエンコーダーカウント |
| prev_count | 前回のエンコーダーカウント(参照で更新される) |
- 戻り値
- 計算された速度 [m/s]
VelocityCalculator.cpp の 51 行目に定義があります。
◆ calculate() [2/2]
| double VelocityCalculator::calculate |
( |
int64_t | current_count, |
|
|
int64_t & | prev_count ) |
ラップ吸収済み累積カウントから速度を計算(int64版)
- 引数
-
| current_count | 現在の累積カウント |
| prev_count | 前回の累積カウント(参照で更新される) |
- 戻り値
- 計算された速度 [m/s]
VelocityCalculator.cpp の 43 行目に定義があります。
◆ calculateBothWheels() [1/2]
| void VelocityCalculator::calculateBothWheels |
( |
int32_t | current_count_l, |
|
|
int32_t | current_count_r, |
|
|
int32_t & | prev_count_l, |
|
|
int32_t & | prev_count_r, |
|
|
double & | vel_l, |
|
|
double & | vel_r ) |
左右両輪の速度を計算
- 引数
-
| current_count_l | 現在の左輪エンコーダーカウント |
| current_count_r | 現在の右輪エンコーダーカウント |
| prev_count_l | 前回の左輪エンコーダーカウント(参照で更新される) |
| prev_count_r | 前回の右輪エンコーダーカウント(参照で更新される) |
| vel_l | 計算された左輪速度 [m/s](出力) |
| vel_r | 計算された右輪速度 [m/s](出力) |
VelocityCalculator.cpp の 67 行目に定義があります。
◆ calculateBothWheels() [2/2]
| void VelocityCalculator::calculateBothWheels |
( |
int64_t | current_count_l, |
|
|
int64_t | current_count_r, |
|
|
int64_t & | prev_count_l, |
|
|
int64_t & | prev_count_r, |
|
|
double & | vel_l, |
|
|
double & | vel_r ) |
左右両輪の速度を計算(int64累積値版)
- 引数
-
| current_count_l | 現在の左輪累積カウント |
| current_count_r | 現在の右輪累積カウント |
| prev_count_l | 前回の左輪累積カウント(参照で更新される) |
| prev_count_r | 前回の右輪累積カウント(参照で更新される) |
| vel_l | 計算された左輪速度 [m/s](出力) |
| vel_r | 計算された右輪速度 [m/s](出力) |
VelocityCalculator.cpp の 58 行目に定義があります。
◆ setDeltaTime()
| void VelocityCalculator::setDeltaTime |
( |
double | dt_sec | ) |
|
◆ setWheelRadius()
| void VelocityCalculator::setWheelRadius |
( |
double | radius | ) |
|
◆ wrapDelta()
| int64_t VelocityCalculator::wrapDelta |
( |
int32_t | current_count, |
|
|
int32_t | last_count ) |
|
static |
int32境界のラップを吸収したカウント差分を返す
- 引数
-
| current_count | 現在のカウント |
| last_count | 前回のカウント |
- 戻り値
- current - last を [-2^31, 2^31) で解釈した差分(int64)。 さらに16bit幅への畳み込みでHWカウンタ直読時の折返しにも備える。 1制御周期の真の移動は数百カウント以下であることが前提。
VelocityCalculator.cpp の 27 行目に定義があります。
このクラス詳解は次のファイルから抽出されました: