2012a/A4/SanChan/M3
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[2012a/Member]]
*ロボコン 空き缶を積むロボット[#y98b4655]
#ref(2012a/A4/SanChan/M3/robocon_course.png,100%,ロボット)
上図のようなコースで、緑の位置にある缶を赤の位置にある缶...
*ロボット本体 [#t7f2874e]
#ref(2012a/A4/SanChan/M3/120727_091018.jpg,100%,ロボット)
できあがったロボットは上のようになりました。構造としては...
#ref(2012a/A4/SanChan/M3/120727_183712_2.jpg,100%,ロボット)
図のようにモーター(裏側にもある)2つを用いて、レール構...
#ref(2012a/A4/SanChan/M3/120727_183529_2.jpg,100%,ロボット)
正面から見たものです。画像の青で囲んだところにある歯車で...
#ref(2012a/A4/SanChan/M3/120727_183953.jpg,100%,ロボット)
実際に持ち上げてみました。持ち上げる動作自体はほぼ100...
反省点:
構造に時間をかけすぎて、プログラミングがおろそかになって...
構造上の問題としては、ハサミやレールに大量のパーツを使用...
*プログラミング [#s5e091c6]
マスター側プログラム
//**************************************//
// nxtプログラム MASTER //
//**************************************//
#define turn90 420
#define turn45 170
#define close 2000
#define open 2500
#define up 490
#define down 480
#define BT_CONN 1
#define get_sBOX 1
#define get_fBOX 2
#define out_sBOX 3
#define out_fBOX 4
void turn_l(int i){
Float(OUT_BC);
RotateMotor(OUT_C,70,i);
Wait(200);
Off(OUT_BC);
Wait(200);
}
void turn_r(int i){
Float(OUT_BC);
RotateMotor(OUT_B,70,i);
Wait(200);
Off(OUT_BC);
Wait(200);
}
task main(void){
int get_s=0,get_f=0,out_s=0,out_f=0;
int modeM;
SetSensorLight(IN_2);
SetSensorLight(IN_3);
ResetTachoCount(OUT_B);
modeM=1;
while(1){
switch(modeM){
case 1:
turn_r(turn45);
modeM=2;
break;
case 2:
RotateMotor(OUT_BC,50,1300);
Wait(200);
modeM=3;
break;
case 3:
modeM=4;
CoastEx(OUT_BC,0);
get_s=1;
break;
case 4:
SendRemoteBool(BT_CONN,get_sBOX,get_s); //...
ReceiveRemoteBool(get_fBOX, true,get_f); /...
if(get_f==1){ //...
modeM=5;
PlayTone(TONE_C4,150);
}
break;
case 5:
Wait(200);
modeM=6;
break;
case 6:
OnFwd(OUT_BC,40);
if(Sensor(IN_3)<40){
modeM=7;
}
break;
case 7:
if(Sensor(IN_3)<55){
modeM=8;
CoastEx(OUT_BC,0);
}
break;
case 8:
OnFwd(OUT_B,50);
if(Sensor(IN_2)<35){
modeM=9;
}
break;
case 9:
RotateMotor(OUT_B,60,180);
Wait(200);
CoastEx(OUT_BC,0);
out_s=1;
modeM=10;
break;
case 10:
SendRemoteBool(BT_CONN,out_sBOX,out_s); //...
ReceiveRemoteBool(out_fBOX, true,out_f); //...
if(out_f==1){ //...
modeM=11;
}
break;
case 11:
RotateMotor(OUT_BC,-50,500);
modeM=12;
break;
case 12:
CoastEx(OUT_BC,0);
break;
}
}
}
スレイブ側プログラム
//**************************************//
// nxtプログラム SLAVE //
//**************************************//
#define turn90 420
#define turn45 210
#define close 2500
#define open 2500
#define up 490
#define down 480
#define BT_CONN 1
#define get_sBOX 1
#define get_fBOX 2
#define out_sBOX 3
#define out_fBOX 4
task main(void){
int get_s=0,get_f=0,out_s=0,out_f=0;
int modeS;
modeS=1;
while(1){
switch(modeS){
case 1:
ReceiveRemoteBool(get_sBOX,true,get_s); //...
if(get_s==1){ //...
modeS=2;
}
break;
case 2:
PlayTone(TONE_C4,150);
RotateMotor(OUT_A,-90,close);
Wait(200);
modeS=3;
break;
case 3:
RotateMotor(OUT_BC,-65,up);
Wait(200);
modeS=4;
break;
case 4:
get_f=1;
SendResponseBool(get_fBOX,get_f); //...
ReceiveRemoteBool(out_sBOX,true,out_s); //...
if(out_s==1){ //...
modeS=5;
}
break;
case 5:
PlayTone(TONE_C4,150);
RotateMotor(OUT_A,90,open);
Wait(200);
modeS=6;
break;
case 6:
out_f=1;
SendResponseBool(out_fBOX,out_f); //...
break;
}
}
}
終了行:
[[2012a/Member]]
*ロボコン 空き缶を積むロボット[#y98b4655]
#ref(2012a/A4/SanChan/M3/robocon_course.png,100%,ロボット)
上図のようなコースで、緑の位置にある缶を赤の位置にある缶...
*ロボット本体 [#t7f2874e]
#ref(2012a/A4/SanChan/M3/120727_091018.jpg,100%,ロボット)
できあがったロボットは上のようになりました。構造としては...
#ref(2012a/A4/SanChan/M3/120727_183712_2.jpg,100%,ロボット)
図のようにモーター(裏側にもある)2つを用いて、レール構...
#ref(2012a/A4/SanChan/M3/120727_183529_2.jpg,100%,ロボット)
正面から見たものです。画像の青で囲んだところにある歯車で...
#ref(2012a/A4/SanChan/M3/120727_183953.jpg,100%,ロボット)
実際に持ち上げてみました。持ち上げる動作自体はほぼ100...
反省点:
構造に時間をかけすぎて、プログラミングがおろそかになって...
構造上の問題としては、ハサミやレールに大量のパーツを使用...
*プログラミング [#s5e091c6]
マスター側プログラム
//**************************************//
// nxtプログラム MASTER //
//**************************************//
#define turn90 420
#define turn45 170
#define close 2000
#define open 2500
#define up 490
#define down 480
#define BT_CONN 1
#define get_sBOX 1
#define get_fBOX 2
#define out_sBOX 3
#define out_fBOX 4
void turn_l(int i){
Float(OUT_BC);
RotateMotor(OUT_C,70,i);
Wait(200);
Off(OUT_BC);
Wait(200);
}
void turn_r(int i){
Float(OUT_BC);
RotateMotor(OUT_B,70,i);
Wait(200);
Off(OUT_BC);
Wait(200);
}
task main(void){
int get_s=0,get_f=0,out_s=0,out_f=0;
int modeM;
SetSensorLight(IN_2);
SetSensorLight(IN_3);
ResetTachoCount(OUT_B);
modeM=1;
while(1){
switch(modeM){
case 1:
turn_r(turn45);
modeM=2;
break;
case 2:
RotateMotor(OUT_BC,50,1300);
Wait(200);
modeM=3;
break;
case 3:
modeM=4;
CoastEx(OUT_BC,0);
get_s=1;
break;
case 4:
SendRemoteBool(BT_CONN,get_sBOX,get_s); //...
ReceiveRemoteBool(get_fBOX, true,get_f); /...
if(get_f==1){ //...
modeM=5;
PlayTone(TONE_C4,150);
}
break;
case 5:
Wait(200);
modeM=6;
break;
case 6:
OnFwd(OUT_BC,40);
if(Sensor(IN_3)<40){
modeM=7;
}
break;
case 7:
if(Sensor(IN_3)<55){
modeM=8;
CoastEx(OUT_BC,0);
}
break;
case 8:
OnFwd(OUT_B,50);
if(Sensor(IN_2)<35){
modeM=9;
}
break;
case 9:
RotateMotor(OUT_B,60,180);
Wait(200);
CoastEx(OUT_BC,0);
out_s=1;
modeM=10;
break;
case 10:
SendRemoteBool(BT_CONN,out_sBOX,out_s); //...
ReceiveRemoteBool(out_fBOX, true,out_f); //...
if(out_f==1){ //...
modeM=11;
}
break;
case 11:
RotateMotor(OUT_BC,-50,500);
modeM=12;
break;
case 12:
CoastEx(OUT_BC,0);
break;
}
}
}
スレイブ側プログラム
//**************************************//
// nxtプログラム SLAVE //
//**************************************//
#define turn90 420
#define turn45 210
#define close 2500
#define open 2500
#define up 490
#define down 480
#define BT_CONN 1
#define get_sBOX 1
#define get_fBOX 2
#define out_sBOX 3
#define out_fBOX 4
task main(void){
int get_s=0,get_f=0,out_s=0,out_f=0;
int modeS;
modeS=1;
while(1){
switch(modeS){
case 1:
ReceiveRemoteBool(get_sBOX,true,get_s); //...
if(get_s==1){ //...
modeS=2;
}
break;
case 2:
PlayTone(TONE_C4,150);
RotateMotor(OUT_A,-90,close);
Wait(200);
modeS=3;
break;
case 3:
RotateMotor(OUT_BC,-65,up);
Wait(200);
modeS=4;
break;
case 4:
get_f=1;
SendResponseBool(get_fBOX,get_f); //...
ReceiveRemoteBool(out_sBOX,true,out_s); //...
if(out_s==1){ //...
modeS=5;
}
break;
case 5:
PlayTone(TONE_C4,150);
RotateMotor(OUT_A,90,open);
Wait(200);
modeS=6;
break;
case 6:
out_f=1;
SendResponseBool(out_fBOX,out_f); //...
break;
}
}
}
ページ名: