• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1915 (tree)
日時2010-09-17 18:13:03
作者satofumi

ログメッセージ

制御周期をパラメータ化

変更サマリ

差分

--- branches/tsukuba_2010/libs/run_drive/motor_velocity.c (revision 1914)
+++ branches/tsukuba_2010/libs/run_drive/motor_velocity.c (revision 1915)
@@ -8,12 +8,13 @@
88 */
99
1010 #include "motor_velocity.h"
11+#include "robot_parameter.h"
1112 #include "motor_pwm.h"
1213 #include "encoder_reader.h"
1314
1415 enum {
15- DEFAULT_GAIN_P = 16, /* 1/1 の重さ */
16- DEFAULT_GAIN_I = 32, /* 1/256 の重さ */
16+ DEFAULT_GAIN_P = 32, /* 1/1 の重さ */
17+ DEFAULT_GAIN_I = 32 * CONTROL_CYCLE_MSEC_SHIFT, /* 1/256 の重さ */
1718 };
1819
1920
--- branches/tsukuba_2010/libs/run_drive/wheel_velocity.c (revision 1914)
+++ branches/tsukuba_2010/libs/run_drive/wheel_velocity.c (revision 1915)
@@ -34,7 +34,8 @@
3434 static int mm2count_velocity(int mm)
3535 {
3636 int count_per_msec =
37- (((mm * ENCODER_RESOLUTION) >> 10) / (int)(2 * M_PI * WHEEL_RADIUS_MM));
37+ (((mm * ENCODER_RESOLUTION) >> (10 - CONTROL_CYCLE_MSEC_SHIFT))
38+ / (int)(2 * M_PI * WHEEL_RADIUS_MM));
3839
3940 return count_per_msec;
4041 }
@@ -43,7 +44,9 @@
4344 static int count2mm_velocity(int count)
4445 {
4546 int mm_per_sec =
46- count * (int)(2 * M_PI * (WHEEL_RADIUS_MM << 10)) / ENCODER_RESOLUTION;
47+ count * (int)(2 * M_PI *
48+ (WHEEL_RADIUS_MM << (10 - CONTROL_CYCLE_MSEC_SHIFT)))
49+ / ENCODER_RESOLUTION;
4750
4851 return mm_per_sec;
4952 }
--- branches/tsukuba_2010/libs/run_drive/samples/motor_velocity_run.c (revision 1914)
+++ branches/tsukuba_2010/libs/run_drive/samples/motor_velocity_run.c (revision 1915)
@@ -19,7 +19,7 @@
1919
2020
2121 enum {
22- TARGET_COUNT = 1,
22+ TARGET_COUNT = 4,
2323 };
2424
2525
@@ -29,13 +29,11 @@
2929 int current_count[2];
3030 int i;
3131
32-#if 1
3332 if (++msec >= 4) {
3433 msec = 0;
3534 } else {
3635 return;
3736 }
38-#endif
3937
4038 for (i = 0; i < 2; ++i) {
4139 encoder_update(&encoder_[i]);
--- branches/tsukuba_2010/libs/run_drive/samples/wheel_velocity_run.c (revision 1914)
+++ branches/tsukuba_2010/libs/run_drive/samples/wheel_velocity_run.c (revision 1915)
@@ -19,8 +19,15 @@
1919
2020 static void timer_handler(void)
2121 {
22+ static int msec = 0;
2223 int i;
2324
25+ if (++msec >= 4) {
26+ msec = 0;
27+ } else {
28+ return;
29+ }
30+
2431 for (i = 0; i < 2; ++i) {
2532 encoder_update(&wheel_[i].encoder);
2633 }
@@ -35,7 +42,7 @@
3542 int main(void)
3643 {
3744 enum {
38- VELOCITY_MM_PER_SEC = 100,
45+ VELOCITY_MM_PER_SEC = 200,
3946 };
4047 int i;
4148
--- branches/tsukuba_2010/libs/run_drive/robot_parameter.h (revision 1914)
+++ branches/tsukuba_2010/libs/run_drive/robot_parameter.h (revision 1915)
@@ -11,6 +11,12 @@
1111 */
1212
1313
14+enum {
15+ CONTROL_CYCLE_MSEC_SHIFT = 3,
16+ CONTROL_CYCLE_MSEC = 1 << CONTROL_CYCLE_MSEC_SHIFT, //!< 制御周期 [msec]
17+};
18+
19+
1420 #define ENCODER_RESOLUTION 400 //!< エンコーダ分解能 [1]
1521 #define WHEEL_RADIUS_MM 43 //!< 車輪の半径 [mm]
1622 #define GEAR_RATIO 1.0 //!< ギヤ比 (モータ軸/車輪軸) [1]
旧リポジトリブラウザで表示