• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1911 (tree)
日時2010-09-17 10:44:05
作者satofumi

ログメッセージ

車輪制御用のサンプルを実装

変更サマリ

差分

--- branches/tsukuba_2010/libs/run_drive/wheel_t.h (revision 1910)
+++ branches/tsukuba_2010/libs/run_drive/wheel_t.h (revision 1911)
@@ -3,7 +3,7 @@
33
44 /*!
55 \file
6- \brief 車輪の管理
6+ \brief 車輪速の管理
77
88 \author Satofumi KAMIMURA
99
@@ -14,13 +14,14 @@
1414 #include "motor_t.h"
1515
1616
17-//! 車輪の管理
17+//! 車輪速の管理
1818 typedef struct
1919 {
2020 encoder_t encoder;
2121 motor_t motor;
2222
23- int target_velocity; //!<
23+ int target_velocity; //!< [count/msec]
24+ int next_add_velocity; //!< [count/msec]
2425 } wheel_t;
2526
2627 #endif /* !QRK_WHEEL_T_H */
--- branches/tsukuba_2010/libs/run_drive/wheel_velocity.c (revision 1910)
+++ branches/tsukuba_2010/libs/run_drive/wheel_velocity.c (revision 1911)
@@ -19,13 +19,17 @@
1919 motor_velocity_initialize(&wheel->motor, device_id);
2020
2121 wheel->target_velocity = 0;
22+ wheel->next_add_velocity = 0;
2223 }
2324
2425
2526 void wheel_set_velocity(wheel_t *wheel, int mm_per_sec)
2627 {
28+ // 速度をカウント単位系に変換してから代入する
29+
30+ // count_per_msec =
31+
2732 (void)mm_per_sec;
28- // !!! 速度をカウント単位系に変換してから代入する
2933 wheel->target_velocity = -1;
3034 }
3135
--- branches/tsukuba_2010/libs/run_drive/samples/wheel_velocity_run.c (revision 1910)
+++ branches/tsukuba_2010/libs/run_drive/samples/wheel_velocity_run.c (revision 1911)
@@ -8,24 +8,51 @@
88
99 #include "imask.h"
1010 #include "clock_initialize.h"
11+#include "interrupt_priority.h"
1112 #include "wheel_velocity.h"
13+#include "encoder_reader.h"
14+#include "timer_control.h"
1215
1316
14-static wheel_t wheel[2];
17+static wheel_t wheel_[2];
1518
1619
20+static void timer_handler(void)
21+{
22+ int i;
23+
24+ for (i = 0; i < 2; ++i) {
25+ encoder_update(&wheel_[i].encoder);
26+ }
27+
28+ // 車輪の速度制御
29+ for (i = 0; i < 2; ++i) {
30+ wheel_velocity_control(&wheel_[i]);
31+ }
32+}
33+
34+
1735 int main(void)
1836 {
37+ enum {
38+ VELOCITY_MM_PER_SEC = 200,
39+ };
1940 int i;
2041
2142 imask_initialize();
2243 clock_initialize();
44+ timer_initialize(INTERRUPT_PRIORITY_TIMER);
2345
2446 for (i = 0; i < 2; ++i) {
25- wheel_initialize(&wheel[i], i);
47+ wheel_initialize(&wheel_[i], i);
48+ wheel_set_velocity(&wheel_[i], VELOCITY_MM_PER_SEC);
2649 }
50+ set_imask_exr(0);
2751
28- // !!!
52+ timer_set_interval_function(timer_handler);
53+ timer_start();
2954
30- return 0;
55+ while (1) {
56+ ;
57+ }
3158 }
--- branches/tsukuba_2010/libs/run_drive/samples/Makefile (revision 1910)
+++ branches/tsukuba_2010/libs/run_drive/samples/Makefile (revision 1911)
@@ -42,7 +42,7 @@
4242 motor_pwm_out.mot : motor_pwm_out.o $(BASE_OBJ) $(SOURCE_DIR)/motor_pwm.o $(SOURCE_DIR)/mtu2_initialize.o
4343 motor_velocity_run.mot : motor_velocity_run.o $(BASE_OBJ) $(SOURCE_DIR)/timer_control.o $(SOURCE_DIR)/encoder_reader.o $(SOURCE_DIR)/motor_pwm.o $(SOURCE_DIR)/motor_velocity.o $(SOURCE_DIR)/mtu2_initialize.o
4444 pwm_output.mot : pwm_output.o $(SOURCE_DIR)/pwm_control.o
45-wheel_velocity_run.mot : wheel_velocity_run.o $(BASE_OBJ) $(SOURCE_DIR)/wheel_velocity.o $(SOURCE_DIR)/encoder_reader.o $(SOURCE_DIR)/motor_velocity.o $(SOURCE_DIR)/mtu2_initialize.o $(SOURCE_DIR)/motor_pwm.o
45+wheel_velocity_run.mot : wheel_velocity_run.o $(BASE_OBJ) $(SOURCE_DIR)/wheel_velocity.o $(SOURCE_DIR)/encoder_reader.o $(SOURCE_DIR)/motor_velocity.o $(SOURCE_DIR)/mtu2_initialize.o $(SOURCE_DIR)/motor_pwm.o $(SOURCE_DIR)/timer_control.o
4646
4747 # DO NOT DELETE
4848
--- branches/tsukuba_2010/libs/run_drive/robot_parameter.h (revision 1910)
+++ branches/tsukuba_2010/libs/run_drive/robot_parameter.h (revision 1911)
@@ -11,7 +11,11 @@
1111 */
1212
1313
14+#define ENCODER_RESOLUTION 100 //!< エンコーダ分解能 [1]
15+#define WHEEL_RADIUS_MM 43 //!< 車輪の半径 [mm]
16+#define GEAR_RATIO 1.0 //!< ギヤ比 (モータ軸/車輪軸) [1]
17+
1418 // !!!
15-#define TREAD 300 // [mm]
19+#define TREAD 300 //!< トレッド [mm]
1620
1721 #endif /* !QRK_ROBOT_PARAMETER_H */
旧リポジトリブラウザで表示