2015a/Member/o-shima/Mission3
¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¤·¤ÆºîÀ®
[
¥È¥Ã¥×
] [
¿·µ¬
|
°ìÍ÷
|
¸¡º÷
|
ºÇ½ª¹¹¿·
|
¥Ø¥ë¥×
|
¥í¥°¥¤¥ó
]
³«»Ï¹Ô:
[[2015a/Member]]
#contents
*²ÝÂê [#xe7a3619]
Ⱦ·Â1m°ÊÆâ¤Ë¤¢¤ë¶õ¤´Ì¤òõ¤·½Ð¤·¡¢25cm¤Îµ÷Î¥¤«¤é¥Ü¡¼¥ë¤òž¤¬¤·¤Æ¤½¤Î¶õ¤´Ì¤ËÅö¤Æ¤ë¡£¤â¤·¡¢25cm°ÊÆâ¤Ë¶õ¤´Ì¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢30cm¤Þ¤ÇÎ¥¤ì¤ë¡£
*¥í¥Ü¥Ã¥È [#acc6b667]
**Á´ÂÎ [#h1f43ef8]
Á´ÂΤϤ³¤¦¤Ê¤Ã¤Æ¤¤¤ë¡£
#ref(image2 (2).JPG)
#ref(image1 (3).JPG)
**¹½Â¤ [#l9019e71]
¥Ü¡¼¥ë¤Ï¥¢¡¼¥à¤ò¾å²¼¤µ¤»¤Æ¤Ä¤«¤à¡£
#ref(image4.JPG)
#ref(image3 (2).JPG)
¶õ¤´Ì¤Ë¥Ü¡¼¥ë¤òÅö¤Æ¤ë¤È¤¤Ï¥¢¡¼¥à¤ò¾å¤Ë¾å¤²¤¿¾õÂÖ¤«¤é¡¢Á´ÂΤòÁ°¿Ê¤µ¤»¤Æ¥Ü¡¼¥ë¤òž¤¬¤¹¡£
*¥×¥í¥°¥é¥à [#w773cdd8]
**¥×¥í¥°¥é¥à¤ÎÀâÌÀ [#c05c62d1]
¶õ¤´Ì¤ËÂФ·¤Æ¥í¥Ü¥Ã¥È¤Î³ÑÅÙ¤ò·×¬¤¹¤ë¤³¤È¤Ç¶õ¤´Ì¤òõ¤·½Ð¤·¤¿¡£
**¥×¥í¥°¥é¥à [#u3e1a820]
#define speed1 45
#define speed2 30
#define shoot OnRev(OUT_BC,40);Wait(1000);OnRev(OUT_A,30);Wait(500);Off(OUT_A);OnFwd(OUT_BC,80);Wait(300) //¥Ü¡¼¥ë¤òž¤¬¤¹ÄêµÁ
const float diameter =5.45; //¥¿¥¤¥ä¤Îľ·Â
const float track= 10.35; //¥¿¥¤¥ä¤ÎÉý
const float pi =3.1415; //±ß¼þΨ
void fwdDist(float d) //d ÑÁ°¿Ê
{
long angle;
angle = d/(diameter*pi)*360.0; //³ÑÅÙ¤ò·×»»
RotateMotorEx(OUT_BC,speed2,angle,0,true,true); //¥â¡¼¥¿¡¼¤ò45¡ó¤Î¥¹¥Ô¡¼¥É¤ÇƱ´ü¤µ¤»angleÅ٤ޤDzóž
}
void turnAng(long ang) //³ÑÅÙangÅÙ»þ·×²ó¤ê¤ËÀû²ó
{
long angle;
angle=track/diameter*ang;
RotateMotorEx(OUT_BC,speed2,angle,100,true,true);
}
int searchDirection(long ang) //º£¤ÎÊý¸þ¤òÃæ¿´¤ËangÅÙ¤ÎÈϰϤÇõ¤·¡¢´Ì¤Þ¤Ç¤Îµ÷Î¥¤òÊÖ¤¹¡£
{
long angle,tacho_min=0,tacho_corr;
int d_min;
d_min=300; ²¾¤ÎºÇ¾®ÃÍ
angle=(track/diameter)*ang; //Àû²ó³ÑÅÙ¤«¤é¥¿¥¤¥ä¤Î²óž¤ò·×»»
turnAng(ang/2); //»ØÄꤷ¤¿³ÑÅÙ¤ÎȾʬ¤òÀû²ó
ResetTachoCount(OUT_BC); //³ÑÅٷ׬¤ò¥ê¥»¥Ã¥È
OnFwdSync(OUT_BC,speed2,-100); //30¡ó¤Î¥¹¥Ô¡¼¥É¤ÇÈ¿»þ·×²ó¤ê¤ËÀû²ó
while(MotorTachoCount(OUT_B)<=angle)
{
if(SensorUS(S1)<d_min){
d_min=SensorUS(S1);
tacho_min=MotorTachoCount(OUT_B); //ºÇ¾®Ãͤò¹¹¿·
}
}
OnFwdSyncEx(OUT_BC,speed2,100,RESET_NONE);
until(MotorTachoCount(OUT_B)<=tacho_min||SensorUS(S1)<=d_min); //´Ì¤Î¤È¤³¤í¤Þ¤ÇÀû²ó
Wait(14);
Off(OUT_BC);Wait(500);
return d_min;
}
task main() //´Ì¤òõ¤·½Ð¤·¤Æ25ѤÇÄä»ß¡¢¥Ü¡¼¥ë¤òž¤¬¤¹
{
SetSensorLowspeed(S1);
int d =searchDirection(500);
if (d>25.0){
fwdDist(d-25.0);
shoot;
}
}
*´¶ÁÛ [#zb0fcff1]
**´¶ÁÛ [#u30fa096]
¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò»²¹Í¤Ë¤·¤Æ³ÑÅٻȤä¿¡£Íý²ò¤¹¤ë¤Î¤¬Æñ¤·¤«¤Ã¤¿¤¬¡¢¤È¤Æ¤âÌÌÇò¤«¤Ã¤¿¡£º£¤Þ¤Ç»È¤Ã¤Æ¤Ê¤«¤Ã¤¿³ÑÅٻȤäƥí¥Ü¥Ã¥È¤òư¤«¤¹¤³¤È¤¬¿·Á¯¤ÇÌÌÇò¤«¤Ã¤¿¡£¤³¤ì¤ò»È¤¨¤Ð²ÝÂê1¡¢2¤Î¥×¥í¥°¥é¥à¤ò¤â¤Ã¤È¤è¤êÎɤ¤¤â¤Î¤Ë¤Ç¤¤ë¤È»×¤Ã¤¿¡£
½ªÎ»¹Ô:
[[2015a/Member]]
#contents
*²ÝÂê [#xe7a3619]
Ⱦ·Â1m°ÊÆâ¤Ë¤¢¤ë¶õ¤´Ì¤òõ¤·½Ð¤·¡¢25cm¤Îµ÷Î¥¤«¤é¥Ü¡¼¥ë¤òž¤¬¤·¤Æ¤½¤Î¶õ¤´Ì¤ËÅö¤Æ¤ë¡£¤â¤·¡¢25cm°ÊÆâ¤Ë¶õ¤´Ì¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢30cm¤Þ¤ÇÎ¥¤ì¤ë¡£
*¥í¥Ü¥Ã¥È [#acc6b667]
**Á´ÂÎ [#h1f43ef8]
Á´ÂΤϤ³¤¦¤Ê¤Ã¤Æ¤¤¤ë¡£
#ref(image2 (2).JPG)
#ref(image1 (3).JPG)
**¹½Â¤ [#l9019e71]
¥Ü¡¼¥ë¤Ï¥¢¡¼¥à¤ò¾å²¼¤µ¤»¤Æ¤Ä¤«¤à¡£
#ref(image4.JPG)
#ref(image3 (2).JPG)
¶õ¤´Ì¤Ë¥Ü¡¼¥ë¤òÅö¤Æ¤ë¤È¤¤Ï¥¢¡¼¥à¤ò¾å¤Ë¾å¤²¤¿¾õÂÖ¤«¤é¡¢Á´ÂΤòÁ°¿Ê¤µ¤»¤Æ¥Ü¡¼¥ë¤òž¤¬¤¹¡£
*¥×¥í¥°¥é¥à [#w773cdd8]
**¥×¥í¥°¥é¥à¤ÎÀâÌÀ [#c05c62d1]
¶õ¤´Ì¤ËÂФ·¤Æ¥í¥Ü¥Ã¥È¤Î³ÑÅÙ¤ò·×¬¤¹¤ë¤³¤È¤Ç¶õ¤´Ì¤òõ¤·½Ð¤·¤¿¡£
**¥×¥í¥°¥é¥à [#u3e1a820]
#define speed1 45
#define speed2 30
#define shoot OnRev(OUT_BC,40);Wait(1000);OnRev(OUT_A,30);Wait(500);Off(OUT_A);OnFwd(OUT_BC,80);Wait(300) //¥Ü¡¼¥ë¤òž¤¬¤¹ÄêµÁ
const float diameter =5.45; //¥¿¥¤¥ä¤Îľ·Â
const float track= 10.35; //¥¿¥¤¥ä¤ÎÉý
const float pi =3.1415; //±ß¼þΨ
void fwdDist(float d) //d ÑÁ°¿Ê
{
long angle;
angle = d/(diameter*pi)*360.0; //³ÑÅÙ¤ò·×»»
RotateMotorEx(OUT_BC,speed2,angle,0,true,true); //¥â¡¼¥¿¡¼¤ò45¡ó¤Î¥¹¥Ô¡¼¥É¤ÇƱ´ü¤µ¤»angleÅ٤ޤDzóž
}
void turnAng(long ang) //³ÑÅÙangÅÙ»þ·×²ó¤ê¤ËÀû²ó
{
long angle;
angle=track/diameter*ang;
RotateMotorEx(OUT_BC,speed2,angle,100,true,true);
}
int searchDirection(long ang) //º£¤ÎÊý¸þ¤òÃæ¿´¤ËangÅÙ¤ÎÈϰϤÇõ¤·¡¢´Ì¤Þ¤Ç¤Îµ÷Î¥¤òÊÖ¤¹¡£
{
long angle,tacho_min=0,tacho_corr;
int d_min;
d_min=300; ²¾¤ÎºÇ¾®ÃÍ
angle=(track/diameter)*ang; //Àû²ó³ÑÅÙ¤«¤é¥¿¥¤¥ä¤Î²óž¤ò·×»»
turnAng(ang/2); //»ØÄꤷ¤¿³ÑÅÙ¤ÎȾʬ¤òÀû²ó
ResetTachoCount(OUT_BC); //³ÑÅٷ׬¤ò¥ê¥»¥Ã¥È
OnFwdSync(OUT_BC,speed2,-100); //30¡ó¤Î¥¹¥Ô¡¼¥É¤ÇÈ¿»þ·×²ó¤ê¤ËÀû²ó
while(MotorTachoCount(OUT_B)<=angle)
{
if(SensorUS(S1)<d_min){
d_min=SensorUS(S1);
tacho_min=MotorTachoCount(OUT_B); //ºÇ¾®Ãͤò¹¹¿·
}
}
OnFwdSyncEx(OUT_BC,speed2,100,RESET_NONE);
until(MotorTachoCount(OUT_B)<=tacho_min||SensorUS(S1)<=d_min); //´Ì¤Î¤È¤³¤í¤Þ¤ÇÀû²ó
Wait(14);
Off(OUT_BC);Wait(500);
return d_min;
}
task main() //´Ì¤òõ¤·½Ð¤·¤Æ25ѤÇÄä»ß¡¢¥Ü¡¼¥ë¤òž¤¬¤¹
{
SetSensorLowspeed(S1);
int d =searchDirection(500);
if (d>25.0){
fwdDist(d-25.0);
shoot;
}
}
*´¶ÁÛ [#zb0fcff1]
**´¶ÁÛ [#u30fa096]
¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò»²¹Í¤Ë¤·¤Æ³ÑÅٻȤä¿¡£Íý²ò¤¹¤ë¤Î¤¬Æñ¤·¤«¤Ã¤¿¤¬¡¢¤È¤Æ¤âÌÌÇò¤«¤Ã¤¿¡£º£¤Þ¤Ç»È¤Ã¤Æ¤Ê¤«¤Ã¤¿³ÑÅٻȤäƥí¥Ü¥Ã¥È¤òư¤«¤¹¤³¤È¤¬¿·Á¯¤ÇÌÌÇò¤«¤Ã¤¿¡£¤³¤ì¤ò»È¤¨¤Ð²ÝÂê1¡¢2¤Î¥×¥í¥°¥é¥à¤ò¤â¤Ã¤È¤è¤êÎɤ¤¤â¤Î¤Ë¤Ç¤¤ë¤È»×¤Ã¤¿¡£
¥Ú¡¼¥¸Ì¾: