2018a/Member/Mooo/Mission1
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[2018a/Member]]
#contents
*課題 [#ba889013]
これまで住んだことのある都道府県名、市町村名、地区名など...
**選択した文字 [#d30c6c6c]
私は、「富士」という文字を課題に選んだ。
選んだ理由としては、画数は多くなってしまうが斜めの線がな...
*ロボットの説明 [#q900608f]
**ロボットの全体 [#c07df9ef]
まず初めに、相方との相談でXY軸のロボットを作ろうかと考え...
&ref(2018a/Member/Mooo/Mission1/全体.jpg,100%,前から見た...
よって、このロボットは
?車部分の機構
?ペンを上げ下げする機構
の2つからできている。
**?車部分の機構 [#m7281ccd]
土台である車部分の機構は、後輪の左右両方に一つずつモータ...
前輪部分は当初360度回転するタイヤを取り付けていたが、本体...
&ref(2018a/Member/Mooo/Mission1/前輪.jpg,100%,前輪部分の...
**?ペンを上げ下げする機構 [#x37606b1]
ペンを上げ下げする機構については、下の図のようになってい...
&ref(2018a/Member/Mooo/Mission1/ペン.jpg,100%,ペンを上げ...
*プログラムの説明 [#f5a17872]
**プログラムの下準備 [#jbbb994a]
プログラムの下準備として、タイヤが1回転でどの程度進むのか...
タイヤ1回転で進む距離の計測方法はタイヤを10回転させるプロ...
-タイヤ1回転で進む距離→17.5?
-タイヤ同士の距離→17?
となった。
**基本事項の定義 [#la12c996]
各モーターの出力などをはじめに定義しておいた。
#define PA 75 // Aの規定の出力
#define PB 75 // Bの規定の出力
#define PC 75 // Cの規定の出力
#define CM (750/35) // 1cm進む時に、タイヤが回る角度
#define WT 100 // 1cm進む時の待機時間
**前進、後進のプログラム [#m1e83218]
どちらのプログラムも長さを変数で指定しておくことによって...
-前進のプログラム
void FWD(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, -x * CM, 0, true, true);
Wait(100);
#else
OnRevSync(OUT_AC, 30, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
-後進のプログラム
void REV(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, x * CM, 0, true, true);
Wait(100);
#else
OnFwdSync(OUT_AC, 40, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
**曲がる際のプログラム [#b7e78961]
こちらも角度を変数指定しておくことで、簡略化した。
-左に直角に曲がるとき
void turnL90()
{
RotateMotorEx(OUT_AC, 30, 235, 100, true, true);
Wait(200);
}
-右に直角に曲がるとき
void turnR90()
{
RotateMotorEx(OUT_AC, 30, -235, -100, true, true);
Wait(200);
}
-右にX度曲がるとき
void turnR(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, -100, true, true);
Wait(200);
}
-左にX度曲がるとき
void turnL(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, 100, true, true);
Wait(200);
}
**ペンの上げ下げのプログラム [#tb825f29]
一番簡単だったプログラム
-ペンを下げる
void pen_down()
{
RotateMotor(OUT_B, 40, -20);
Wait(100);
}
-ペンを上げる
void pen_up()
{
RotateMotor(OUT_B, 40, 20);
Wait(100);
}
** 縦線、横線を引くプログラム[#qda95588]
定義したものを使い、長さXの縦横の線を引くプログラム
「富士」は斜めの線は必要ないので斜めの線のプログラムは組...
-横線
void yokobou(int x)
{
RotateMotor(OUT_A, 25, -x * 10);
Wait(100);
pen_down();
RotateMotor(OUT_A, 25, x * 10);
Wait(100);
RotateMotor(OUT_C, 25, -x * 10);
Wait(100);
pen_up();
RotateMotor(OUT_C, 25, x * 10);
Wait(100);
}
-縦線
void tatebou(int x)
{
pen_down();
RotateMotorEx(OUT_AC, 20, x * CM, 0, true, true);
Wait(100);
pen_up();
}
**幅寄せプログラム [#e579e0ea]
次の線までの移動のプログラム
こちらも変数を変えるだけで、あらゆる動きに対応できるよう...
#define HABA1 70
#define HABA2 100
#define HABA3 130
#define HABA4 161
#define HABA5 178
#define HABA6 195
void habayoseR(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, -para);
RotateMotor(OUT_A, 30, -(para * 103 / 100));
Wait(200);
}
void habayoseL(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, -para);
RotateMotor(OUT_C, 30, -para);
Wait(200);
}
**プログラム本編 [#adfff7b1]
// タイヤ 1回転で 17.5cm
// タイヤ同士の距離 17cm
#define PA 75 // Aの規定の出力
#define PB 75 // Bの規定の出力
#define PC 75 // Cの規定の出力
#define CM (750/35) // 1cm進む時に、タイヤが回る角度
#define WT 100 // 1cm進む時の待機時間
void FWD(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, -x * CM, 0, true, true);
Wait(100);
#else
OnRevSync(OUT_AC, 30, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
void REV(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, x * CM, 0, true, true);
Wait(100);
#else
OnFwdSync(OUT_AC, 40, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
void turnL90()
{
RotateMotorEx(OUT_AC, 30, 235, 100, true, true);
Wait(200);
}
void turnR90()
{
RotateMotorEx(OUT_AC, 30, -235, -100, true, true);
Wait(200);
}
void turnR(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, -100, true, true);
Wait(200);
}
void turnL(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, 100, true, true);
Wait(200);
}
#define HABA1 70
#define HABA2 100
#define HABA3 130
#define HABA4 161
#define HABA5 178
#define HABA6 195
void habayoseR(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, -para);
RotateMotor(OUT_A, 30, -(para * 103 / 100));
Wait(200);
}
void habayoseL(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, -para);
RotateMotor(OUT_C, 30, -para);
Wait(200);
}
void pen_down()
{
RotateMotor(OUT_B, 40, -20);
Wait(100);
}
void pen_up()
{
RotateMotor(OUT_B, 40, 20);
Wait(100);
}
void yokobou(int x)
{
RotateMotor(OUT_A, 25, -x * 10);
Wait(100);
pen_down();
RotateMotor(OUT_A, 25, x * 10);
Wait(100);
RotateMotor(OUT_C, 25, -x * 10);
Wait(100);
pen_up();
RotateMotor(OUT_C, 25, x * 10);
Wait(100);
}
void tatebou(int x)
{
pen_down();
RotateMotorEx(OUT_AC, 20, x * CM, 0, true, true);
Wait(100);
pen_up();
}
void draw_fu()
{
tatebou(1); //ウ冠
habayoseL(3);
tatebou(1);
FWD(1);
habayoseR(6);
tatebou(1);
habayoseL(5); //富の口
REV(1);
tatebou(2);
FWD(2);
habayoseR(4);
tatebou(2);
REV(2); //富の田
tatebou(4);
FWD(4);
habayoseL(2);
tatebou(4);
FWD(4);
habayoseL(2);
tatebou(4);
turnL90(); //ウ冠へ移動
FWD(9);
turnR90();
turnR(10);
FWD(23);
turnR90();
turnR(10);
// turnR(14);
// REV(2);
tatebou(6);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(3);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
}
void draw_ji()
{
tatebou(6);
FWD(5);
habayoseR(5);
tatebou(4);
FWD(15);
turnL90();
turnL(10);
REV(11);
tatebou(4);
}
task main()
{
pen_up();
draw_fu();
FWD(5);
habayoseR(3);
draw_ji();
}
*最後に [#p8306ac6]
車型のため、覚悟はしていたがかなりの量のプログラムになっ...
終了行:
[[2018a/Member]]
#contents
*課題 [#ba889013]
これまで住んだことのある都道府県名、市町村名、地区名など...
**選択した文字 [#d30c6c6c]
私は、「富士」という文字を課題に選んだ。
選んだ理由としては、画数は多くなってしまうが斜めの線がな...
*ロボットの説明 [#q900608f]
**ロボットの全体 [#c07df9ef]
まず初めに、相方との相談でXY軸のロボットを作ろうかと考え...
&ref(2018a/Member/Mooo/Mission1/全体.jpg,100%,前から見た...
よって、このロボットは
?車部分の機構
?ペンを上げ下げする機構
の2つからできている。
**?車部分の機構 [#m7281ccd]
土台である車部分の機構は、後輪の左右両方に一つずつモータ...
前輪部分は当初360度回転するタイヤを取り付けていたが、本体...
&ref(2018a/Member/Mooo/Mission1/前輪.jpg,100%,前輪部分の...
**?ペンを上げ下げする機構 [#x37606b1]
ペンを上げ下げする機構については、下の図のようになってい...
&ref(2018a/Member/Mooo/Mission1/ペン.jpg,100%,ペンを上げ...
*プログラムの説明 [#f5a17872]
**プログラムの下準備 [#jbbb994a]
プログラムの下準備として、タイヤが1回転でどの程度進むのか...
タイヤ1回転で進む距離の計測方法はタイヤを10回転させるプロ...
-タイヤ1回転で進む距離→17.5?
-タイヤ同士の距離→17?
となった。
**基本事項の定義 [#la12c996]
各モーターの出力などをはじめに定義しておいた。
#define PA 75 // Aの規定の出力
#define PB 75 // Bの規定の出力
#define PC 75 // Cの規定の出力
#define CM (750/35) // 1cm進む時に、タイヤが回る角度
#define WT 100 // 1cm進む時の待機時間
**前進、後進のプログラム [#m1e83218]
どちらのプログラムも長さを変数で指定しておくことによって...
-前進のプログラム
void FWD(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, -x * CM, 0, true, true);
Wait(100);
#else
OnRevSync(OUT_AC, 30, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
-後進のプログラム
void REV(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, x * CM, 0, true, true);
Wait(100);
#else
OnFwdSync(OUT_AC, 40, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
**曲がる際のプログラム [#b7e78961]
こちらも角度を変数指定しておくことで、簡略化した。
-左に直角に曲がるとき
void turnL90()
{
RotateMotorEx(OUT_AC, 30, 235, 100, true, true);
Wait(200);
}
-右に直角に曲がるとき
void turnR90()
{
RotateMotorEx(OUT_AC, 30, -235, -100, true, true);
Wait(200);
}
-右にX度曲がるとき
void turnR(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, -100, true, true);
Wait(200);
}
-左にX度曲がるとき
void turnL(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, 100, true, true);
Wait(200);
}
**ペンの上げ下げのプログラム [#tb825f29]
一番簡単だったプログラム
-ペンを下げる
void pen_down()
{
RotateMotor(OUT_B, 40, -20);
Wait(100);
}
-ペンを上げる
void pen_up()
{
RotateMotor(OUT_B, 40, 20);
Wait(100);
}
** 縦線、横線を引くプログラム[#qda95588]
定義したものを使い、長さXの縦横の線を引くプログラム
「富士」は斜めの線は必要ないので斜めの線のプログラムは組...
-横線
void yokobou(int x)
{
RotateMotor(OUT_A, 25, -x * 10);
Wait(100);
pen_down();
RotateMotor(OUT_A, 25, x * 10);
Wait(100);
RotateMotor(OUT_C, 25, -x * 10);
Wait(100);
pen_up();
RotateMotor(OUT_C, 25, x * 10);
Wait(100);
}
-縦線
void tatebou(int x)
{
pen_down();
RotateMotorEx(OUT_AC, 20, x * CM, 0, true, true);
Wait(100);
pen_up();
}
**幅寄せプログラム [#e579e0ea]
次の線までの移動のプログラム
こちらも変数を変えるだけで、あらゆる動きに対応できるよう...
#define HABA1 70
#define HABA2 100
#define HABA3 130
#define HABA4 161
#define HABA5 178
#define HABA6 195
void habayoseR(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, -para);
RotateMotor(OUT_A, 30, -(para * 103 / 100));
Wait(200);
}
void habayoseL(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, -para);
RotateMotor(OUT_C, 30, -para);
Wait(200);
}
**プログラム本編 [#adfff7b1]
// タイヤ 1回転で 17.5cm
// タイヤ同士の距離 17cm
#define PA 75 // Aの規定の出力
#define PB 75 // Bの規定の出力
#define PC 75 // Cの規定の出力
#define CM (750/35) // 1cm進む時に、タイヤが回る角度
#define WT 100 // 1cm進む時の待機時間
void FWD(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, -x * CM, 0, true, true);
Wait(100);
#else
OnRevSync(OUT_AC, 30, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
void REV(int x)
{
#if 1
RotateMotorEx(OUT_AC, 30, x * CM, 0, true, true);
Wait(100);
#else
OnFwdSync(OUT_AC, 40, 0);
Wait(x * 10 * WT);
Off(OUT_AC);
Wait(100);
#endif
}
void turnL90()
{
RotateMotorEx(OUT_AC, 30, 235, 100, true, true);
Wait(200);
}
void turnR90()
{
RotateMotorEx(OUT_AC, 30, -235, -100, true, true);
Wait(200);
}
void turnR(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, -100, true, true);
Wait(200);
}
void turnL(int x)
{
RotateMotorEx(OUT_AC, 30, x * 235 / 90, 100, true, true);
Wait(200);
}
#define HABA1 70
#define HABA2 100
#define HABA3 130
#define HABA4 161
#define HABA5 178
#define HABA6 195
void habayoseR(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, -para);
RotateMotor(OUT_A, 30, -(para * 103 / 100));
Wait(200);
}
void habayoseL(int x)
{
int para;
if (x == 1)
para = HABA1;
else if (x == 2)
para = HABA2;
else if (x == 3)
para = HABA3;
else if (x == 4)
para = HABA4;
else if (x == 5)
para = HABA5;
else if (x == 6)
para = HABA6;
else
return;
RotateMotor(OUT_A, 30, para);
RotateMotor(OUT_C, 30, para);
RotateMotor(OUT_A, 30, -para);
RotateMotor(OUT_C, 30, -para);
Wait(200);
}
void pen_down()
{
RotateMotor(OUT_B, 40, -20);
Wait(100);
}
void pen_up()
{
RotateMotor(OUT_B, 40, 20);
Wait(100);
}
void yokobou(int x)
{
RotateMotor(OUT_A, 25, -x * 10);
Wait(100);
pen_down();
RotateMotor(OUT_A, 25, x * 10);
Wait(100);
RotateMotor(OUT_C, 25, -x * 10);
Wait(100);
pen_up();
RotateMotor(OUT_C, 25, x * 10);
Wait(100);
}
void tatebou(int x)
{
pen_down();
RotateMotorEx(OUT_AC, 20, x * CM, 0, true, true);
Wait(100);
pen_up();
}
void draw_fu()
{
tatebou(1); //ウ冠
habayoseL(3);
tatebou(1);
FWD(1);
habayoseR(6);
tatebou(1);
habayoseL(5); //富の口
REV(1);
tatebou(2);
FWD(2);
habayoseR(4);
tatebou(2);
REV(2); //富の田
tatebou(4);
FWD(4);
habayoseL(2);
tatebou(4);
FWD(4);
habayoseL(2);
tatebou(4);
turnL90(); //ウ冠へ移動
FWD(9);
turnR90();
turnR(10);
FWD(23);
turnR90();
turnR(10);
// turnR(14);
// REV(2);
tatebou(6);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(3);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
FWD(4);
habayoseR(2);
tatebou(4);
}
void draw_ji()
{
tatebou(6);
FWD(5);
habayoseR(5);
tatebou(4);
FWD(15);
turnL90();
turnL(10);
REV(11);
tatebou(4);
}
task main()
{
pen_up();
draw_fu();
FWD(5);
habayoseR(3);
draw_ji();
}
*最後に [#p8306ac6]
車型のため、覚悟はしていたがかなりの量のプログラムになっ...
ページ名: