2013a/Member/Sho/Mission2
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*ロボットの紹介 [#ka0eb18a]
+最初にボールを投げるロボット
#ref(2013a/Member/Sho/Mission2/DSC_0008.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0009.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0010.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0011.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0012.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0013.jpg,10%)
++最初にボールを受け取るロボット
#ref(2013a/Member/Sho/Mission2/_36974.jpg,30%)
#ref(2013a/Member/Sho/Mission2/_36972.jpg,30%)
#ref(2013a/Member/Sho/Mission2/_36968.jpg,30%)
-ロボットの前方は、ボールをつかむためのアームとパスをする...
-アームの部分を四角形し、ボールを運ぶ時のボールを手放して...
-ロボットの後方は、タイヤをつけてロボット全体のバランスを...
-課題1のロボットとベースを同じにすることでプログラムの面...
-小さくて平たいブロックをたくさん使うことによって、ロボッ...
-タイヤも課題1と同様、小さいものを使うことによって機動性...
-タッチセンサーは、アームのなかほどにつけました。
-もう一つのロボットも同じ仕様にしてパスの出し手と受け手の...
*コース攻略 [#w3a23940]
#ref(2013a/Member/Sho/Mission2/robocon2013a.png,70%)
-今回のコースは、課題1のコースを利用したもので基本的なラ...
-RCXでは、赤外線通信がロボットとの距離が遠くてできなかっ...
-しきい値は、課題1より少し高く39に設定することで調整で...
-パスは、真っ直ぐできるようにロボットどうしの向きに注意し...
-ボールをつかむ動作では、少しでもずれると取れないので慎重...
*プログラム説明 [#ce91a882]
+最初にパスを出す側のロボット
-しきい値、モーターのパワー、左旋回、右旋回、アーム、交差...
#define THRESHOLD 42
#define HIPOWER 7
#define LOWPOWER 2
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define set_power_N SetPower(OUT_B,LOWPOWER);
#define go_fwd set_power_H; OnFwd(OUT_AC);
#define arm_fwd set_power_N; OnFwd(OUT_B);Wait(30);Off(O...
#define arm_bwd set_power_N; OnRev(OUT_B);Wait(30);Off(O...
#define turn_left1 set_power_L ;\
OnFwd(OUT_C);OnRev(OUT_A);
#define turn_left0 set_power_L ;\
OnFwd(OUT_C);Off(OUT_A);
#define turn_right0 set_power_L ;\
OnFwd(OUT_A);Off(OUT_C);
#define turn_right1 set_power_L ;\
OnFwd(OUT_A);OnRev(OUT_C);
#define STEP 1
#define nMAX 3
#define short_break Off(OUT_AC); Wait(100);
#define CROSS_TIME 300
#define cross_line set_power_L;\
OnFwd(OUT_A);OnRev(OUT_C);\
Wait(CROSS_TIME);short_break;
''サブルーチン''
-左旋回でライントレース
sub followline_l ()
{
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
PlaySound(SOUND_UP);
MOVETIME=MOVETIME+600;
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-右旋回でライントレース
sub followline_r ()
{
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+600;
PlaySound(SOUND_DOWN);
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_left0;
}else{
turn_left1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-左回りでライントレース
sub followline_l1 ()
{
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+450;
PlaySound(SOUND_LOW_BEEP);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
Wait(STEP*10);
}
}
}
-右回りのライントレース
sub followline_r1 ()
{
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+150;
PlaySound(SOUND_CLICK);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD +1){
turn_left0;
}else{
turn_left1;
}
Wait(STEP*10);
}
}
}
-ボールをキャッチする
sub catch_1 ()
{
turn_right1;Wait(100);
Off(OUT_AC);Wait(50);
go_fwd;Wait(50);
Off(OUT_AC);Wait(50);
OnFwd(OUT_B);Wait(15);
Off(OUT_B);Wait(10);
turn_left1;Wait(100);
Off(OUT_AC);Wait(50);
}
-ボールを投げる
sub throw_1 ()
{
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(10);
}
-ボールを取りに行く
sub get_1()
{
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(300);
OnRev(OUT_B);Wait(40);Off(OUT_B);Wait(10);
}
''タスクメイン''
task main ()
{
SetSensor(SENSOR_2,SENSOR_LIGHT);
ClearTimer(0);
int nOnline;
int MOVETIME;
turn_left1;Wait(180);
Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=150){
followline_r1();
}
Off(OUT_AC);
Wait(3500);
turn_left1;Wait(80);
Off(OUT_AC);Wait(100);
get_1();
turn_left1;Wait(50);
Off(OUT_AC);Wait(800);
throw_1();
turn_left1;Wait(80);
Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=450){
followline_l1();
}
Off(OUT_AC);
Wait(50);
ClearTimer(0);
turn_right1;Wait(120);Off(OUT_AC);Wait(10);
get_1();
turn_left1;Wait(130);Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=600){
followline_l();
}
Off(OUT_AC);
Wait(50);
turn_left1;Wait(30);Off(OUT_AC);Wait(10);
throw_1();
turn_right1;Wait(100);Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=600){
followline_l();
}
Off(OUT_AC);
Wait(50);
ClearTimer(0);
catch_1();
}
2. 最初にパスを受け取る側のロボット
-しきい値、モーターのパワー、左旋回、右旋回、アーム、交差...
#define THRESHOLD 39 //基準のしきい値
#define HIPOWER 7
#define LOWPOWER 2
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define set_power_N SetPower(OUT_B,LOWPOWER);
#define go_fwd set_power_H; OnFwd(OUT_AC); //前進
#define throw set_power_H; OnFwd(OUT_B); //投げる
#define arm_fwd set_power_N; OnFwd(OUT_B);Wait(30);Off(O...
#define arm_bwd set_power_N; OnRev(OUT_B);Wait(30);Off(O...
#define turn_left1 set_power_L ; //左旋回
OnFwd(OUT_C);OnRev(OUT_A);
#define turn_left0 set_power_L ; //左回転
OnFwd(OUT_C);Off(OUT_A);
#define turn_right0 set_power_L ; //右回転
OnFwd(OUT_A);Off(OUT_C);
#define turn_right1 set_power_L ; //右旋回
OnFwd(OUT_A);OnRev(OUT_C);
#define STEP 1
#define nMAX 200 //判断する最大値
#define short_break Off(OUT_AC); Wait(100); //小休憩
#define CROSS_TIME 300 //交差点を通過する時間
#define cross_line set_power_L; //交差点を通過
OnFwd(OUT_A);OnRev(OUT_C);Wait(CROSS_TIME);short_break;
''サブルーチン''
-左旋回のライントレース
sub followline_l () //左側をライントレース {
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
PlaySound(SOUND_UP);
MOVETIME=MOVETIME+500;
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-右旋回のライントレース
sub followline_r () //右側をライントレース {
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+500;
PlaySound(SOUND_DOWN);
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_left0;
}else{
turn_left1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-左回りのライントレース
sub followline_l1 () //もうひとつの左側のライントレース {
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+500;
PlaySound(SOUND_LOW_BEEP);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
Wait(STEP*10);
}
}
}
-右回りのライントレース
sub catch_1 () //もうひとつの右側のライントレース {
turn_right1;Wait(125);
Off(OUT_AC);Wait(50);
go_fwd;Wait(20);
Off(OUT_AC);Wait(10);
OnFwd(OUT_B);Wait(11);
Off(OUT_B);Wait(10);
go_fwd;Wait(170);
Off(OUT_AC);Wait(1);
OnRev(OUT_B);Wait(10);
Off(OUT_B);Wait(50);
turn_left1;Wait(20);
Off(OUT_AC);Wait(2);
}
-ボールを投げる
sub throw_1 () //ボールを投げる {
throw;Wait(50);
Off(OUT_B);Wait(10);
}
-ボールを取りに行く
sub get_1 () //ボールを拾う {
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(600);
OnRev(OUT_B);Wait(50);
Off(OUT_B);Wait(50);
}
''タスクメイン''
task main () {
SetSensor(SENSOR_2,SENSOR_LIGHT);
ClearTimer(0);
int nOnline;
int MOVETIME;
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
catch_1();
ClearTimer(0);
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
turn_right1;Wait(10);
while(FastTimer(0)<=300){
followline_l1();
}
Off(OUT_AC);Wait(1);
ClearTimer(0);
turn_left1;
Wait(30);
turn_right1;Wait(30);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
turn_left1;Wait(200);
Off(OUT_AC);Wait(50);
throw_1();
turn_right1;Wait(80);
Off(OUT_AC);Wait(10);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
PlaySound(SOUND_CLICK);
ClearTimer(0);
turn_left1;Wait(180);
Off(OUT_AC);Wait(50);
get_1();
turn_right1;Wait(60);
Off(OUT_AC);Wait(600);
throw_1();
Off(OUT_B);Wait(50);
Off(OUT_AC);Wait(50);
}
*まとめ、感想 [#ze9cfd38]
今回の課題は、特に外的な要因によっていろいろな影響が出た...
終了行:
*ロボットの紹介 [#ka0eb18a]
+最初にボールを投げるロボット
#ref(2013a/Member/Sho/Mission2/DSC_0008.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0009.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0010.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0011.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0012.jpg,10%)
#ref(2013a/Member/Sho/Mission2/DSC_0013.jpg,10%)
++最初にボールを受け取るロボット
#ref(2013a/Member/Sho/Mission2/_36974.jpg,30%)
#ref(2013a/Member/Sho/Mission2/_36972.jpg,30%)
#ref(2013a/Member/Sho/Mission2/_36968.jpg,30%)
-ロボットの前方は、ボールをつかむためのアームとパスをする...
-アームの部分を四角形し、ボールを運ぶ時のボールを手放して...
-ロボットの後方は、タイヤをつけてロボット全体のバランスを...
-課題1のロボットとベースを同じにすることでプログラムの面...
-小さくて平たいブロックをたくさん使うことによって、ロボッ...
-タイヤも課題1と同様、小さいものを使うことによって機動性...
-タッチセンサーは、アームのなかほどにつけました。
-もう一つのロボットも同じ仕様にしてパスの出し手と受け手の...
*コース攻略 [#w3a23940]
#ref(2013a/Member/Sho/Mission2/robocon2013a.png,70%)
-今回のコースは、課題1のコースを利用したもので基本的なラ...
-RCXでは、赤外線通信がロボットとの距離が遠くてできなかっ...
-しきい値は、課題1より少し高く39に設定することで調整で...
-パスは、真っ直ぐできるようにロボットどうしの向きに注意し...
-ボールをつかむ動作では、少しでもずれると取れないので慎重...
*プログラム説明 [#ce91a882]
+最初にパスを出す側のロボット
-しきい値、モーターのパワー、左旋回、右旋回、アーム、交差...
#define THRESHOLD 42
#define HIPOWER 7
#define LOWPOWER 2
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define set_power_N SetPower(OUT_B,LOWPOWER);
#define go_fwd set_power_H; OnFwd(OUT_AC);
#define arm_fwd set_power_N; OnFwd(OUT_B);Wait(30);Off(O...
#define arm_bwd set_power_N; OnRev(OUT_B);Wait(30);Off(O...
#define turn_left1 set_power_L ;\
OnFwd(OUT_C);OnRev(OUT_A);
#define turn_left0 set_power_L ;\
OnFwd(OUT_C);Off(OUT_A);
#define turn_right0 set_power_L ;\
OnFwd(OUT_A);Off(OUT_C);
#define turn_right1 set_power_L ;\
OnFwd(OUT_A);OnRev(OUT_C);
#define STEP 1
#define nMAX 3
#define short_break Off(OUT_AC); Wait(100);
#define CROSS_TIME 300
#define cross_line set_power_L;\
OnFwd(OUT_A);OnRev(OUT_C);\
Wait(CROSS_TIME);short_break;
''サブルーチン''
-左旋回でライントレース
sub followline_l ()
{
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
PlaySound(SOUND_UP);
MOVETIME=MOVETIME+600;
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-右旋回でライントレース
sub followline_r ()
{
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+600;
PlaySound(SOUND_DOWN);
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_left0;
}else{
turn_left1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-左回りでライントレース
sub followline_l1 ()
{
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+450;
PlaySound(SOUND_LOW_BEEP);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
Wait(STEP*10);
}
}
}
-右回りのライントレース
sub followline_r1 ()
{
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+150;
PlaySound(SOUND_CLICK);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD +1){
turn_left0;
}else{
turn_left1;
}
Wait(STEP*10);
}
}
}
-ボールをキャッチする
sub catch_1 ()
{
turn_right1;Wait(100);
Off(OUT_AC);Wait(50);
go_fwd;Wait(50);
Off(OUT_AC);Wait(50);
OnFwd(OUT_B);Wait(15);
Off(OUT_B);Wait(10);
turn_left1;Wait(100);
Off(OUT_AC);Wait(50);
}
-ボールを投げる
sub throw_1 ()
{
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(10);
}
-ボールを取りに行く
sub get_1()
{
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(300);
OnRev(OUT_B);Wait(40);Off(OUT_B);Wait(10);
}
''タスクメイン''
task main ()
{
SetSensor(SENSOR_2,SENSOR_LIGHT);
ClearTimer(0);
int nOnline;
int MOVETIME;
turn_left1;Wait(180);
Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=150){
followline_r1();
}
Off(OUT_AC);
Wait(3500);
turn_left1;Wait(80);
Off(OUT_AC);Wait(100);
get_1();
turn_left1;Wait(50);
Off(OUT_AC);Wait(800);
throw_1();
turn_left1;Wait(80);
Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=450){
followline_l1();
}
Off(OUT_AC);
Wait(50);
ClearTimer(0);
turn_right1;Wait(120);Off(OUT_AC);Wait(10);
get_1();
turn_left1;Wait(130);Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=600){
followline_l();
}
Off(OUT_AC);
Wait(50);
turn_left1;Wait(30);Off(OUT_AC);Wait(10);
throw_1();
turn_right1;Wait(100);Off(OUT_AC);Wait(10);
ClearTimer(0);
while(FastTimer(0)<=600){
followline_l();
}
Off(OUT_AC);
Wait(50);
ClearTimer(0);
catch_1();
}
2. 最初にパスを受け取る側のロボット
-しきい値、モーターのパワー、左旋回、右旋回、アーム、交差...
#define THRESHOLD 39 //基準のしきい値
#define HIPOWER 7
#define LOWPOWER 2
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define set_power_N SetPower(OUT_B,LOWPOWER);
#define go_fwd set_power_H; OnFwd(OUT_AC); //前進
#define throw set_power_H; OnFwd(OUT_B); //投げる
#define arm_fwd set_power_N; OnFwd(OUT_B);Wait(30);Off(O...
#define arm_bwd set_power_N; OnRev(OUT_B);Wait(30);Off(O...
#define turn_left1 set_power_L ; //左旋回
OnFwd(OUT_C);OnRev(OUT_A);
#define turn_left0 set_power_L ; //左回転
OnFwd(OUT_C);Off(OUT_A);
#define turn_right0 set_power_L ; //右回転
OnFwd(OUT_A);Off(OUT_C);
#define turn_right1 set_power_L ; //右旋回
OnFwd(OUT_A);OnRev(OUT_C);
#define STEP 1
#define nMAX 200 //判断する最大値
#define short_break Off(OUT_AC); Wait(100); //小休憩
#define CROSS_TIME 300 //交差点を通過する時間
#define cross_line set_power_L; //交差点を通過
OnFwd(OUT_A);OnRev(OUT_C);Wait(CROSS_TIME);short_break;
''サブルーチン''
-左旋回のライントレース
sub followline_l () //左側をライントレース {
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
PlaySound(SOUND_UP);
MOVETIME=MOVETIME+500;
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-右旋回のライントレース
sub followline_r () //右側をライントレース {
int nOnline=0;
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+500;
PlaySound(SOUND_DOWN);
while(nOnline < nMAX && FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_right1;
nOnline++;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_right0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_left0;
}else{
turn_left1;
}
nOnline=0;
}
Wait(STEP*10);
}
}
-左回りのライントレース
sub followline_l1 () //もうひとつの左側のライントレース {
int MOVETIME;
MOVETIME=0;
SetSensor(SENSOR_2,SENSOR_LIGHT);
MOVETIME=MOVETIME+500;
PlaySound(SOUND_LOW_BEEP);
while(FastTimer(0)<=MOVETIME){
if(SENSOR_2< THRESHOLD -14) {
turn_left1;
}else{
if(SENSOR_2< THRESHOLD -10){
turn_left0;
}else if(SENSOR_2< THRESHOLD -7){
go_fwd;
}else if(SENSOR_2< THRESHOLD -1){
turn_right0;
}else{
turn_right1;
}
Wait(STEP*10);
}
}
}
-右回りのライントレース
sub catch_1 () //もうひとつの右側のライントレース {
turn_right1;Wait(125);
Off(OUT_AC);Wait(50);
go_fwd;Wait(20);
Off(OUT_AC);Wait(10);
OnFwd(OUT_B);Wait(11);
Off(OUT_B);Wait(10);
go_fwd;Wait(170);
Off(OUT_AC);Wait(1);
OnRev(OUT_B);Wait(10);
Off(OUT_B);Wait(50);
turn_left1;Wait(20);
Off(OUT_AC);Wait(2);
}
-ボールを投げる
sub throw_1 () //ボールを投げる {
throw;Wait(50);
Off(OUT_B);Wait(10);
}
-ボールを取りに行く
sub get_1 () //ボールを拾う {
OnFwd(OUT_B);Wait(10);
Off(OUT_B);Wait(600);
OnRev(OUT_B);Wait(50);
Off(OUT_B);Wait(50);
}
''タスクメイン''
task main () {
SetSensor(SENSOR_2,SENSOR_LIGHT);
ClearTimer(0);
int nOnline;
int MOVETIME;
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
catch_1();
ClearTimer(0);
while(FastTimer(0)<=500){
followline_l();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
turn_right1;Wait(10);
while(FastTimer(0)<=300){
followline_l1();
}
Off(OUT_AC);Wait(1);
ClearTimer(0);
turn_left1;
Wait(30);
turn_right1;Wait(30);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
turn_left1;Wait(200);
Off(OUT_AC);Wait(50);
throw_1();
turn_right1;Wait(80);
Off(OUT_AC);Wait(10);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
ClearTimer(0);
while(FastTimer(0)<=500){
followline_r();
}
Off(OUT_AC);
Wait(1);
PlaySound(SOUND_CLICK);
ClearTimer(0);
turn_left1;Wait(180);
Off(OUT_AC);Wait(50);
get_1();
turn_right1;Wait(60);
Off(OUT_AC);Wait(600);
throw_1();
Off(OUT_B);Wait(50);
Off(OUT_AC);Wait(50);
}
*まとめ、感想 [#ze9cfd38]
今回の課題は、特に外的な要因によっていろいろな影響が出た...
ページ名: