Controlor for Humanoid. Walking trajectory generator, sensor reflection etc.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
Revision 10:be8b10e54ecb, committed 2012-09-22
- Comitter:
- syundo0730
- Date:
- Sat Sep 22 06:58:21 2012 +0000
- Parent:
- 9:d9ce965299d2
- Child:
- 11:1539d181e159
- Commit message:
- repeat
Changed in this revision
--- a/Motion.cpp Sat Sep 22 06:16:15 2012 +0000 +++ b/Motion.cpp Sat Sep 22 06:58:21 2012 +0000 @@ -18,6 +18,7 @@ } m_mode = 1; + m_in_interrupt = false; //zero clear m_idx = 0; @@ -34,8 +35,12 @@ void Motion::step() { if (m_idx < m_IDX_MAX - 1) { + m_in_interrupt = true; update(); } else { + m_in_interrupt = false; + m_idx = 0; + m_play = 0; tick.detach(); } } @@ -111,4 +116,9 @@ pwm.SetDuty(i, (uint32_t)m_buf[i]); __enable_irq(); } +} + +bool Motion::is_in_interrupt() +{ + return m_in_interrupt; } \ No newline at end of file
--- a/Motion.h Sat Sep 22 06:16:15 2012 +0000 +++ b/Motion.h Sat Sep 22 06:58:21 2012 +0000 @@ -1,38 +1,40 @@ -#ifndef MOTION_H_2012_09_21_ -#define MOTION_H_2012_09_21_ - -#include "LPC17xx.h" -#include "mbed.h" - -class Motion -{ - public: - Motion(uint32_t** data, unsigned char size_idx, unsigned char size_num); - //~Motion(); - public: - void step(); - private: - void update(); - void set_inter(); - void init_inter(); - void step_inter(); - - private: - uint32_t** m_data; - unsigned char m_IDX_MAX; - unsigned char m_NUM_MAX; - unsigned char m_data_num[16]; //inter - unsigned char m_mode; - - private: - unsigned char m_idx; - unsigned char m_play; - private: - double m_buf[25]; //buf - double m_d_buf[25]; //dbuf - double m_dd_buf[25]; //ddbuf - double m_brake_flg; - unsigned char m_brake_pnt; -}; - +#ifndef MOTION_H_2012_09_21_ +#define MOTION_H_2012_09_21_ + +#include "LPC17xx.h" +#include "mbed.h" + +class Motion +{ + public: + Motion(uint32_t** data, unsigned char size_idx, unsigned char size_num); + //~Motion(); + public: + void step(); + bool is_in_interrupt(); + private: + void update(); + void set_inter(); + void init_inter(); + void step_inter(); + + private: + uint32_t** m_data; + unsigned char m_IDX_MAX; + unsigned char m_NUM_MAX; + unsigned char m_data_num[16]; //inter + unsigned char m_mode; + bool m_in_interrupt; + + private: + unsigned char m_idx; + unsigned char m_play; + private: + double m_buf[25]; //buf + double m_d_buf[25]; //dbuf + double m_dd_buf[25]; //ddbuf + double m_brake_flg; + unsigned char m_brake_pnt; +}; + #endif \ No newline at end of file
--- a/main.cpp Sat Sep 22 06:16:15 2012 +0000 +++ b/main.cpp Sat Sep 22 06:58:21 2012 +0000 @@ -26,25 +26,13 @@ Motion inter0(array, size_x, size_y); - tick.attach(&inter0, &Motion::step, 0.02); + //tick.attach(&inter0, &Motion::step, 0.02); while (1) { - //SetDuty(1,SRV_MAX_DUTY); - //sleep(); - //__enable_irq(); - //__disable_irq(); - //NVIC_DisableIRQ(PWM1_IRQn); + //int id = 0; + if (!inter0.is_in_interrupt()) { + tick.attach(&inter0, &Motion::step, 0.02); + } + wait(0.02); } -} - -/*void main_th(void) { - PWM pwm; - //const uint32_t center = 1500 - 1; - //const uint32_t dif = SRV_MAX_DUTY - center; - static uint8_t i; - - __disable_irq(); - pwm.SetDuty(1,SRV_MIN_DUTY+i); - __enable_irq(); - ++i; -}*/ \ No newline at end of file +} \ No newline at end of file