課題については2019a/Mission1を参照。
私は今年一年過ごすこの街、「松本」を選んだ。
ペンが両タイヤの中心に来るように置き、ペンが軸となるようにすることでペンが降りている状態でも回転することが出来るようにした...と思っていた。
これがペンを上下する機巧である。ペンの上下とロボットの動きで文字を書くようにした。
まず直線を二種類、90度の右回転と左回転を調べ定義した。このとき直線と回転を連続して行うと、調べたときの動きをせず、行動と行動の間に停止させる必要があることにきづく。 その後、文字をこのようにした。
はじめに定義した四種のdefineに加え、さらにペンの上下と他四種を定義した。
#define t_l90 OnFwd(OUT_A);OnRev(OUT_C);Off(OUT_B);Wait(22);Off(OUT_ABC);//左回転(90度) #define t_l OnFwd(OUT_A);OnRev(OUT_C);Off(OUT_B);//左回転 #define t_r90 OnFwd(OUT_C);OnRev(OUT_A);Off(OUT_B);Wait(23);Off(OUT_ABC);//右回転(90度) #define t_r OnFwd(OUT_C);OnRev(OUT_A);Off(OUT_B);//右回転 #define str2 OnFwd(OUT_AC);Off(OUT_B);Wait(6);Off(OUT_ABC);//直進2 #define str1 OnFwd(OUT_AC);Off(OUT_B);Wait(3);Off(OUT_ABC);//直進1 #define back OnRev(OUT_AC);Off(OUT_B);//後退 #define stopABC Off(OUT_ABC);Wait(100);//停止 #define up OnFwd (OUT_B);Wait(5);Off(OUT_B);//ペンを上げる #define down OnRev(OUT_B);Wait(4);Off(OUT_B);//ペンを下げる
黒の矢印が筆を下ろした状態での動き
赤の矢印が筆を上げた状態での動き
松を書くためのプログラミング
黒の1
task main() { stopABC str2
赤の1
stopABC up stopABC t_r Wait(36); back Wait(3);
黒の2
stopABC down stopABC str1 str2 str2
赤の2
stopABC up stopABC back Wait(12); stopABC t_r Wait(6);
黒の3
stopABC down stopABC str2 stopABC back Wait(8); stopABC t_l Wait(10); stopABC str2
赤の3
stopABC up stopABC back Wait(8); stopABC t_l Wait(42); stopABC str2 str1
黒の4
stopABC down stopABC str2
赤の4
stopABC up stopABC str1 t_r90
黒の5
stopABC down stopABC str2
赤の5
stopABC up stopABC back Wait(6); stopABC t_r Wait(32); stopABC str2
黒の6
stopABC down stopABC str2 stopABC t_l Wait(45); stopABC str2 stopABC t_r90 stopABC str2 back Wait(8);
赤の6
stopABC up stopABC back Wait(10); stopABC t_l Wait(28); stopABC str2 str2
本を書くためのプログラミング
黒の7
stopABC down stopABC str2 str2
赤の7
stopABC up back Wait(3); stopABC t_r Wait(36); back Wait(3);
黒の8
stopABC down stopABC str2 str2 str1
赤の8
stopABC up back Wait(15); stopABC t_r Wait(16);
黒の9
stopABC down str2 str2 stopABC back Wait(14); stopABC t_l90 stopABC str2 str2
赤の9
stopABC up stopABC back Wait(6); t_r Wait(35); stopABC str1
黒の10
stopABC down stopABC str2 stopABC up }
同じプログラムでこれだけの差が出来てしまった。この理由として次のことが考えられる。
思った通りになかなか動いてもらえず苦労した。同じプログラムで異なる動きを見せたときは、それはもう困った。完璧にはほど遠いが、読めるくらいまでになったことはとても感動している。