2015a/Member/iwana/Mission3
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
#contents
* ロボットの説明 [#pd3f2927]
モーターA,Bに左右のタイヤをつけ、モーターCにアームを取り...
#ref(./1438161541687.jpg,50%);
* プログラムの説明 [#k5bc81ce]
プログラムは~
1)空き缶の位置(角度)の測定~
2)空き缶の位置を向く~
3)空き缶に向かって前進~
4)ボールの射出~
の順で動く。~
**定数や関数の定義 [#z221a145]
#define turn_left OnFwd(OUT_A,25);OnRev(OUT_B,25);
#define turn_right OnFwd(OUT_B,25);OnRev(OUT_A,25);
#define go_forward OnFwd(OUT_AB,25);
#define TURN_TIME_10=147; //10°回転するのにかかる時間
TURN_TIME_10の決定は、ロボットを回転させ180°回転するのに...
**空き缶の位置(角度)の測定 [#a7c1ec1d]
int scan_angle(int a){ //0<=a<=36で指定 a*10°の範囲をス...
PlaySound(SOUND_CLICK);
Wait(500);
int min_temp=0; //仮の最小値
int min=100; //最小値
int angle=0; //最小値を記録した角度[°]
int i=0; //i*10[°]ごと記録する
int turn_time=TURN_TIME_10;
repeat(a){
min_temp=SensorUS(S4);
if(min>=min_temp){ //最小値比較
min=min_temp; //最小値更新
angle=i*10; //最小値
PlaySound(SOUND_LOW_BEEP);
Wait(500);
}
turn_right;
Wait(turn_time);
i++;
}
return angle;
}
10°ごと旋回してそのつど距離センサーの値を取得する。取得し...
** 空き缶の位置を向く[#p0dcd450]
task main(){
int machine_turn_time=0; //ロボットの回転時間
SetSensorLowspeed(S4);
int angle=scan_angle(36); //360°スキャン
if(angle<=180){
machine_turn_time=TURN_TIME_10*angle;
go_forward;
Wait(machine_turn_time);
Off(OUT_AB);
}else{
machine_turn_time=TURN_TIME_10*angle;
go_forward;
Wait(machine_turn_time);
Off(OUT_AB);
}
scan_angle()関数で空き缶のある位置(角度)が帰ってくる。...
**空き缶に向かって前進 [#off12e44]
int flg=0;
while(flg==0){
go_forward;
if(SensorUS(S4)<=15){
flg=1;
}
}
Off(OUT_AB);
センサーの値を取得し、15cmを切ったら停止する。
**ボールの射出 [#ob74b464]
OnFwd(OUT_C,100); //ボール射出
Wait(500);
}
* 問題点 [#lcb18621]
-電池の消耗によって、回転に要する時間が変わってくるので正...
-ボールの射出方式が悪く、ボールを遠くに飛ばせない。
* 改善案 [#u3080db2]
-センサーが100cm以下の値を返してきたらスキャンを停止し、...
終了行:
#contents
* ロボットの説明 [#pd3f2927]
モーターA,Bに左右のタイヤをつけ、モーターCにアームを取り...
#ref(./1438161541687.jpg,50%);
* プログラムの説明 [#k5bc81ce]
プログラムは~
1)空き缶の位置(角度)の測定~
2)空き缶の位置を向く~
3)空き缶に向かって前進~
4)ボールの射出~
の順で動く。~
**定数や関数の定義 [#z221a145]
#define turn_left OnFwd(OUT_A,25);OnRev(OUT_B,25);
#define turn_right OnFwd(OUT_B,25);OnRev(OUT_A,25);
#define go_forward OnFwd(OUT_AB,25);
#define TURN_TIME_10=147; //10°回転するのにかかる時間
TURN_TIME_10の決定は、ロボットを回転させ180°回転するのに...
**空き缶の位置(角度)の測定 [#a7c1ec1d]
int scan_angle(int a){ //0<=a<=36で指定 a*10°の範囲をス...
PlaySound(SOUND_CLICK);
Wait(500);
int min_temp=0; //仮の最小値
int min=100; //最小値
int angle=0; //最小値を記録した角度[°]
int i=0; //i*10[°]ごと記録する
int turn_time=TURN_TIME_10;
repeat(a){
min_temp=SensorUS(S4);
if(min>=min_temp){ //最小値比較
min=min_temp; //最小値更新
angle=i*10; //最小値
PlaySound(SOUND_LOW_BEEP);
Wait(500);
}
turn_right;
Wait(turn_time);
i++;
}
return angle;
}
10°ごと旋回してそのつど距離センサーの値を取得する。取得し...
** 空き缶の位置を向く[#p0dcd450]
task main(){
int machine_turn_time=0; //ロボットの回転時間
SetSensorLowspeed(S4);
int angle=scan_angle(36); //360°スキャン
if(angle<=180){
machine_turn_time=TURN_TIME_10*angle;
go_forward;
Wait(machine_turn_time);
Off(OUT_AB);
}else{
machine_turn_time=TURN_TIME_10*angle;
go_forward;
Wait(machine_turn_time);
Off(OUT_AB);
}
scan_angle()関数で空き缶のある位置(角度)が帰ってくる。...
**空き缶に向かって前進 [#off12e44]
int flg=0;
while(flg==0){
go_forward;
if(SensorUS(S4)<=15){
flg=1;
}
}
Off(OUT_AB);
センサーの値を取得し、15cmを切ったら停止する。
**ボールの射出 [#ob74b464]
OnFwd(OUT_C,100); //ボール射出
Wait(500);
}
* 問題点 [#lcb18621]
-電池の消耗によって、回転に要する時間が変わってくるので正...
-ボールの射出方式が悪く、ボールを遠くに飛ばせない。
* 改善案 [#u3080db2]
-センサーが100cm以下の値を返してきたらスキャンを停止し、...
ページ名: