![](/media/cache/profiles/e5815151957be36ad2085b7a1a02c5cc.jpg.50x50_q85.jpg)
Controlor for Humanoid. Walking trajectory generator, sensor reflection etc.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
main.cpp@9:d9ce965299d2, 2012-09-22 (annotated)
- Committer:
- syundo0730
- Date:
- Sat Sep 22 06:16:15 2012 +0000
- Revision:
- 9:d9ce965299d2
- Parent:
- 8:72b4a248d469
- Child:
- 10:be8b10e54ecb
play motion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
syundo0730 | 0:d114194bff43 | 1 | #include "LPC17xx.h" |
syundo0730 | 0:d114194bff43 | 2 | #include "mbed.h" |
syundo0730 | 9:d9ce965299d2 | 3 | #include "PWM.h" |
syundo0730 | 9:d9ce965299d2 | 4 | #include "Motion.h" |
syundo0730 | 0:d114194bff43 | 5 | |
syundo0730 | 9:d9ce965299d2 | 6 | Ticker tick; |
syundo0730 | 9:d9ce965299d2 | 7 | PWM pwm; |
syundo0730 | 5:0ca9f1bc1fb0 | 8 | |
syundo0730 | 8:72b4a248d469 | 9 | int main(void) |
syundo0730 | 8:72b4a248d469 | 10 | { |
syundo0730 | 9:d9ce965299d2 | 11 | unsigned char size_x = 4, size_y = 24; |
syundo0730 | 0:d114194bff43 | 12 | |
syundo0730 | 9:d9ce965299d2 | 13 | uint32_t **array = new uint32_t*[size_x]; |
syundo0730 | 9:d9ce965299d2 | 14 | for (int i = 0; i < size_x; ++i) { |
syundo0730 | 9:d9ce965299d2 | 15 | array[i] = new uint32_t[size_y]; |
syundo0730 | 9:d9ce965299d2 | 16 | } |
syundo0730 | 9:d9ce965299d2 | 17 | for (int i = 0; i < size_x; ++i) { |
syundo0730 | 9:d9ce965299d2 | 18 | for (int j = 0; j < size_y; ++j) { |
syundo0730 | 9:d9ce965299d2 | 19 | array[i][j] = 900 + 300 * i; |
syundo0730 | 9:d9ce965299d2 | 20 | } |
syundo0730 | 9:d9ce965299d2 | 21 | } |
syundo0730 | 9:d9ce965299d2 | 22 | array[0][size_y - 1] = 50; |
syundo0730 | 9:d9ce965299d2 | 23 | array[1][size_y - 1] = 50; |
syundo0730 | 9:d9ce965299d2 | 24 | array[2][size_y - 1] = 50; |
syundo0730 | 9:d9ce965299d2 | 25 | array[3][size_y - 1] = 50; |
syundo0730 | 9:d9ce965299d2 | 26 | |
syundo0730 | 9:d9ce965299d2 | 27 | Motion inter0(array, size_x, size_y); |
syundo0730 | 9:d9ce965299d2 | 28 | |
syundo0730 | 9:d9ce965299d2 | 29 | tick.attach(&inter0, &Motion::step, 0.02); |
syundo0730 | 1:5c2e40445778 | 30 | |
syundo0730 | 5:0ca9f1bc1fb0 | 31 | while (1) { |
syundo0730 | 5:0ca9f1bc1fb0 | 32 | //SetDuty(1,SRV_MAX_DUTY); |
syundo0730 | 5:0ca9f1bc1fb0 | 33 | //sleep(); |
syundo0730 | 8:72b4a248d469 | 34 | //__enable_irq(); |
syundo0730 | 8:72b4a248d469 | 35 | //__disable_irq(); |
syundo0730 | 8:72b4a248d469 | 36 | //NVIC_DisableIRQ(PWM1_IRQn); |
syundo0730 | 5:0ca9f1bc1fb0 | 37 | } |
syundo0730 | 5:0ca9f1bc1fb0 | 38 | } |
syundo0730 | 5:0ca9f1bc1fb0 | 39 | |
syundo0730 | 9:d9ce965299d2 | 40 | /*void main_th(void) { |
syundo0730 | 8:72b4a248d469 | 41 | PWM pwm; |
syundo0730 | 8:72b4a248d469 | 42 | //const uint32_t center = 1500 - 1; |
syundo0730 | 8:72b4a248d469 | 43 | //const uint32_t dif = SRV_MAX_DUTY - center; |
syundo0730 | 8:72b4a248d469 | 44 | static uint8_t i; |
syundo0730 | 8:72b4a248d469 | 45 | |
syundo0730 | 8:72b4a248d469 | 46 | __disable_irq(); |
syundo0730 | 8:72b4a248d469 | 47 | pwm.SetDuty(1,SRV_MIN_DUTY+i); |
syundo0730 | 8:72b4a248d469 | 48 | __enable_irq(); |
syundo0730 | 8:72b4a248d469 | 49 | ++i; |
syundo0730 | 9:d9ce965299d2 | 50 | }*/ |