![]() |
![]() |
#define LEG 300 // LEG MOVE TIME #define ANKLE 1200 // ANKEL MOVE TIME int main(int argc,char **argv){ t_stop=execi(&stop,0,NULL,100,DEFAULT_STACK_SIZE); // make stop task t_walk=execi(&walk,0,NULL,90,DEFAULT_STACK_SIZE); // make walk task t_eye=execi(&eye,0,NULL,10,DEFAULT_STACK_SIZE); // make eye task return 0; } |
関数名 | 優先度 |
---|---|
stop(ストップ関数) | 100 |
walk(ウォーク関数) | 90 |
eye(アイ関数) | 10 |
int stop(){ // rcx stop function int stopchar; stopchar=getchar(); if(stopchar==KEY_RUN){ cputs("stop"); killall(100); } return 0; } |
int walk(){ // Walk function motor_a_speed(MAX_SPEED); motor_b_speed(MAX_SPEED); motor_b_dir(rev); msleep(1500); motor_b_dir(brake); while(1){ leg_move_right(); // right leg move function ankle_move_right(); // right ankle move function leg_move_left(); // left leg move function ankle_move_left(); // left ankle move function } return 0; } |
void leg_move_right(){ // right leg move function motor_a_dir(fwd); msleep(LEG); motor_b_dir(rev); msleep(ANKLE); motor_b_dir(brake); wait_event(&ts1_wakeup,0); motor_a_dir(brake); } void leg_move_left(){ // left leg move function motor_a_dir(rev); msleep(LEG); motor_b_dir(fwd); msleep(ANKLE); motor_b_dir(brake); wait_event(&ts1_wakeup,0); motor_a_dir(brake); } wakeup_t ts1_wakeup(wakeup_t data){ return SENSOR_1<0xf000; } |
leg_move_right関数のフローチャート |
![]() |
void ankle_move_right(){ // right ankle move function motor_b_dir(fwd); msleep(1500); wait_event(&ts3_wakeup,0); dsound_system(DSOUND_BEEP); msleep(1500); motor_b_dir(brake); } void ankle_move_left(){ // left ankle move function motor_b_dir(rev); msleep(1500); wait_event(&ts2_wakeup,0); dsound_system(DSOUND_BEEP); msleep(1500); motor_b_dir(brake); } wakeup_t ts2_wakeup(wakeup_t data){ return SENSOR_2>0xf000; } wakeup_t ts3_wakeup(wakeup_t data){ return SENSOR_3>0xf000; } |
leg_move_right関数のフローチャート |
![]() |
#define EYE_MOVE 200 // EYE MOVE TIME int eye(){ // Move eye function motor_c_speed(MAX_SPEED); while(1){ motor_c_dir(fwd); msleep(EYE_MOVE); motor_c_dir(brake); msleep(EYE_MOVE); motor_c_dir(rev); msleep(EYE_MOVE); motor_c_dir(brake); msleep(EYE_MOVE); motor_c_dir(rev); msleep(EYE_MOVE); motor_c_dir(brake); msleep(EYE_MOVE); motor_c_dir(fwd); msleep(EYE_MOVE); motor_c_dir(brake); msleep(EYE_MOVE); } return 0; } |