#contents *²ÝÂꣲ [#bc070098] ¹õ¤¤Àþ¤Ë±è¤Ã¤Æ·è¤á¤é¤ì¤¿¥³¡¼¥¹¤ò¿Ê¤ß¥Ô¥ó¥Ý¥óµå¤òÅÓÃæ¤Ç¤Ä¤«¤ß¥´¡¼¥ë¤Ë¥·¥å¡¼¥È¤»¤è¤È¸À¤¦²ÝÂê¤Ç¤¢¤Ã¤¿¡£ **¥³¡¼¥¹ [#l73ed32a] AÃÏÅÀ¤«¤é½Ðȯ ¢ª B ¢ª C(ľ¿Ê) ¢ª D(°ì»þÄä»ß¤Î¸å¡¢Ä¾¿Ê) ¢ª E ¢ª F ¢ª G(°ì»þÄä»ß¤Î¸å¡¢±¦ÀÞ) ¢ª H ¢ª I ¢ª J(±¦ÀÞ) ¢ª K(º¸ÀÞ) ¢ª L(¥Ô¥ó¥Ý¥ó¶Ì¤ò¤Ä¤«¤à) ¢ª K(ľ¿Ê) ¢ª M(°ì»þÄä»ß) ¢ª ¥·¥å¡¼¥È¢ª AÃÏÅÀ¤ËÆþ¤ë(¥´¡¼¥ë) ¤Î¥³¡¼¥¹¤Ë¤·¤¿¡£ &ref(2019a/Member/hiroe/Mission2/2019a-mission2.png,50%,¥³¡¼¥¹); *¥í¥Ü¥Ã¥È [#ceec241e] &ref(2019a/Member/hiroe/Mission2/robo1.jpg,20%,robo); ¤Ê¤ë¤Ù¤¯¥«¥é¡¼¥»¥ó¥µ¡¼¤¬£²¤Ä¤Î¥¿¥¤¥ä¤Î¿¿¤óÃæ¤Ë¤¯¤ë¤è¤¦¤Ë¤·¡¢²óž¤ÎÃæ¿´¤ò¥«¥é¡¼¥»¥ó¥µ¡¼¤Î°ÌÃ֤ˤʤë¤è¤¦¤Ë¤·¤¿¡£ &ref(2019a/Member/hiroe/Mission2/robo4.jpg,20%,robo4); µå¤ò½¦¤¦¥¢¡¼¥à¤ò¥«¥é¡¼¥»¥ó¥µ¡¼¤ÎÁ°¤ËÀßÃÖ¤·¤¿¡£¤³¤Î¥¢¡¼¥à¤ò¾å²¼¤µ¤»¤ë¤³¤È¤Çµå¤ò½¦¤¤¡¢±¿¤Ó¡¢¥·¥å¡¼¥È¤¹¤ë¡£ &ref(2019a/Member/hiroe/Mission2/robo2.jpg,20%,robo2); *¥é¥¤¥ó¥È¥ì¡¼¥¹ [#p0767076] ¥é¥¤¥ó¥È¥ì¡¼¥¹¤Î´ðËÜŪ¤ÊÊý¿Ë¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£¥«¥é¡¼¥»¥ó¥µ¡¼¤ÎÈϰϤΰìÉô¤Ë¥³¡¼¥¹¤¬Æþ¤ë¤è¤¦¤Ë¥»¥Ã¥Æ¥£¥ó¥°¤·¡¢¤¢¤ëÌÀ¤ë¤µ¤Î»þ¤Ïľ¿Ê¡¢¤½¤ì¤è¤ê°Å¤¯¤Ê¤Ã¤¿¤é±¦²óž¡ÊRturn¡Ë¡¢ÌÀ¤ë¤¯¤Ê¤Ã¤¿¤éº¸²óž¡ÊLturn¡Ë¤¹¤ë¡£ &ref(2019a/Member/hiroe/Mission2/°Å¤¤1.jpg,50%,°Å¤¤); ¥»¥Ã¥Æ¥£¥ó¥°¤¹¤ë°ÌÃÖ¤ò¥³¡¼¥¹¤Ë¤¢¤Þ¤ê¤«¤Ö¤é¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£¤½¤¦¤¹¤ë¤³¤È¤Ç¸òº¹ÅÀ¤ËÆþ¤Ã¤¿¤È¤¤Ï¥«¡¼¥Ö¤ËÈæ¤ÙµÞ·ã¤Ë°Å¤¯¤Ê¤ë¡£¤³¤ì¤Ç¸òº¹ÅÀ¤òǧ¼±¤¹¤ë¡£ &ref(2019a/Member/hiroe/Mission2/°Å¤¯¤Ê¤ë.jpg,50%,°Å¤¯¤Ê¤ë); ¤½¤ì¤¾¤ì¤ÎÌÀ¤ë¤µ¤ÎÃͤϲ¼¿Þ¤ÎÄ̤ê¤Ç¤¢¤ë¡£¼ÂºÝ¤ËÁö¤é¤»¤ë»þ¤Ë¥³¡¼¥É¤ÎÃæ¤Ëprint(cs.value())¤òÆþ¤ì¤ë¤ÈÌÀ¤ë¤µ¤ÎÃͤòÃΤ뤳¤È¤¬½ÐÍè¤ë¡£¤½¤ì¤ò¸µ¤ËÌÀ¤ë¤µ¤ÎÃͤ泦¤ò·è¤á¤¿¡£(¤Ê¤ª¥é¥¤¥ó¤Î̵¤¤¿¿¤ÃÇò¤Î¤È¤¤Ï£¸£°°Ê¾å¤ÎÃͤˤʤ롣) &ref(2019a/Member/hiroe/Mission2/ÌÀ¤ë¤µ¤ÎÃÍ.jpg,50%,ÌÀ¤ë¤µ¤ÎÃÍ); ¤³¤Î²¼¼Ì¿¿¤Ç¥«¥é¡¼¥»¥ó¥µ¡¼¤Ï£µ£°¤òÊÖ¤¹¡£ &ref(2019a/Member/hiroe/Mission2/robo5.jpg,20%,robo5); *¥×¥í¥°¥é¥à [#w9879415] **»Ï¤á¤Ë [#l39b5294] -ev3devÍѤ˽ñ¤«¤ì¤¿python¥é¥¤¥Ö¥é¥ê¤äsleep´Ø¿ô¤Ê¤É¤òƳÆþ¤¹¤ë¡£ #!/usr/bin/env python3 from ev3dev.ev3 import * from time import * m = LargeMotor('outA') n = LargeMotor('outB') l = MidiumMoter('outC') cs = ColorSensor('in2') cs.mode = 'COL-REFLECT' m¤Ïº¸Â¦¤Î¼ÖÎØ¤òư¤«¤¹¥â¡¼¥¿¡¼¡¢n¤Ï±¦Â¦¤Î¼ÖÎØ¤òư¤«¤¹¥â¡¼¥¿¡¼¡¢l¤Ï¥¢¡¼¥à¤ò¾å¤²²¼¤²¤µ¤»¤ë¥â¡¼¥¿¡¼¤òɽ¤·¤Æ¤¤¤ë¡£cs¤Ï¥«¥é¡¼¥»¥ó¥µ¡¼¤Î¤³¤È¤Çº£²ó¤Ï¿§¤ÎÌÀ¤ë¤µ¤¬ÌÀ¤ë¤¯¤Ê¤ë¤Û¤ÉÃͤ¬Â礤¯¤Ê¤ë¤è¤¦¤Ë£°¡Á£±£°£°¤Þ¤Ç¤ÎÃͤòÊÖ¤¹¡£ d_sp=150) n.run_timed(time_sp=100, speed_sp=150) def back(): m.run_timed(time_sp=100, speed_sp=-150) n.run_timed(time_sp=100, speed_sp=-150) Á°²ó¤Î¡Öµ¡ÂΤòư¤«¤¹¥¹¥Ô¡¼¥É¤¬Â®¤¹¤®¤ë¡Êspeed_sp=500¡Ë¤Èưºî¤¬Á´¤¯°ÂÄꤷ¤Ê¤¤¡×¤È¤¤¤¦È¿¾Ê¤â³è¤«¤·¡¢º£²ó¤Ï¥¹¥Ô¡¼¥É¤ò150¤ÇÅý°ì¤·¤¿¡£ def Rturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') def Lturn(x): m.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') Lturn¤Ç±¦¥¿¥¤¥ä¤ò¼´¤Ëº¸²óž¡¢Rturn¤Çº¸¥¿¥¤¥ä¤ò¼´¤Ë±¦²óž¤¹¤ë¡£´ðËÜŪ¤Ë¤Ï£ø¤Ë£°¤òÂåÆþ¤·¾¯¤·¤º¤Ä²óž¤¹¤ë¤è¤¦¤Ë¤¹¤ë¤¬¡¢°ìÅ٤ˤ¿¤¯¤µ¤ó²óž¤µ¤»¤¿¤¤¤È¤¤Ï£ø¤ËÂ礤ÊÃͤòÆþ¤ì¤ë¤è¤¦¤Ë¤¹¤ë¡£ def RRturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') def LLturn(x): m.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') RRturn¤Çµ¡ÂΤòÃæ¿´¤Ë±¦²óž¡¢LLturn¤Çµ¡ÂΤòÃæ¿´¤Ëº¸²óž¤¹¤ë¡£¾å¤ÈƱÍͤ˴ðËÜŪ¤Ë¤Ïx¤Ë0¤òÂåÆþ¤·É¬Íפ˱þ¤¸¤ÆÂ礤ÊÃͤòÂåÆþ¤¹¤ë¡£ def armup(): l.run_to_abs_pos(position_sp=100,speed_sp=100,stop_action="hold") sleep(0.1) def armdown(): l.run_to_abs_pos(position_sp=-100,speed_sp=100,stop_action="hold") sleep(0.1) armup()¤Ç¥¢¡¼¥à¤ò¾å¤²¡¢armdown()¤Ç²¼¤²¤ë¡£Â礤¤³ÑÅپ夲¤¿¤ê¡¢Â®¤¤¥¹¥Ô¡¼¥É¤Ç¾å¤²¤ë¤Èµå¤¬¿á¤ÃÈô¤ó¤Ç¤¤¤¯¤Î¤Çµ¤¤ò¤Ä¤±¤ë¡£ **¥³¡¼¥¹Ê¬¤± [#hfa5b73e] ¥³¡¼¥¹¤ò²¼¿Þ¤Î¤è¤¦¤Ë¤¤¤¯¤Ä¤«¤Î¥Ö¥í¥Ã¥¯¤Ëʬ¤±¤Æ¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤ò¤¹¤ë¡£ &ref(2019a/Member/hiroe/Mission2/¥³¡¼¥¹¥Ö¥í¥Ã¥¯.jpg,50%,¥³¡¼¥¹¥Ö¥í¥Ã¥¯); **Â裱¥Ö¥í¥Ã¥¯¡ÊÀÖ¡Ë [#aea53e1d] Â裱¥Ö¥í¥Ã¥¯¤Ç¤ÏC¤ÈD¤Ë¸òº¹ÅÀ¤¬¤¢¤ê¡¢¤½¤³¤òľ¿Ê¤¹¤ëɬÍפ¬¤¢¤ë¡£¤½¤³¤Çtyoku´Ø¿ô¤òÄêµÁ¤¹¤ë¡£tyoku´Ø¿ô¤ÏÌÀ¤ë¤µ¤ÎÃͤ¬£±£µ°Ê¾å¡Ê¸òº¹ÅÀ¤ò±Û¤¨¤ë¡Ë¤Þ¤Çľ¿Ê¤ò¤·Â³¤±¤ë´Ø¿ô¤Ç¤¢¤ë¡£ def tyoku(): a=cs.value() while(a<15): run() sleep(0.1) a=cs.value() £±¤Ä¤á¤Î¸òº¹ÅÀ¤Çtyoku´Ø¿ô¤ò»È¤¤¡¢£²¤Ä¤á¤Î¸òº¹ÅÀ¤Ç£±ÉÃsleep¤µ¤»tyoku´Ø¿ô¤ò»È¤¨¤ÐÂ裱¥Ö¥í¥Ã¥¯¤ÏÄ̲á¡Ä¤È¾å¼ê¤¯¤Ï¤¤¤«¤Ê¤¤¡££±¤Ä¤á¤Î¸òº¹ÅÀ¤ò±Û¤·¤¿¸åľ¿Ê¤·¤¹¤®¤Æ¤·¤Þ¤¤¡¢¥«¡¼¥Ö¤Ç¤¢¤ë¤Î¤Ë¸òº¹ÅÀ¤Èǧ¼±¤·¤Æ¤·¤Þ¤¦°Å¤µ¤Î½ê¤Þ¤Ç¿Ê¤ó¤Ç¤·¤Þ¤¤¡¢£²¤Ä¤á¤Î¸òº¹ÅÀ¤Èǧ¼±¤·¤Æ¤·¤Þ¤¦¡£ &ref(2019a/Member/hiroe/Mission2/¤Á¤ç¤¯.jpg,50%,¤Á¤ç¤¯); ¤³¤ì¤òËɤ°¤¿¤á¤Ë¡Ö£±¤Ä¤á¤Î¸òº¹ÅÀ¤òǧ¼±¤·¤Æ¤«¤é¤·¤Ð¤é¤¯¤Ï£²¤Ä¤á¤Î¸òº¹ÅÀ¤Ï¤ÏÍè¤Ê¤¤¡×¤È¤¤¤Ã¤¿É÷¤Ë¤¹¤ëɬÍפ¬¤¢¤ë¡£º£²ó¤Ï¡Ö£´£°²ó°Ê¾å¥ë¡¼¥×¤·¤Ê¤¤¤È¼¡¤Î¸òº¹ÅÀ¤ÏÍè¤Ê¤¤¡×¤È¤·¤¿¡£¤³¤¦¤¹¤ë¤³¤È¤ÇËÜÍè¸òº¹ÅÀ¤Èǧ¼±¤¹¤ë°Å¤µ¤Ç¤¢¤Ã¤Æ¤â±¦²óž¤·Â³¤±¥«¡¼¥Ö¤Î¥é¥¤¥ó¥È¥ì¡¼¥¹¤¬½ÐÍè¤ë¡£ c=0 #¸òº¹ÅÀ¤Î¿ô d=40 #¥ë¡¼¥×¤·¤¿¿ô¡Ê£±¤Ä¤á¤Î¸òº¹ÅÀ¤«¤é¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤¿¤¤¤Î¤Ç»Ï¤á¤Ï£´£°¤«¤é¥¹¥¿¡¼¥È¡Ë while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): #±¦²óž Rturn(0) elif start>=65: #º¸²óž Lturn(0) elif start<15 and d>40: #¸òº¹ÅÀ¡¡£´£°²ó¥ë¡¼¥×¤¹¤ë¤Þ¤Ç¤Ï¸òº¹ÅÀ¤Èǧ¼±¤µ¤»¤Ê¤¤ c=c+1 if c==1: #£±¤Ä¤á¤Î¸òº¹ÅÀ d=0 #£°²óÌܤȤ·¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤ë if c==2: #£²¤Ä¤á¤Î¸òº¹ÅÀ sleep(1) #£±ÉôÖÄä»ß tyoku() else: #ľ¿Ê run() sleep(0.1) ¤³¤ì¤ÇÂ裱¥Ö¥í¥Ã¥¯¤òÄ̲á½ÐÍè¤ë¡£ **Â裲¥Ö¥í¥Ã¥¯¡ÊÜô¡Ë [#y0334ce2] E,F¤Î90¡ë²óž¤Ç¡¢±¦¥¿¥¤¥ä¤ò¼´¤È¤¹¤ë±¦²óž¤ò¤¹¤ë¤È¾å¼ê¤¯¤¤¤«¤Ê¤¤¡£²¼¿Þ¤Î¤è¤¦¤Ë²óž¤·¤Æ¤¤¤ëÅÓÃæ¤Ë¥é¥¤¥ó¤òÈô¤Ó±Û¤¨¤Æ¤·¤Þ¤¦¤«¤é¤À¡£ &ref(2019a/Member/hiroe/Mission2/Èô¤Ó±Û¤¨¤ë.jpg,50%,Èô¤Ó±Û¤¨¤ë); &ref(2019a/Member/hiroe/Mission2/Èô¤Ó±Û¤¨¤Ê¤¤.jpg,50%,Èô¤Ó±Û¤¨¤Ê¤¤); ¤è¤Ã¤Æ¡¢µ¡ÂΤòÃæ¿´¤È¤·¤¿²óž¤Ë¤¹¤ëɬÍפ¬¤¢¤ë¡£¿·¤·¤¤´Ø¿ôRmaga¤òÄêµÁ¤¹¤ë¡£ def Rmaga(): a=cs.value() while(a<50): sleep(0.1) RRturn(0) sleep(0.1) run() a=cs.value() ¤³¤Î´Ø¿ô¤¬¤·¤Æ¤¤¤ë»ö¤Ïtyoku´Ø¿ô¤È¤Û¤È¤ó¤ÉƱ¤¸¤Ç¤¢¤ë¡£Rmaga¤Ç¤Ïľ¿Ê¤¹¤ë¤Û¤É¤ÎÌÀ¤ë¤µ¤Ë¤Ê¤ë¤Þ¤Çµ¡ÂΤò±¦²óž¤µ¤»¤Æ¤¤¤ë¡£ E,F°Ê³°¤ÎÆ»¤Î¤ê¤Ç¤·¤Æ¤¤¤ë¤³¤È¤ÏÂè1¥Ö¥í¥Ã¥¯¤ÈƱ¤¸¤Ç¤¢¤ë¤Î¤ÇÀè¤Û¤É¤Î¥³¡¼¥É¤Ë3¡¤4ÈÖÌܤθòº¹ÅÀ¤Ç¤ÏRmaga¤ò¤¹¤ë¤È¤¤¤¦¥³¡¼¥É¤ò²Ã¤¨¤ë¡£¤µ¤é¤Ë4¤Ä¤á¤Î¸òº¹ÅÀ¤Ç¤³¤ÎWhileʸ¤òÈ´¤±¤ë¡£ while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): #±¦²óž Rturn(0) elif start>=65: #º¸²óž Lturn(0) elif start<15 and d>40: #¸òº¹ÅÀ¡¡£´£°²ó¥ë¡¼¥×¤¹¤ë¤Þ¤Ç¤Ï¸òº¹ÅÀ¤Èǧ¼±¤µ¤»¤Ê¤¤ c=c+1 if c==1: #£±¤Ä¤á¤Î¸òº¹ÅÀ d=0 #£°²óÌܤȤ·¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤ë tyoku() if c==2: #£²¤Ä¤á¤Î¸òº¹ÅÀ sleep(1) #£±ÉôÖÄä»ß tyoku() if c==3 or c==4: sleep(1) Rmaga() if c==4: #4¤Ä¤á¤Î¸òº¹ÅÀ¤Ç¤³¤ÎWhileʸ¤òÈ´¤±¤ë break else: #ľ¿Ê run() sleep(0.1) **Â裳¥Ö¥í¥Ã¥¯¡Ê²«¡Ë [#fb2914a8] ¸òº¹ÅÀG¤ÏRmaga´Ø¿ô¡¢H,I¤Ïtyoku´Ø¿ô¤ÇÄ̲á¤Ç¤¤ë¡£ ¸òº¹ÅÀJ¤«¤éK¤Ë¹Ô¤¯¤Þ¤Ç¤Ëµ¡ÂΤòľÀþKL¤ËÂФ·¤Æ¿âľ¤Ë¤·¤¿¤¤¡£Á°²ó¤Î²ÝÂ꣱¤Î¼Â¸³¤«¤éµ¡ÂÎÃæ¿´¤Ë360¡ë²óž¤¹¤ë¤Ë¤Ï744¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¤Èʬ¤«¤Ã¤Æ¤¤¤ë¡£¤Ä¤Þ¤ê10¡ë²óž¤¹¤ë¤Ë¤ÏÌó20¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¡£²¼¿Þ¤è¤ê²óž¤µ¤»¤ë¤Ù¤³ÑÅÙ¤ÏÌó60¡ë¤Èʬ¤«¤ë¤Î¤Ç¤À¤¤¤¿¤¤120¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¤È¸«Åö¤¬Î©¤Ä¡£²¿²ó¤â·«¤êÊÖ¤·»î¤·¤¿¤È¤³¤í¡¢160¤ÈÆþÎϤ¹¤ë¤È¾å¼ê¤¯¤¤¤¯¤Èʬ¤«¤Ã¤¿¡£¤è¤Ã¤Æ¼¡¤Î¥³¡¼¥É¤ò²Ã¤¨¤ë¡£ &ref(2019a/Member/hiroe/Mission2/60.jpg,25%,60); for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() Â裳¥Ö¥í¥Ã¥¯¤Î±ß¤ÏÂ裱¥Ö¥í¥Ã¥¯¤Î¥«¡¼¥Ö¤ËÈæ¤Ù¶ÊΨ¤¬Â礤¯Â裱¥Ö¥í¥Ã¥¯¤Î»þ¤è¤ê¤â°ìÅÙ¤ËÂ礤¯¥«¡¼¥Ö¤µ¤»¤ëɬÍפ¬¤¢¤ë¡£¤è¤Ã¤ÆÂ裱¥Ö¥í¥Ã¥¯¤Ç¤ÏLturn(0)¤À¤Ã¤¿½ê¤òÂ裳¥Ö¥í¥Ã¥¯¤ÏLturn(70)¤Ë¤·¤Æ¤¤¤ë¡£¤À¤«¤é¡¢°ìÅÙWhileʸ¤òÈ´¤±¤ëɬÍפ¬¤¢¤Ã¤¿¤ó¤Ç¤¹¤Í¡£ Â裳¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ start=cs.value() while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(70) elif start<15: c=c+1 if c==1: sleep(1) #G¤Ç°ì»þÄä»ß Rmaga() if c==2 or c==3: tyoku() if c==4: for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() break else: run() sleep(0.1) **Â裴¥Ö¥í¥Ã¥¯¡ÊÎÐ¡Ë [#i9183acc] Â裴¥Ö¥í¥Ã¥¯¤Ç¤Ïµå¤ò½¦¤¦Æ°ºî¤¬Æþ¤ë¡£ -µ¡ÂΤòµå¤ÎÊý¤Ë¸þ¤¯¤è¤¦¤Ë90¡ë²óž¡£¡Ä¡ -¾¯¤·¥Ð¥Ã¥¯¤¹¤ë¡£¡Ê¥¢¡¼¥à¤¬Ä¹¤¯¤³¤Î¤Þ¤Þ¥¢¡¼¥à¤ò²¼¤í¤¹¤Èµå¤Ë¤Ö¤Ä¤«¤Ã¤Æ¤·¤Þ¤¦¤¿¤á¡£¡Ë¡Ä¢ -¥¢¡¼¥à¤ò²¼¤²¤ë¡£¡Ä£ -L¤Þ¤Ç¿Ê¤à¡£¡ÊÌÀ¤ë¤¯¤Ê¤ë¤Þ¤Ç¿Ê¤à¡Ë¡Ä¤ -¥¢¡¼¥à¤ò¾å¤²¤ë¡£¡Ä¥ -µ¡ÂΤò180¡ë²óž¡Ä¦ ¤³¤Î6¤Ä¤Îưºî¤Çµå¤ò½¦¤¤Â裴¥Ö¥í¥Ã¥¯¤ÏÄ̲á¤Ç¤¤ë¡£¥Ý¥¤¥ó¥È¤Ï¤³¤Î°ìÏ¢¤Îưºî¤Ï¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ç¹Ô¤ï¤ì¤Æ¤¤¤ë¤³¤È¤Ç¤¢¤ë¡£¡Ê¥é¥¤¥ó¥È¥ì¡¼¥¹¤È¤¤¤¦ËÜÍè¤Î²ÝÂ꤬ãÀ®¤Ç¤¤Æ¤ª¤é¤º¡¢È¿¾ÊÅÀ¤Ç¤¢¤ë¡£¡Ë Â裴¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ for n_1 in range(18): #¡ sleep(0.1) LLturn(0) sleep(0.1) run() for n_2 in range(10): #¢ back() sleep(0.1) armdown() #£ while True: #¤ start=cs.value() if start>80: break run() sleep(0.1) armup() #¥ for n_3 in range(36): #¦ sleep(0.1) RRturn(0) sleep(0.1) **Â裵¥Ö¥í¥Ã¥¯¡ÊÀÄ¡Ë [#m5feba9b] Â裴¥Ö¥í¥Ã¥¯¤Î¥Ý¥¤¥ó¥È¤È¤·¤Æ½Ò¤Ù¤¿¤è¤¦¤ËÂ裴¥Ö¥í¥Ã¥¯¤Îưºî¤ÏÁ´¤Æ¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ç¹Ô¤Ã¤Æ¤¤¤ë¡£¤Ä¤Þ¤êÂ裴¥Ö¥í¥Ã¥¯¤Îưºî¤Î½ª¤ï¤ê¤Ï²¼¿Þ¤Î¤è¤¦¤Ë¤Ê¤ë¡£ &ref(2019a/Member/hiroe/Mission2/ÃÏÅÀL.jpg,40%,60); ÍýÏÀ¾åµ¡ÂΤÏľÀþKL¤ËÂФ·¤ÆÊ¿¹Ô¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Ï¤º¤Ç¤¢¤ë¡£¤·¤«¤·¼ÂºÝ¤Ë¤Ï¾¯¤·¤Î¸íº¹¤¬½Å¤Ê¤ê¾å¿Þ¤Î¤è¤¦¤Ë±¦Â¦¤Ë·¹¤¤¤¿¤è¤¦¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£º£²ó¤ÏµÕ¤Ë¤³¤Î·¹¤¤òÍøÍѤ·¤ÆÂ裵¥Ö¥í¥Ã¥¯¤ò¹¶Î¬¤¹¤ë¡£ Â裵¥Ö¥í¥Ã¥¯¤Î³«»Ï»þ¤Ç¤Ï¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ë¤¢¤ê¡¢µ¡ÂΤ¬±¦Â¦¤Ë·¹¤¤¤Æ¤¤¤ë¤¿¤átyoku´Ø¿ô¤òÍѤ¤¤ë¤È¡¢µ¡ÂΤ¬¥é¥¤¥ó¤Î±¦Â¦¤Ë½Ð¤ë¡£¤³¤¦¤¹¤ì¤Ð¡¢º£¤Þ¤Ç¤Î¥é¥¤¥ó¥È¥ì¡¼¥¹¤Î»ÅÊý¤Ç¿Ê¤à¤³¤È¤¬¤Ç¤¤ë¡£¸òº¹ÅÀ¤Èǧ¼±¤¹¤ë¤Î¤ÏÂ裵¥Ö¥í¥Ã¥¯¤Î³«»Ï»þ¡¢ÃÏÅÀK¡¢¤½¤·¤Æ¥´¡¼¥ë¤ÎÃÏÅÀM¤Ç¤¢¤ë¡£¤è¤Ã¤Æ°ì¤ÄÌÜ¤ÈÆó¤ÄÌܤθòº¹ÅÀ¤Ç¤Ïtyoku´Ø¿ô¤ò»È¤¤¡¢ºÇ¸å¤Î¸òº¹ÅÀ¤Ç¤¢¤ë¥´¡¼¥ë¤Ç¤Ïµ¡ÂΤòÄä»ß¤·¥¢¡¼¥à¤ò²¼¤í¤»¤ÐÂ裵¥Ö¥í¥Ã¥¯¤òÄ̲ᡢ¤Ä¤Þ¤ê²ÝÂꣲãÀ®¤Ç¤¢¤ë¡£ &ref(2019a/Member/hiroe/Mission2/¥é¥¹¥È.jpg,40%,¥é¥¹¥È); Â裵¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(0) elif start<15: c=c+1 if c==1 or c==2: sleep(0.1) tyoku() if c==3: sleep(1) break else: run() sleep(0.1) armdown() **¼ÂÁõ¥×¥í¥°¥é¥à [#m31d2a1c] ºÇ¸å¤Ë²ÝÂꣲ¤òãÀ®¤¹¤ë¤¿¤á¤Ë¤³¤ì¤Þ¤ÇºÜ¤»¤Æ¤¤¿¥×¥í¥°¥é¥à¤ò¤Þ¤È¤á¤Æ¡¢¼ÂÁõ¥×¥í¥°¥é¥à¤È¤·¤Æ¤³¤³¤ËºÜ¤»¤ë¡£ #!/usr/bin/env python3 from ev3dev.ev3 import * from time import * m = LargeMotor('outA') n = LargeMotor('outB') l = MediumMotor('outC') cs = ColorSensor('in2') cs.mode = 'COL-REFLECT' def run(): m.run_timed(time_sp=100, speed_sp=150) n.run_timed(time_sp=100, speed_sp=150) def back(): m.run_timed(time_sp=100, speed_sp=-150) n.run_timed(time_sp=100, speed_sp=-150) def Rturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') def Lturn(x): m.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') def RRturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') def LLturn(x): m.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') def armup(): l.run_to_abs_pos(position_sp=100,speed_sp=100,stop_action="hold") sleep(0.1) def armdown(): l.run_to_abs_pos(position_sp=-100,speed_sp=100,stop_action="hold") sleep(0.1) def tyoku(): a=cs.value() while(a<15): run() sleep(0.1) a=cs.value() def Rmaga(): a=cs.value() while(a<50): sleep(0.1) RRturn(0) sleep(0.1) run() a=cs.value() c=0 d=0 while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): Rturn(0) elif start>=65: Lturn(0) elif start<15 and d>40: c=c+1 if c==1: d=0 tyoku() if c==2: sleep(1) tyoku() if c==3 or c==4: sleep(1) Rmaga() if c==4: break else: run() sleep(0.1) c=0 start=cs.value() while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(70) elif start<15: c=c+1 if c==1: sleep(1) Rmaga() if c==2 or c==3: tyoku() if c==4: for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() break else: run() sleep(0.1) for n_1 in range(18): sleep(0.1) LLturn(0) sleep(0.1) run() for n_2 in range(10): back() sleep(0.1) armdown() while True: start=cs.value() if start>80: break run() sleep(0.1) armup() for n_3 in range(36): sleep(0.1) RRturn(0) sleep(0.1) c=0 while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(0) elif start<15: c=c+1 if c==1 or c==2: sleep(0.1) tyoku() if c==3: sleep(1) break else: run() sleep(0.1) armdown() *È¿¾Ê [#t1e44ef7] -º£²ó¤Ï¥³¡¼¥¹¤ò¥Ö¥í¥Ã¥¯¤Çʬ¤±¤ë¤³¤È¤Ë¤è¤ê¥Ö¥í¥Ã¥¯¤Ç¤ÎÆñ½ê¤¬¸«¤¨¤ä¤¹¤¯¤Ê¤ê²ÝÂ깶ά¤Î¤á¤É¤âΩ¤Æ¤ä¤¹¤¯¤¹¤ë¤³¤È¤¬¤Ç¤¤¿¡£Á´¤Æ¤Î¥Ö¥í¥Ã¥¯¤Ç»×¤Ã¤¿Ä̤ê¤Îưºî¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤¿¡£ -¥Ö¥í¥Ã¥¯¤Ëʬ¤±¤ë¤³¤È¤ÇÎɤ¤ÅÀ¤â¤¢¤Ã¤¿¤¬°¤¤ÅÀ¤â¤¢¤Ã¤¿¡£¥Ö¥í¥Ã¥¯Æâ¤Ç¤Îưºî¤Ï¤Ç¤¤¿¤¬¡¢Â裲¥Ö¥í¥Ã¥¯¤«¤éÂ裳¥Ö¥í¥Ã¥¯¤Ø°Ü¹Ô¤¹¤ë»þ¡¢Â裲¥Ö¥í¥Ã¥¯¤Î½ª¤ï¤ê»þ¤Î°ÌÃ֤Υº¥ì¤òÂ裳¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï²ÃÌ£¤Ç¤¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢¥º¥ì¤Æ¤·¤Þ¤¤Àµ¤·¤¯Â裳¥Ö¥í¥Ã¥¯¤¬Æ°¤«¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£¾å¤Î¼Â¹Ô¥×¥í¥°¥é¥à¤Ç¤ÏÂ裲¥Ö¥í¥Ã¥¯¤Î½ª¤ï¤ê»þ¤Ë¿Í¤Î¼ê¤Ç¾¯¤·°ÌÃÖ¤òÀµ¤·¤¯¥º¥é¤·¤Æ¤¢¤²¤Ê¤¤¤È¤¤¤±¤Ê¤¤¡£¤½¤Î°ÌÃ֤Τº¤ì¤ò½¤Àµ¤¹¤ë¥³¡¼¥É¤òÉÕ¤±²Ã¤¨¤¿¤«¤Ã¤¿¤¬»þ´Ö¤¬Ìµ¤¯´Ö¤Ë¹ç¤ï¤Ê¤«¤Ã¤¿¡£¥Ö¥í¥Ã¥¯¤´¤È¤Ëʬ¤±¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢¥Ö¥í¥Ã¥¯Æâ¤Îưºî¤òãÀ®¤¹¤ë¤³¤È¤ËÀº°ìÇդˤʤäƤ·¤Þ¤¤¡¢¥Ö¥í¥Ã¥¯´Ö¤Î°Ü¹Ô»þ¤Ë¤Ä¤¤¤Æ¤Î¹Í褬·ç¤±¤Æ¤·¤Þ¤Ã¤¿¡£¤³¤ì¤ò²þÁ±¤¹¤ë°Ù¤Ëº£¸å¤Ï¡¢¤¢¤ë¥Ö¥í¥Ã¥¯¤¬Ä̲á¤Ç¤¤¿¤é¤½¤Î°ÌÃÖ¤òµÏ¿¤·¤Æ¤ª¤¡¢¤½¤Î°ÌÃÖ¤«¤é¼¡¤Î¥Ö¥í¥Ã¥¯¤òư¤«¤¹¥×¥í¥°¥é¥à¤ò¹Í¤¨¤ë¤è¤¦¤Ë¤¹¤ë¡£ -Â裴¥Ö¥í¥Ã¥¯¤Ê¤É¡¢¥³¡¼¥¹¤¢¤ê¤¤Î¥×¥í¥°¥é¥à¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤ÈÆÍÑÀ¤¬Ä㤯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£¸¶°ø¤Î°ì¤Ä¤Ëµå¤ò½¦¤¦¥¢¡¼¥à¤¬¾¯¤·¥º¥ì¤ë¤È¥¢¡¼¥à¤Î·ä´Ö¤Ëµå¤¬Æþ¤é¤º½¦¤¨¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¡¢¤½¤ÎÄ´À°¤ò¥é¥¤¥ó¥È¥ì¡¼¥¹¤Ç¤Ï¤Ê¤¯Ä¾ÀܳÑÅÙ¤òÁàºî¤¹¤ë¤·¤«Ìµ¤¯¤Ê¤Ã¤¿¤È¤¤¤¦¤Î¤¬¤¢¤ë¡£¥¢¡¼¥à¤Î·Á¤ò¤µ¤é¤Ë¹¤²¤¿¤ê¡¢Â¾¤Î¥°¥ë¡¼¥×¤¬¤·¤Æ¤¤¤¿¤è¤¦¤Ëµå¤Ë¤«¤Ö¤»¤ë¤è¤¦¤Ë¥¢¡¼¥à¤ò²¼¤í¤·µå¤ò»ý¤Á¾å¤²¤º¤Ë±¿¤Ö¤Ê¤É¤Î¹©Éפò¤·¤Æµå¤ò½¦¤¦¤È¸À¤¦Æ°ºî¤ÎµöÍÆÈϰϤò¹¤²¤ë¤Ù¤¤À¤Ã¤¿¡£ º£Æü¤ÎˬÌä¼Ô¿ô&counter(today);¿Í ºòÆü¤ÎˬÌä¼Ô¿ô&counter(yesterday);¿Í ¹ç·×ˬÌä¼Ô¿ô&counter(all);¿Í -´ðËÜŪ¤Ê´Ø¿ô¤òÄêµÁ¤¹¤ë¡£ def run(): m.run_timed(time_sp=100, speed_sp=150) n.run_timed(time_sp=100, speed_sp=150) def back(): m.run_timed(time_sp=100, speed_sp=-150) n.run_timed(time_sp=100, speed_sp=-150) Á°²ó¤Î¡Öµ¡ÂΤòư¤«¤¹¥¹¥Ô¡¼¥É¤¬Â®¤¹¤®¤ë¡Êspeed_sp=500¡Ë¤Èưºî¤¬Á´¤¯°ÂÄꤷ¤Ê¤¤¡×¤È¤¤¤¦È¿¾Ê¤â³è¤«¤·¡¢º£²ó¤Ï¥¹¥Ô¡¼¥É¤ò150¤ÇÅý°ì¤·¤¿¡£ def Rturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') def Lturn(x): m.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') Lturn¤Ç±¦¥¿¥¤¥ä¤ò¼´¤Ëº¸²óž¡¢Rturn¤Çº¸¥¿¥¤¥ä¤ò¼´¤Ë±¦²óž¤¹¤ë¡£´ðËÜŪ¤Ë¤Ï£ø¤Ë£°¤òÂåÆþ¤·¾¯¤·¤º¤Ä²óž¤¹¤ë¤è¤¦¤Ë¤¹¤ë¤¬¡¢°ìÅ٤ˤ¿¤¯¤µ¤ó²óž¤µ¤»¤¿¤¤¤È¤¤Ï£ø¤ËÂ礤ÊÃͤòÆþ¤ì¤ë¤è¤¦¤Ë¤¹¤ë¡£ def RRturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') def LLturn(x): m.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') RRturn¤Çµ¡ÂΤòÃæ¿´¤Ë±¦²óž¡¢LLturn¤Çµ¡ÂΤòÃæ¿´¤Ëº¸²óž¤¹¤ë¡£¾å¤ÈƱÍͤ˴ðËÜŪ¤Ë¤Ïx¤Ë0¤òÂåÆþ¤·É¬Íפ˱þ¤¸¤ÆÂ礤ÊÃͤòÂåÆþ¤¹¤ë¡£ def armup(): l.run_to_abs_pos(position_sp=100,speed_sp=100,stop_action="hold") sleep(0.1) def armdown(): l.run_to_abs_pos(position_sp=-100,speed_sp=100,stop_action="hold") sleep(0.1) armup()¤Ç¥¢¡¼¥à¤ò¾å¤²¡¢armdown()¤Ç²¼¤²¤ë¡£Â礤¤³ÑÅپ夲¤¿¤ê¡¢Â®¤¤¥¹¥Ô¡¼¥É¤Ç¾å¤²¤ë¤Èµå¤¬¿á¤ÃÈô¤ó¤Ç¤¤¤¯¤Î¤Çµ¤¤ò¤Ä¤±¤ë¡£ **¥³¡¼¥¹Ê¬¤± [#hfa5b73e] ¥³¡¼¥¹¤ò²¼¿Þ¤Î¤è¤¦¤Ë¤¤¤¯¤Ä¤«¤Î¥Ö¥í¥Ã¥¯¤Ëʬ¤±¤Æ¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤ò¤¹¤ë¡£ &ref(2019a/Member/hiroe/Mission2/¥³¡¼¥¹¥Ö¥í¥Ã¥¯.jpg,50%,¥³¡¼¥¹¥Ö¥í¥Ã¥¯); **Â裱¥Ö¥í¥Ã¥¯¡ÊÀÖ¡Ë [#aea53e1d] Â裱¥Ö¥í¥Ã¥¯¤Ç¤ÏC¤ÈD¤Ë¸òº¹ÅÀ¤¬¤¢¤ê¡¢¤½¤³¤òľ¿Ê¤¹¤ëɬÍפ¬¤¢¤ë¡£¤½¤³¤Çtyoku´Ø¿ô¤òÄêµÁ¤¹¤ë¡£tyoku´Ø¿ô¤ÏÌÀ¤ë¤µ¤ÎÃͤ¬£±£µ°Ê¾å¡Ê¸òº¹ÅÀ¤ò±Û¤¨¤ë¡Ë¤Þ¤Çľ¿Ê¤ò¤·Â³¤±¤ë´Ø¿ô¤Ç¤¢¤ë¡£ def tyoku(): a=cs.value() while(a<15): run() sleep(0.1) a=cs.value() £±¤Ä¤á¤Î¸òº¹ÅÀ¤Çtyoku´Ø¿ô¤ò»È¤¤¡¢£²¤Ä¤á¤Î¸òº¹ÅÀ¤Ç£±ÉÃsleep¤µ¤»tyoku´Ø¿ô¤ò»È¤¨¤ÐÂ裱¥Ö¥í¥Ã¥¯¤ÏÄ̲á¡Ä¤È¾å¼ê¤¯¤Ï¤¤¤«¤Ê¤¤¡££±¤Ä¤á¤Î¸òº¹ÅÀ¤ò±Û¤·¤¿¸åľ¿Ê¤·¤¹¤®¤Æ¤·¤Þ¤¤¡¢¥«¡¼¥Ö¤Ç¤¢¤ë¤Î¤Ë¸òº¹ÅÀ¤Èǧ¼±¤·¤Æ¤·¤Þ¤¦°Å¤µ¤Î½ê¤Þ¤Ç¿Ê¤ó¤Ç¤·¤Þ¤¤¡¢£²¤Ä¤á¤Î¸òº¹ÅÀ¤Èǧ¼±¤·¤Æ¤·¤Þ¤¦¡£ &ref(2019a/Member/hiroe/Mission2/¤Á¤ç¤¯.jpg,50%,¤Á¤ç¤¯); ¤³¤ì¤òËɤ°¤¿¤á¤Ë¡Ö£±¤Ä¤á¤Î¸òº¹ÅÀ¤òǧ¼±¤·¤Æ¤«¤é¤·¤Ð¤é¤¯¤Ï£²¤Ä¤á¤Î¸òº¹ÅÀ¤Ï¤ÏÍè¤Ê¤¤¡×¤È¤¤¤Ã¤¿É÷¤Ë¤¹¤ëɬÍפ¬¤¢¤ë¡£º£²ó¤Ï¡Ö£´£°²ó°Ê¾å¥ë¡¼¥×¤·¤Ê¤¤¤È¼¡¤Î¸òº¹ÅÀ¤ÏÍè¤Ê¤¤¡×¤È¤·¤¿¡£¤³¤¦¤¹¤ë¤³¤È¤ÇËÜÍè¸òº¹ÅÀ¤Èǧ¼±¤¹¤ë°Å¤µ¤Ç¤¢¤Ã¤Æ¤â±¦²óž¤·Â³¤±¥«¡¼¥Ö¤Î¥é¥¤¥ó¥È¥ì¡¼¥¹¤¬½ÐÍè¤ë¡£ c=0 #¸òº¹ÅÀ¤Î¿ô d=40 #¥ë¡¼¥×¤·¤¿¿ô¡Ê£±¤Ä¤á¤Î¸òº¹ÅÀ¤«¤é¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤¿¤¤¤Î¤Ç»Ï¤á¤Ï£´£°¤«¤é¥¹¥¿¡¼¥È¡Ë while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): #±¦²óž Rturn(0) elif start>=65: #º¸²óž Lturn(0) elif start<15 and d>40: #¸òº¹ÅÀ¡¡£´£°²ó¥ë¡¼¥×¤¹¤ë¤Þ¤Ç¤Ï¸òº¹ÅÀ¤Èǧ¼±¤µ¤»¤Ê¤¤ c=c+1 if c==1: #£±¤Ä¤á¤Î¸òº¹ÅÀ d=0 #£°²óÌܤȤ·¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤ë if c==2: #£²¤Ä¤á¤Î¸òº¹ÅÀ sleep(1) #£±ÉôÖÄä»ß tyoku() else: #ľ¿Ê run() sleep(0.1) ¤³¤ì¤ÇÂ裱¥Ö¥í¥Ã¥¯¤òÄ̲á½ÐÍè¤ë¡£ **Â裲¥Ö¥í¥Ã¥¯¡ÊÜô¡Ë [#y0334ce2] E,F¤Î90¡ë²óž¤Ç¡¢±¦¥¿¥¤¥ä¤ò¼´¤È¤¹¤ë±¦²óž¤ò¤¹¤ë¤È¾å¼ê¤¯¤¤¤«¤Ê¤¤¡£²¼¿Þ¤Î¤è¤¦¤Ë²óž¤·¤Æ¤¤¤ëÅÓÃæ¤Ë¥é¥¤¥ó¤òÈô¤Ó±Û¤¨¤Æ¤·¤Þ¤¦¤«¤é¤À¡£ &ref(2019a/Member/hiroe/Mission2/Èô¤Ó±Û¤¨¤ë.jpg,50%,Èô¤Ó±Û¤¨¤ë); &ref(2019a/Member/hiroe/Mission2/Èô¤Ó±Û¤¨¤Ê¤¤.jpg,50%,Èô¤Ó±Û¤¨¤Ê¤¤); ¤è¤Ã¤Æ¡¢µ¡ÂΤòÃæ¿´¤È¤·¤¿²óž¤Ë¤¹¤ëɬÍפ¬¤¢¤ë¡£¿·¤·¤¤´Ø¿ôRmaga¤òÄêµÁ¤¹¤ë¡£ def Rmaga(): a=cs.value() while(a<50): sleep(0.1) RRturn(0) sleep(0.1) run() a=cs.value() ¤³¤Î´Ø¿ô¤¬¤·¤Æ¤¤¤ë»ö¤Ïtyoku´Ø¿ô¤È¤Û¤È¤ó¤ÉƱ¤¸¤Ç¤¢¤ë¡£Rmaga¤Ç¤Ïľ¿Ê¤¹¤ë¤Û¤É¤ÎÌÀ¤ë¤µ¤Ë¤Ê¤ë¤Þ¤Çµ¡ÂΤò±¦²óž¤µ¤»¤Æ¤¤¤ë¡£ E,F°Ê³°¤ÎÆ»¤Î¤ê¤Ç¤·¤Æ¤¤¤ë¤³¤È¤ÏÂè1¥Ö¥í¥Ã¥¯¤ÈƱ¤¸¤Ç¤¢¤ë¤Î¤ÇÀè¤Û¤É¤Î¥³¡¼¥É¤Ë3¡¤4ÈÖÌܤθòº¹ÅÀ¤Ç¤ÏRmaga¤ò¤¹¤ë¤È¤¤¤¦¥³¡¼¥É¤ò²Ã¤¨¤ë¡£¤µ¤é¤Ë4¤Ä¤á¤Î¸òº¹ÅÀ¤Ç¤³¤ÎWhileʸ¤òÈ´¤±¤ë¡£ while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): #±¦²óž Rturn(0) elif start>=65: #º¸²óž Lturn(0) elif start<15 and d>40: #¸òº¹ÅÀ¡¡£´£°²ó¥ë¡¼¥×¤¹¤ë¤Þ¤Ç¤Ï¸òº¹ÅÀ¤Èǧ¼±¤µ¤»¤Ê¤¤ c=c+1 if c==1: #£±¤Ä¤á¤Î¸òº¹ÅÀ d=0 #£°²óÌܤȤ·¥ë¡¼¥×¤·¤¿²ó¿ô¤ò¿ô¤¨¤ë tyoku() if c==2: #£²¤Ä¤á¤Î¸òº¹ÅÀ sleep(1) #£±ÉôÖÄä»ß tyoku() if c==3 or c==4: sleep(1) Rmaga() if c==4: #4¤Ä¤á¤Î¸òº¹ÅÀ¤Ç¤³¤ÎWhileʸ¤òÈ´¤±¤ë break else: #ľ¿Ê run() sleep(0.1) **Â裳¥Ö¥í¥Ã¥¯¡Ê²«¡Ë [#fb2914a8] ¸òº¹ÅÀG¤ÏRmaga´Ø¿ô¡¢H,I¤Ïtyoku´Ø¿ô¤ÇÄ̲á¤Ç¤¤ë¡£ ¸òº¹ÅÀJ¤«¤éK¤Ë¹Ô¤¯¤Þ¤Ç¤Ëµ¡ÂΤòľÀþKL¤ËÂФ·¤Æ¿âľ¤Ë¤·¤¿¤¤¡£Á°²ó¤Î²ÝÂ꣱¤Î¼Â¸³¤«¤éµ¡ÂÎÃæ¿´¤Ë360¡ë²óž¤¹¤ë¤Ë¤Ï744¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¤Èʬ¤«¤Ã¤Æ¤¤¤ë¡£¤Ä¤Þ¤ê10¡ë²óž¤¹¤ë¤Ë¤ÏÌó20¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¡£²¼¿Þ¤è¤ê²óž¤µ¤»¤ë¤Ù¤³ÑÅÙ¤ÏÌó60¡ë¤Èʬ¤«¤ë¤Î¤Ç¤À¤¤¤¿¤¤120¤ÈÆþÎϤ¹¤ì¤Ð¤è¤¤¤È¸«Åö¤¬Î©¤Ä¡£²¿²ó¤â·«¤êÊÖ¤·»î¤·¤¿¤È¤³¤í¡¢160¤ÈÆþÎϤ¹¤ë¤È¾å¼ê¤¯¤¤¤¯¤Èʬ¤«¤Ã¤¿¡£¤è¤Ã¤Æ¼¡¤Î¥³¡¼¥É¤ò²Ã¤¨¤ë¡£ &ref(2019a/Member/hiroe/Mission2/60.jpg,25%,60); for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() Â裳¥Ö¥í¥Ã¥¯¤Î±ß¤ÏÂ裱¥Ö¥í¥Ã¥¯¤Î¥«¡¼¥Ö¤ËÈæ¤Ù¶ÊΨ¤¬Â礤¯Â裱¥Ö¥í¥Ã¥¯¤Î»þ¤è¤ê¤â°ìÅÙ¤ËÂ礤¯¥«¡¼¥Ö¤µ¤»¤ëɬÍפ¬¤¢¤ë¡£¤è¤Ã¤ÆÂ裱¥Ö¥í¥Ã¥¯¤Ç¤ÏLturn(0)¤À¤Ã¤¿½ê¤òÂ裳¥Ö¥í¥Ã¥¯¤ÏLturn(70)¤Ë¤·¤Æ¤¤¤ë¡£¤À¤«¤é¡¢°ìÅÙWhileʸ¤òÈ´¤±¤ëɬÍפ¬¤¢¤Ã¤¿¤ó¤Ç¤¹¤Í¡£ Â裳¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ start=cs.value() while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(70) elif start<15: c=c+1 if c==1: sleep(1) #G¤Ç°ì»þÄä»ß Rmaga() if c==2 or c==3: tyoku() if c==4: for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() break else: run() sleep(0.1) **Â裴¥Ö¥í¥Ã¥¯¡ÊÎÐ¡Ë [#i9183acc] Â裴¥Ö¥í¥Ã¥¯¤Ç¤Ïµå¤ò½¦¤¦Æ°ºî¤¬Æþ¤ë¡£ -µ¡ÂΤòµå¤ÎÊý¤Ë¸þ¤¯¤è¤¦¤Ë90¡ë²óž¡£¡Ä¡ -¾¯¤·¥Ð¥Ã¥¯¤¹¤ë¡£¡Ê¥¢¡¼¥à¤¬Ä¹¤¯¤³¤Î¤Þ¤Þ¥¢¡¼¥à¤ò²¼¤í¤¹¤Èµå¤Ë¤Ö¤Ä¤«¤Ã¤Æ¤·¤Þ¤¦¤¿¤á¡£¡Ë¡Ä¢ -¥¢¡¼¥à¤ò²¼¤²¤ë¡£¡Ä£ -L¤Þ¤Ç¿Ê¤à¡£¡ÊÌÀ¤ë¤¯¤Ê¤ë¤Þ¤Ç¿Ê¤à¡Ë¡Ä¤ -¥¢¡¼¥à¤ò¾å¤²¤ë¡£¡Ä¥ -µ¡ÂΤò180¡ë²óž¡Ä¦ ¤³¤Î6¤Ä¤Îưºî¤Çµå¤ò½¦¤¤Â裴¥Ö¥í¥Ã¥¯¤ÏÄ̲á¤Ç¤¤ë¡£¥Ý¥¤¥ó¥È¤Ï¤³¤Î°ìÏ¢¤Îưºî¤Ï¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ç¹Ô¤ï¤ì¤Æ¤¤¤ë¤³¤È¤Ç¤¢¤ë¡£¡Ê¥é¥¤¥ó¥È¥ì¡¼¥¹¤È¤¤¤¦ËÜÍè¤Î²ÝÂ꤬ãÀ®¤Ç¤¤Æ¤ª¤é¤º¡¢È¿¾ÊÅÀ¤Ç¤¢¤ë¡£¡Ë Â裴¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ for n_1 in range(18): #¡ sleep(0.1) LLturn(0) sleep(0.1) run() for n_2 in range(10): #¢ back() sleep(0.1) armdown() #£ while True: #¤ start=cs.value() if start>80: break run() sleep(0.1) armup() #¥ for n_3 in range(36): #¦ sleep(0.1) RRturn(0) sleep(0.1) **Â裵¥Ö¥í¥Ã¥¯¡ÊÀÄ¡Ë [#m5feba9b] Â裴¥Ö¥í¥Ã¥¯¤Î¥Ý¥¤¥ó¥È¤È¤·¤Æ½Ò¤Ù¤¿¤è¤¦¤ËÂ裴¥Ö¥í¥Ã¥¯¤Îưºî¤ÏÁ´¤Æ¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ç¹Ô¤Ã¤Æ¤¤¤ë¡£¤Ä¤Þ¤êÂ裴¥Ö¥í¥Ã¥¯¤Îưºî¤Î½ª¤ï¤ê¤Ï²¼¿Þ¤Î¤è¤¦¤Ë¤Ê¤ë¡£ &ref(2019a/Member/hiroe/Mission2/ÃÏÅÀL.jpg,40%,60); ÍýÏÀ¾åµ¡ÂΤÏľÀþKL¤ËÂФ·¤ÆÊ¿¹Ô¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Ï¤º¤Ç¤¢¤ë¡£¤·¤«¤·¼ÂºÝ¤Ë¤Ï¾¯¤·¤Î¸íº¹¤¬½Å¤Ê¤ê¾å¿Þ¤Î¤è¤¦¤Ë±¦Â¦¤Ë·¹¤¤¤¿¤è¤¦¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£º£²ó¤ÏµÕ¤Ë¤³¤Î·¹¤¤òÍøÍѤ·¤ÆÂ裵¥Ö¥í¥Ã¥¯¤ò¹¶Î¬¤¹¤ë¡£ Â裵¥Ö¥í¥Ã¥¯¤Î³«»Ï»þ¤Ç¤Ï¥é¥¤¥ó¤Î¤É¿¿¤óÃæ¤Ë¤¢¤ê¡¢µ¡ÂΤ¬±¦Â¦¤Ë·¹¤¤¤Æ¤¤¤ë¤¿¤átyoku´Ø¿ô¤òÍѤ¤¤ë¤È¡¢µ¡ÂΤ¬¥é¥¤¥ó¤Î±¦Â¦¤Ë½Ð¤ë¡£¤³¤¦¤¹¤ì¤Ð¡¢º£¤Þ¤Ç¤Î¥é¥¤¥ó¥È¥ì¡¼¥¹¤Î»ÅÊý¤Ç¿Ê¤à¤³¤È¤¬¤Ç¤¤ë¡£¸òº¹ÅÀ¤Èǧ¼±¤¹¤ë¤Î¤ÏÂ裵¥Ö¥í¥Ã¥¯¤Î³«»Ï»þ¡¢ÃÏÅÀK¡¢¤½¤·¤Æ¥´¡¼¥ë¤ÎÃÏÅÀM¤Ç¤¢¤ë¡£¤è¤Ã¤Æ°ì¤ÄÌÜ¤ÈÆó¤ÄÌܤθòº¹ÅÀ¤Ç¤Ïtyoku´Ø¿ô¤ò»È¤¤¡¢ºÇ¸å¤Î¸òº¹ÅÀ¤Ç¤¢¤ë¥´¡¼¥ë¤Ç¤Ïµ¡ÂΤòÄä»ß¤·¥¢¡¼¥à¤ò²¼¤í¤»¤ÐÂ裵¥Ö¥í¥Ã¥¯¤òÄ̲ᡢ¤Ä¤Þ¤ê²ÝÂꣲãÀ®¤Ç¤¢¤ë¡£ &ref(2019a/Member/hiroe/Mission2/¥é¥¹¥È.jpg,40%,¥é¥¹¥È); Â裵¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤ë¡£ while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(0) elif start<15: c=c+1 if c==1 or c==2: sleep(0.1) tyoku() if c==3: sleep(1) break else: run() sleep(0.1) armdown() **¼ÂÁõ¥×¥í¥°¥é¥à [#m31d2a1c] ºÇ¸å¤Ë²ÝÂꣲ¤òãÀ®¤¹¤ë¤¿¤á¤Ë¤³¤ì¤Þ¤ÇºÜ¤»¤Æ¤¤¿¥×¥í¥°¥é¥à¤ò¤Þ¤È¤á¤Æ¡¢¼ÂÁõ¥×¥í¥°¥é¥à¤È¤·¤Æ¤³¤³¤ËºÜ¤»¤ë¡£ #!/usr/bin/env python3 from ev3dev.ev3 import * from time import * m = LargeMotor('outA') n = LargeMotor('outB') l = MediumMotor('outC') cs = ColorSensor('in2') cs.mode = 'COL-REFLECT' def run(): m.run_timed(time_sp=100, speed_sp=150) n.run_timed(time_sp=100, speed_sp=150) def back(): m.run_timed(time_sp=100, speed_sp=-150) n.run_timed(time_sp=100, speed_sp=-150) def Rturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') def Lturn(x): m.run_to_rel_pos(position_sp=0, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') def RRturn(x): m.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') def LLturn(x): m.run_to_rel_pos(position_sp=-10-x, speed_sp=100, stop_action='brake') n.run_to_rel_pos(position_sp=10+x, speed_sp=100, stop_action='brake') def armup(): l.run_to_abs_pos(position_sp=100,speed_sp=100,stop_action="hold") sleep(0.1) def armdown(): l.run_to_abs_pos(position_sp=-100,speed_sp=100,stop_action="hold") sleep(0.1) def tyoku(): a=cs.value() while(a<15): run() sleep(0.1) a=cs.value() def Rmaga(): a=cs.value() while(a<50): sleep(0.1) RRturn(0) sleep(0.1) run() a=cs.value() c=0 d=0 while True: d=d+1 start=cs.value() if (start>=15 and start<=50) or (start<15 and d<=40): Rturn(0) elif start>=65: Lturn(0) elif start<15 and d>40: c=c+1 if c==1: d=0 tyoku() if c==2: sleep(1) tyoku() if c==3 or c==4: sleep(1) Rmaga() if c==4: break else: run() sleep(0.1) c=0 start=cs.value() while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(70) elif start<15: c=c+1 if c==1: sleep(1) Rmaga() if c==2 or c==3: tyoku() if c==4: for n_1 in range(15): sleep(0.1) RRturn(0) sleep(0.1) run() break else: run() sleep(0.1) for n_1 in range(18): sleep(0.1) LLturn(0) sleep(0.1) run() for n_2 in range(10): back() sleep(0.1) armdown() while True: start=cs.value() if start>80: break run() sleep(0.1) armup() for n_3 in range(36): sleep(0.1) RRturn(0) sleep(0.1) c=0 while True: start=cs.value() if start>=15 and start<=50: Rturn(0) elif start>=65: Lturn(0) elif start<15: c=c+1 if c==1 or c==2: sleep(0.1) tyoku() if c==3: sleep(1) break else: run() sleep(0.1) armdown() *È¿¾Ê [#t1e44ef7] -º£²ó¤Ï¥³¡¼¥¹¤ò¥Ö¥í¥Ã¥¯¤Çʬ¤±¤ë¤³¤È¤Ë¤è¤ê¥Ö¥í¥Ã¥¯¤Ç¤ÎÆñ½ê¤¬¸«¤¨¤ä¤¹¤¯¤Ê¤ê²ÝÂ깶ά¤Î¤á¤É¤âΩ¤Æ¤ä¤¹¤¯¤¹¤ë¤³¤È¤¬¤Ç¤¤¿¡£Á´¤Æ¤Î¥Ö¥í¥Ã¥¯¤Ç»×¤Ã¤¿Ä̤ê¤Îưºî¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤¿¡£ -¥Ö¥í¥Ã¥¯¤Ëʬ¤±¤ë¤³¤È¤ÇÎɤ¤ÅÀ¤â¤¢¤Ã¤¿¤¬°¤¤ÅÀ¤â¤¢¤Ã¤¿¡£¥Ö¥í¥Ã¥¯Æâ¤Ç¤Îưºî¤Ï¤Ç¤¤¿¤¬¡¢Â裲¥Ö¥í¥Ã¥¯¤«¤éÂ裳¥Ö¥í¥Ã¥¯¤Ø°Ü¹Ô¤¹¤ë»þ¡¢Â裲¥Ö¥í¥Ã¥¯¤Î½ª¤ï¤ê»þ¤Î°ÌÃ֤Υº¥ì¤òÂ裳¥Ö¥í¥Ã¥¯¤Î¥×¥í¥°¥é¥à¤Ï²ÃÌ£¤Ç¤¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢¥º¥ì¤Æ¤·¤Þ¤¤Àµ¤·¤¯Â裳¥Ö¥í¥Ã¥¯¤¬Æ°¤«¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£¾å¤Î¼Â¹Ô¥×¥í¥°¥é¥à¤Ç¤ÏÂ裲¥Ö¥í¥Ã¥¯¤Î½ª¤ï¤ê»þ¤Ë¿Í¤Î¼ê¤Ç¾¯¤·°ÌÃÖ¤òÀµ¤·¤¯¥º¥é¤·¤Æ¤¢¤²¤Ê¤¤¤È¤¤¤±¤Ê¤¤¡£¤½¤Î°ÌÃ֤Τº¤ì¤ò½¤Àµ¤¹¤ë¥³¡¼¥É¤òÉÕ¤±²Ã¤¨¤¿¤«¤Ã¤¿¤¬»þ´Ö¤¬Ìµ¤¯´Ö¤Ë¹ç¤ï¤Ê¤«¤Ã¤¿¡£¥Ö¥í¥Ã¥¯¤´¤È¤Ëʬ¤±¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢¥Ö¥í¥Ã¥¯Æâ¤Îưºî¤òãÀ®¤¹¤ë¤³¤È¤ËÀº°ìÇդˤʤäƤ·¤Þ¤¤¡¢¥Ö¥í¥Ã¥¯´Ö¤Î°Ü¹Ô»þ¤Ë¤Ä¤¤¤Æ¤Î¹Í褬·ç¤±¤Æ¤·¤Þ¤Ã¤¿¡£¤³¤ì¤ò²þÁ±¤¹¤ë°Ù¤Ëº£¸å¤Ï¡¢¤¢¤ë¥Ö¥í¥Ã¥¯¤¬Ä̲á¤Ç¤¤¿¤é¤½¤Î°ÌÃÖ¤òµÏ¿¤·¤Æ¤ª¤¡¢¤½¤Î°ÌÃÖ¤«¤é¼¡¤Î¥Ö¥í¥Ã¥¯¤òư¤«¤¹¥×¥í¥°¥é¥à¤ò¹Í¤¨¤ë¤è¤¦¤Ë¤¹¤ë¡£ -Â裴¥Ö¥í¥Ã¥¯¤Ê¤É¡¢¥³¡¼¥¹¤¢¤ê¤¤Î¥×¥í¥°¥é¥à¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤ÈÆÍÑÀ¤¬Ä㤯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£¸¶°ø¤Î°ì¤Ä¤Ëµå¤ò½¦¤¦¥¢¡¼¥à¤¬¾¯¤·¥º¥ì¤ë¤È¥¢¡¼¥à¤Î·ä´Ö¤Ëµå¤¬Æþ¤é¤º½¦¤¨¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¡¢¤½¤ÎÄ´À°¤ò¥é¥¤¥ó¥È¥ì¡¼¥¹¤Ç¤Ï¤Ê¤¯Ä¾ÀܳÑÅÙ¤òÁàºî¤¹¤ë¤·¤«Ìµ¤¯¤Ê¤Ã¤¿¤È¤¤¤¦¤Î¤¬¤¢¤ë¡£¥¢¡¼¥à¤Î·Á¤ò¤µ¤é¤Ë¹¤²¤¿¤ê¡¢Â¾¤Î¥°¥ë¡¼¥×¤¬¤·¤Æ¤¤¤¿¤è¤¦¤Ëµå¤Ë¤«¤Ö¤»¤ë¤è¤¦¤Ë¥¢¡¼¥à¤ò²¼¤í¤·µå¤ò»ý¤Á¾å¤²¤º¤Ë±¿¤Ö¤Ê¤É¤Î¹©Éפò¤·¤Æµå¤ò½¦¤¦¤È¸À¤¦Æ°ºî¤ÎµöÍÆÈϰϤò¹¤²¤ë¤Ù¤¤À¤Ã¤¿¡£ º£Æü¤ÎˬÌä¼Ô¿ô&counter(today);¿Í ºòÆü¤ÎˬÌä¼Ô¿ô&counter(yesterday);¿Í ¹ç·×ˬÌä¼Ô¿ô&counter(all);¿Í