diff --git a/lib/camera.py b/lib/camera.py index 7492c55a174e9c4f4612876bfb63bd6a50033f54..4b59c947fc09c43f3141a3b6f13c6c4b413587f9 100644 --- a/lib/camera.py +++ b/lib/camera.py @@ -17,9 +17,9 @@ TXT_M_USB_1_camera.add_blocked_area(blocked_area_right) blocked_area_left = txt_factory.camera_factory.create_blocked_area(0, 190, 80, 50) TXT_M_USB_1_camera.add_blocked_area(blocked_area_left) -ball_detector_goal_right = txt_factory.camera_factory.create_ball_detector(0, 70, 320, 120, 10, 120, -100, 100, [245,194,79], 25) +ball_detector_goal_right = txt_factory.camera_factory.create_ball_detector(0, 70, 320, 120, 10, 120, -100, 100, [182,142,47], 25) TXT_M_USB_1_camera.add_detector(ball_detector_goal_right) -ball_detector_goal_left = txt_factory.camera_factory.create_ball_detector(0, 70, 320, 120, 10, 120, -100, 100, [192,57,54], 25) +ball_detector_goal_left = txt_factory.camera_factory.create_ball_detector(0, 70, 320, 120, 10, 120, -100, 100, [157,31,43], 25) TXT_M_USB_1_camera.add_detector(ball_detector_goal_left) diff --git a/lib/camera.xml b/lib/camera.xml index 7b77a7674ef19fb4427475641a613b635d17fde4..f5350366c0ad3c0036bdcdefa4c75a2eda51d50c 100644 --- a/lib/camera.xml +++ b/lib/camera.xml @@ -1 +1 @@ -<xml type="camera" verion="1" version="2" rotate="0" height="240" width="320" fps="15"><item id="2" class="BallDetector"><name>ball_detector</name><color>#ff8f51</color><tolerance>10</tolerance><min_ball_diameter>5</min_ball_diameter><max_ball_diameter>80</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>0</y><width>320</width><height>240</height></geometry></item><item id="4" class="BlockedArea"><name>blocked_area_right</name><geometry><x>240</x><y>190</y><width>80</width><height>50</height></geometry></item><item id="5" class="BlockedArea"><name>blocked_area_left</name><geometry><x>0</x><y>190</y><width>80</width><height>50</height></geometry></item><item id="12" class="BallDetector"><name>ball_detector_goal_right</name><color>#f5c24f</color><tolerance>25</tolerance><min_ball_diameter>10</min_ball_diameter><max_ball_diameter>120</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>70</y><width>320</width><height>120</height></geometry></item><item id="11" class="BallDetector"><name>ball_detector_goal_left</name><color>#c03936</color><tolerance>25</tolerance><min_ball_diameter>10</min_ball_diameter><max_ball_diameter>120</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>70</y><width>320</width><height>120</height></geometry></item></xml> \ No newline at end of file +<xml type="camera" verion="1" version="2" rotate="0" height="240" width="320" fps="15"><item id="2" class="BallDetector"><name>ball_detector</name><color>#ff8f51</color><tolerance>10</tolerance><min_ball_diameter>5</min_ball_diameter><max_ball_diameter>80</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>0</y><width>320</width><height>240</height></geometry></item><item id="4" class="BlockedArea"><name>blocked_area_right</name><geometry><x>240</x><y>190</y><width>80</width><height>50</height></geometry></item><item id="5" class="BlockedArea"><name>blocked_area_left</name><geometry><x>0</x><y>190</y><width>80</width><height>50</height></geometry></item><item id="12" class="BallDetector"><name>ball_detector_goal_right</name><color>#b68e2f</color><tolerance>25</tolerance><min_ball_diameter>10</min_ball_diameter><max_ball_diameter>120</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>70</y><width>320</width><height>120</height></geometry></item><item id="11" class="BallDetector"><name>ball_detector_goal_left</name><color>#9d1f2b</color><tolerance>25</tolerance><min_ball_diameter>10</min_ball_diameter><max_ball_diameter>120</max_ball_diameter><start_range_value>-100</start_range_value><end_range_value>100</end_range_value><geometry><x>0</x><y>70</y><width>320</width><height>120</height></geometry></item></xml> \ No newline at end of file diff --git a/lib/display.qml b/lib/display.qml index 3ca23fc872d1a555b240dfc868489ab4bb2cd72a..88ea15352d455ef290ba8a5dc459606c3c8de098 100644 --- a/lib/display.qml +++ b/lib/display.qml @@ -49,7 +49,7 @@ TXTWindow { elide: Text.ElideRight x: 20 y: 40 - width: 39 + width: 40 height: 40 } TXTLabel { @@ -58,8 +58,8 @@ TXTWindow { font.pixelSize: 16 elide: Text.ElideRight x: 20 - y: 99 - width: 39 + y: 100 + width: 40 height: 40 } } diff --git a/lib/display.xml b/lib/display.xml index 06b4c0e7d7c18366a4ff09a7604e85d5df70e003..22cb52cd9760f1dd710ae44ea011d7cdaa439bff 100644 --- a/lib/display.xml +++ b/lib/display.xml @@ -1 +1 @@ -<xml type="display" version="2"><item id="4" class="TXTSwitch"><name>txt_switch_active</name><enabled>true</enabled><checked>false</checked><text>active</text><geometry><x>60</x><y>171</y><width>100</width><height>40</height></geometry></item><item id="5" class="TXTLabel"><name>txt_label_ball</name><text>-</text><geometry><x>60</x><y>40</y><width>100</width><height>40</height></geometry></item><item id="6" class="TXTLabel"><name>txt_label_goal</name><text>-</text><geometry><x>60</x><y>100</y><width>100</width><height>40</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label_ball_</name><text>ball</text><geometry><x>20</x><y>40</y><width>39</width><height>40</height></geometry></item><item id="8" class="TXTLabel"><name>txt_label_goal_</name><text>goal</text><geometry><x>20</x><y>99</y><width>39</width><height>40</height></geometry></item></xml> \ No newline at end of file +<xml type="display" version="2"><item id="4" class="TXTSwitch"><name>txt_switch_active</name><enabled>true</enabled><checked>false</checked><text>active</text><geometry><x>60</x><y>171</y><width>100</width><height>40</height></geometry></item><item id="5" class="TXTLabel"><name>txt_label_ball</name><text>-</text><geometry><x>60</x><y>40</y><width>100</width><height>40</height></geometry></item><item id="6" class="TXTLabel"><name>txt_label_goal</name><text>-</text><geometry><x>60</x><y>100</y><width>100</width><height>40</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label_ball_</name><text>ball</text><geometry><x>20</x><y>40</y><width>40</width><height>40</height></geometry></item><item id="8" class="TXTLabel"><name>txt_label_goal_</name><text>goal</text><geometry><x>20</x><y>100</y><width>40</width><height>40</height></geometry></item></xml> \ No newline at end of file diff --git a/omniwheels_x4_soccer_goal.blockly b/omniwheels_x4_soccer_goal.blockly index a1d2f68426909aef43e65715804024c266658f71..54284845620163da181c123fdc3ef75fabea11fb 100644 --- a/omniwheels_x4_soccer_goal.blockly +++ b/omniwheels_x4_soccer_goal.blockly @@ -701,153 +701,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="2039"> - <field name="NAME">checkTimeouts</field> - <statement name="STACK"> - <block type="controls_if" id="o.;j7*F0}TW}ju0E18(_"> - <value name="IF0"> - <block type="logic_compare" id="yaTkeEV~1|XTU#NgT)j7" inline="false"> - <field name="OP">GT</field> - <value name="A"> - <block type="math_arithmetic" id="zgksfhhp2%*/nv0kv]6k"> - <field name="OP">MINUS</field> - <value name="A"> - <block type="util_runtime_measurement" id="j-xyUfRHV,b}kCz08o+m"> - <field name="TIME">MILLISECOND</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="w|9iU`@W=6$!Dl%9u-Y@"> - <field name="VAR" id="v3eHF0atAL+ouaa{W$=m">ts_ball</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="math_number" id="5_ryZ94QfcJv2_:O]/?g"> - <field name="NUM">500</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="variables_set" id="Z:~u5a?M/hcKIufGbk]L"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - <value name="VALUE"> - <block type="logic_null" id="6nvUE+P$gKwIm:+6*sP!"/> - </value> - <next> - <block type="variables_set" id="$`MFfO6i!mT/klG+$:H]"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> - <value name="VALUE"> - <block type="logic_null" id="FHu):3h?Msu%QttHEtj]"/> - </value> - </block> - </next> - </block> - </statement> - <next> - <block type="controls_if" id="TB*rcFM~i@*D%Dwtx/?U"> - <value name="IF0"> - <block type="logic_compare" id="gPw1GMDTD1_[][5luwe;" inline="false"> - <field name="OP">GT</field> - <value name="A"> - <block type="math_arithmetic" id="THgFqXlrn6V_SnFEL,qY"> - <field name="OP">MINUS</field> - <value name="A"> - <block type="util_runtime_measurement" id="uw^6{2#8iqZO7RG;YaY7"> - <field name="TIME">MILLISECOND</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="HKOfg8b$oR@vts;7DObj"> - <field name="VAR" id=";Ki:[qYaZnowqSa`]/aW">ts_goal_left</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="math_number" id=".b=S3huhD!|a4Hsf^rGL"> - <field name="NUM">500</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="lists_setIndex" id="TkR|_blx2$,hT.aKkf~O"> - <mutation at="true"/> - <field name="MODE">SET</field> - <field name="WHERE">FROM_START</field> - <value name="LIST"> - <block type="variables_get" id="3#3BiP+h9}[ccaIDKlj/"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="AT"> - <block type="math_number" id="YWwjvCGqfBBv67F+ib58"> - <field name="NUM">1</field> - </block> - </value> - <value name="TO"> - <block type="logic_null" id="cM8^dckuY:nW*9,QoDS%"/> - </value> - </block> - </statement> - <next> - <block type="controls_if" id="3O$%2WU}~L29)rJb:dRd"> - <value name="IF0"> - <block type="logic_compare" id="KdN#iJT(!{.3f(:7.mAV" inline="false"> - <field name="OP">GT</field> - <value name="A"> - <block type="math_arithmetic" id="o?sdoD{y^2G_me0TF$8d"> - <field name="OP">MINUS</field> - <value name="A"> - <block type="util_runtime_measurement" id="N%$;|Spy3LX-7f1.cFC$"> - <field name="TIME">MILLISECOND</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="bpKR0|hoi*mdX]v*_:W7"> - <field name="VAR" id="z^z{Ev+IMfS6[W1raY;l">ts_goal_right</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="math_number" id=".+UfY)W[?!t8Vr%!Xs/v"> - <field name="NUM">500</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="lists_setIndex" id="~83Uj0HPT|J(,3W!LWCL"> - <mutation at="true"/> - <field name="MODE">SET</field> - <field name="WHERE">FROM_START</field> - <value name="LIST"> - <block type="variables_get" id="3?9q,AoE6r,fRB}w,{]i"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="AT"> - <block type="math_number" id=";;rL@zk@9)hLoS)Vv_A?"> - <field name="NUM">2</field> - </block> - </value> - <value name="TO"> - <block type="logic_null" id="GUm3tRkD[}|mB@r#$q~4"/> - </value> - </block> - </statement> - </block> - </next> - </block> - </next> - </block> - </statement> - </block> - <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="2492"> + <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="2039"> <field name="instance_name">ball_detector</field> <statement name="statement"> <block type="variables_set" id="=2/,IQfcLO{_5PNd3UK~"> @@ -1021,7 +875,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="3053"> + <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="2600"> <field name="instance_name">ball_detector_goal_left</field> <statement name="statement"> <block type="variables_set" id="kvK,D4e%04[?+!jq*Lch"> @@ -1092,7 +946,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="3314"> + <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="2861"> <field name="instance_name">ball_detector_goal_right</field> <statement name="statement"> <block type="variables_set" id="0!1?#@4|tcM8+U6E[$Tl"> @@ -1103,59 +957,332 @@ </block> </value> <next> - <block type="lists_setIndex" id="BgcR)HFQbgQ=c$87H-Rs"> - <mutation at="true"/> - <field name="MODE">SET</field> - <field name="WHERE">FROM_START</field> - <value name="LIST"> - <block type="variables_get" id=":/RJKz|OwJ!nhurLm~w0"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="AT"> - <block type="math_number" id="e-$k}+kU4DW9ZCaq^L6Z"> - <field name="NUM">2</field> - </block> + <block type="lists_setIndex" id="BgcR)HFQbgQ=c$87H-Rs"> + <mutation at="true"/> + <field name="MODE">SET</field> + <field name="WHERE">FROM_START</field> + <value name="LIST"> + <block type="variables_get" id=":/RJKz|OwJ!nhurLm~w0"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="e-$k}+kU4DW9ZCaq^L6Z"> + <field name="NUM">2</field> + </block> + </value> + <value name="TO"> + <block type="camera_ball_get_value" id="HD@dB-1^W^R^cl$FEj1B"> + <field name="dropdown_event">x</field> + <value name="instance_name"> + <shadow type="camera_detection_event" id="]JXunPguPu4`2m+P=9h!"/> + </value> + </block> + </value> + <next> + <block type="text_print" id="q2(^p4SyTCB3V9x$qufL"> + <value name="TEXT"> + <shadow type="text"> + <field name="TEXT"/> + </shadow> + <block type="text_format" id="pcQS07Q^!C|~pVid{}Ev"> + <mutation items="2"/> + <value name="value"> + <shadow type="text" id="hWEmmvBo)?2YN$R3?}1C"> + <field name="TEXT">goal right: posx:{} posy:{}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="camera_ball_get_value" id="oYhV*54ObZ(bGW#uT|FB"> + <field name="dropdown_event">x</field> + <value name="instance_name"> + <shadow type="camera_detection_event" id="*^dJE~J_!XF_5.jU]mhZ"/> + </value> + </block> + </value> + <value name="ADD1"> + <block type="camera_ball_get_value" id="_L:jweTen.9z!a~w#+bl"> + <field name="dropdown_event">y</field> + <value name="instance_name"> + <shadow type="camera_detection_event" id="qo7;3$`+qC4Qpg/`.~+W"/> + </value> + </block> + </value> + </block> + </value> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="3122"> + <field name="NAME">checkTimeouts</field> + <statement name="STACK"> + <block type="controls_if" id="o.;j7*F0}TW}ju0E18(_"> + <value name="IF0"> + <block type="logic_compare" id="yaTkeEV~1|XTU#NgT)j7" inline="false"> + <field name="OP">GT</field> + <value name="A"> + <block type="math_arithmetic" id="zgksfhhp2%*/nv0kv]6k"> + <field name="OP">MINUS</field> + <value name="A"> + <block type="util_runtime_measurement" id="j-xyUfRHV,b}kCz08o+m"> + <field name="TIME">MILLISECOND</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="w|9iU`@W=6$!Dl%9u-Y@"> + <field name="VAR" id="v3eHF0atAL+ouaa{W$=m">ts_ball</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="math_number" id="5_ryZ94QfcJv2_:O]/?g"> + <field name="NUM">500</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="variables_set" id="Z:~u5a?M/hcKIufGbk]L"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + <value name="VALUE"> + <block type="logic_null" id="6nvUE+P$gKwIm:+6*sP!"/> + </value> + <next> + <block type="variables_set" id="$`MFfO6i!mT/klG+$:H]"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + <value name="VALUE"> + <block type="logic_null" id="FHu):3h?Msu%QttHEtj]"/> + </value> + </block> + </next> + </block> + </statement> + <next> + <block type="controls_if" id="TB*rcFM~i@*D%Dwtx/?U"> + <value name="IF0"> + <block type="logic_compare" id="gPw1GMDTD1_[][5luwe;" inline="false"> + <field name="OP">GT</field> + <value name="A"> + <block type="math_arithmetic" id="THgFqXlrn6V_SnFEL,qY"> + <field name="OP">MINUS</field> + <value name="A"> + <block type="util_runtime_measurement" id="uw^6{2#8iqZO7RG;YaY7"> + <field name="TIME">MILLISECOND</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="HKOfg8b$oR@vts;7DObj"> + <field name="VAR" id=";Ki:[qYaZnowqSa`]/aW">ts_goal_left</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="math_number" id=".b=S3huhD!|a4Hsf^rGL"> + <field name="NUM">500</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="lists_setIndex" id="TkR|_blx2$,hT.aKkf~O"> + <mutation at="true"/> + <field name="MODE">SET</field> + <field name="WHERE">FROM_START</field> + <value name="LIST"> + <block type="variables_get" id="3#3BiP+h9}[ccaIDKlj/"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="YWwjvCGqfBBv67F+ib58"> + <field name="NUM">1</field> + </block> + </value> + <value name="TO"> + <block type="logic_null" id="cM8^dckuY:nW*9,QoDS%"/> + </value> + </block> + </statement> + <next> + <block type="controls_if" id="3O$%2WU}~L29)rJb:dRd"> + <value name="IF0"> + <block type="logic_compare" id="KdN#iJT(!{.3f(:7.mAV" inline="false"> + <field name="OP">GT</field> + <value name="A"> + <block type="math_arithmetic" id="o?sdoD{y^2G_me0TF$8d"> + <field name="OP">MINUS</field> + <value name="A"> + <block type="util_runtime_measurement" id="N%$;|Spy3LX-7f1.cFC$"> + <field name="TIME">MILLISECOND</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="bpKR0|hoi*mdX]v*_:W7"> + <field name="VAR" id="z^z{Ev+IMfS6[W1raY;l">ts_goal_right</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="math_number" id=".+UfY)W[?!t8Vr%!Xs/v"> + <field name="NUM">500</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="lists_setIndex" id="~83Uj0HPT|J(,3W!LWCL"> + <mutation at="true"/> + <field name="MODE">SET</field> + <field name="WHERE">FROM_START</field> + <value name="LIST"> + <block type="variables_get" id="3?9q,AoE6r,fRB}w,{]i"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id=";;rL@zk@9)hLoS)Vv_A?"> + <field name="NUM">2</field> + </block> + </value> + <value name="TO"> + <block type="logic_null" id="GUm3tRkD[}|mB@r#$q~4"/> + </value> + </block> + </statement> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="3575"> + <value name="condition"> + <block type="input_photo_transistor_if_state" id="dX]-jf`=2/tNnEnHfKvx"> + <field name="instance_name">TXT_M_I8_photo_transistor</field> + <field name="property_name">dark</field> + </block> + </value> + <statement name="statement"> + <block type="procedures_callnoreturn" id="5g}yP+C``b}R[T#xBtg|"> + <mutation name="shotBall"/> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="3684"> + <field name="NAME">shotBall</field> + <statement name="STACK"> + <block type="servomotor_set_position" id="9C*rGH2+bsy8H4Xzz#gk"> + <field name="instance_name">TXT_M_S1_servomotor</field> + <value name="position"> + <shadow type="servomotor_number" id="3#vdOeDe(0MHgYPRG0eb"> + <field name="SERVOMOTOR_NUM">400</field> + </shadow> + </value> + <next> + <block type="encodermotor_set_values" id="F+hDM}p/#t|XH]+z~~$B"> + <mutation syncBlocks="3"/> + <field name="instance_name_0">TXT_M_M1_encodermotor</field> + <field name="direction_0">Motor.CCW</field> + <field name="instance_name_1">TXT_M_M2_encodermotor</field> + <field name="direction_1">Motor.CCW</field> + <field name="instance_name_2">TXT_M_M3_encodermotor</field> + <field name="direction_2">Motor.CCW</field> + <field name="instance_name_3">TXT_M_M4_encodermotor</field> + <field name="direction_3">Motor.CCW</field> + <value name="speed"> + <shadow type="motor_number" id="64D3bb)L:IYB~nq!(4hR"> + <field name="MOTOR_NUM">512</field> + </shadow> </value> - <value name="TO"> - <block type="camera_ball_get_value" id="HD@dB-1^W^R^cl$FEj1B"> - <field name="dropdown_event">x</field> - <value name="instance_name"> - <shadow type="camera_detection_event" id="]JXunPguPu4`2m+P=9h!"/> - </value> - </block> + <value name="distance"> + <shadow type="math_number" id="!vn0#[@_$kjeevcKcnqF"> + <field name="NUM">100</field> + </shadow> </value> <next> - <block type="text_print" id="q2(^p4SyTCB3V9x$qufL"> - <value name="TEXT"> - <shadow type="text"> - <field name="TEXT"/> + <block type="util_wait_for" id="m3t4v%1!lE[H3:*p2qXE"> + <field name="format">ms</field> + <value name="value"> + <shadow type="math_number" id="[f5FG@r=T8wETvhgPjR#"> + <field name="NUM">50</field> </shadow> - <block type="text_format" id="pcQS07Q^!C|~pVid{}Ev"> - <mutation items="2"/> - <value name="value"> - <shadow type="text" id="hWEmmvBo)?2YN$R3?}1C"> - <field name="TEXT">goal right: posx:{} posy:{}</field> + </value> + <next> + <block type="servomotor_set_position" id="[6Fc9E204i$BHgyH9F-W"> + <field name="instance_name">TXT_M_S1_servomotor</field> + <value name="position"> + <shadow type="servomotor_number" id="i.IOaM[DE:d3D.IL`53*"> + <field name="SERVOMOTOR_NUM">256</field> </shadow> </value> - <value name="ADD0"> - <block type="camera_ball_get_value" id="oYhV*54ObZ(bGW#uT|FB"> - <field name="dropdown_event">x</field> - <value name="instance_name"> - <shadow type="camera_detection_event" id="*^dJE~J_!XF_5.jU]mhZ"/> - </value> - </block> - </value> - <value name="ADD1"> - <block type="camera_ball_get_value" id="_L:jweTen.9z!a~w#+bl"> - <field name="dropdown_event">y</field> - <value name="instance_name"> - <shadow type="camera_detection_event" id="qo7;3$`+qC4Qpg/`.~+W"/> + <next> + <block type="util_wait_until" id="kEY!lgl3*DfU:CB]K2{%"> + <value name="value"> + <block type="encodermotor_position_read" id="bi9}0jIIDM*S92db?fO["> + <field name="instance_name">TXT_M_M1_encodermotor</field> + </block> </value> + <next> + <block type="encodermotor_set_values" id="ZqZiW,6J)cdL38}.8Dp6"> + <mutation syncBlocks="3"/> + <field name="instance_name_0">TXT_M_M1_encodermotor</field> + <field name="direction_0">Motor.CW</field> + <field name="instance_name_1">TXT_M_M2_encodermotor</field> + <field name="direction_1">Motor.CW</field> + <field name="instance_name_2">TXT_M_M3_encodermotor</field> + <field name="direction_2">Motor.CW</field> + <field name="instance_name_3">TXT_M_M4_encodermotor</field> + <field name="direction_3">Motor.CW</field> + <value name="speed"> + <shadow type="motor_number" id="Q(^TrT!sMN6[NB-$y!`U"> + <field name="MOTOR_NUM">512</field> + </shadow> + </value> + <value name="distance"> + <shadow type="math_number" id="vv:iZ6tXN]M@jx0UY]0T"> + <field name="NUM">40</field> + </shadow> + </value> + <next> + <block type="util_wait_until" id="S:|a({u_(UrXi*)+(pyx"> + <value name="value"> + <block type="encodermotor_position_read" id="9n59:FNrXDFp`7c!3gb+"> + <field name="instance_name">TXT_M_M1_encodermotor</field> + </block> + </value> + <next> + <block type="sound_play_audio_file" id="-8bCV.(5yrq.DB#~[_}@"> + <field name="soundfile_name">26_Augenzwinkern.wav</field> + <field name="checkbox">FALSE</field> + <next> + <block type="util_wait_until" id="O|8(q6;n0}n@CgSBRQCl"> + <value name="value"> + <block type="logic_negate" id="g4~%p~r;1tU)2+XmU,@N"> + <value name="BOOL"> + <block type="sound_is_playing_audiofile" id="kaPo^8PCo^/;@S8JJp^2"/> + </value> + </block> + </value> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> </block> - </value> + </next> </block> - </value> + </next> </block> </next> </block> @@ -1163,7 +1290,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" x="0" y="3575"> + <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" collapsed="true" x="0" y="4242"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -1191,7 +1318,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" x="0" y="3796"> + <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" collapsed="true" x="0" y="4309"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -1219,7 +1346,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" x="0" y="4017"> + <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" collapsed="true" x="0" y="4376"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1247,7 +1374,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" x="0" y="4238"> + <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" collapsed="true" x="0" y="4443"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1275,7 +1402,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" x="0" y="4459"> + <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" collapsed="true" x="0" y="4510"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1303,7 +1430,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" x="0" y="4680"> + <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" collapsed="true" x="0" y="4577"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1331,7 +1458,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="+FKt%DE[[q%Zp0T.Fn}d" x="0" y="4901"> + <block type="procedures_defnoreturn" id="+FKt%DE[[q%Zp0T.Fn}d" collapsed="true" x="0" y="4644"> <field name="NAME">stop</field> <statement name="STACK"> <block type="encodermotor_stop" id="}]1#.xeDc*.k9aGX5P?4"> @@ -1343,7 +1470,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" x="0" y="5094"> + <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" collapsed="true" x="0" y="4711"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="K)Z,8|d5@gck+Q]pnW01"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="(Id`t]O(jxfZJay}20X{"/> @@ -1409,7 +1536,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" x="0" y="5451"> + <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" collapsed="true" x="0" y="4778"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="_mFFsmoZwL{(llRvf-eW"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="aNHXtqe[T`=Y[mqp`ZDN"/> @@ -1475,7 +1602,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" x="0" y="5808"> + <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" collapsed="true" x="0" y="4845"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="~d8Z+AHZ!wz|G]JHW0lQ"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="jRMx@L,Ya|zd@/bBb#1T"/> @@ -1541,7 +1668,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" x="0" y="6165"> + <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" collapsed="true" x="0" y="4912"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="8Z2n_ZVA.)85]V7j%3;7"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="J(gJ~*9ZJJa,[V1)[xn#"/> @@ -1607,7 +1734,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="6522"> + <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" collapsed="true" x="0" y="4979"> <field name="NAME">turnLeft</field> <statement name="STACK"> <block type="procedures_callnoreturn" id="n2^-(/I;nyLq_t.8g0Hh" inline="true"> @@ -1656,7 +1783,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="$nY7HNz^i}wlpk/f(Dja" x="0" y="6707"> + <block type="procedures_defnoreturn" id="$nY7HNz^i}wlpk/f(Dja" collapsed="true" x="0" y="5046"> <field name="NAME">turnRight</field> <statement name="STACK"> <block type="procedures_callnoreturn" id="%_T=@p6r8~Uq5{@hAFr2" inline="true"> @@ -1705,131 +1832,4 @@ </block> </statement> </block> - <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="6892"> - <value name="condition"> - <block type="input_photo_transistor_if_state" id="dX]-jf`=2/tNnEnHfKvx"> - <field name="instance_name">TXT_M_I8_photo_transistor</field> - <field name="property_name">dark</field> - </block> - </value> - <statement name="statement"> - <block type="procedures_callnoreturn" id="5g}yP+C``b}R[T#xBtg|"> - <mutation name="shotBall"/> - </block> - </statement> - </block> - <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="7001"> - <field name="NAME">shotBall</field> - <statement name="STACK"> - <block type="servomotor_set_position" id="9C*rGH2+bsy8H4Xzz#gk"> - <field name="instance_name">TXT_M_S1_servomotor</field> - <value name="position"> - <shadow type="servomotor_number" id="3#vdOeDe(0MHgYPRG0eb"> - <field name="SERVOMOTOR_NUM">400</field> - </shadow> - </value> - <next> - <block type="encodermotor_set_values" id="F+hDM}p/#t|XH]+z~~$B"> - <mutation syncBlocks="3"/> - <field name="instance_name_0">TXT_M_M1_encodermotor</field> - <field name="direction_0">Motor.CCW</field> - <field name="instance_name_1">TXT_M_M2_encodermotor</field> - <field name="direction_1">Motor.CCW</field> - <field name="instance_name_2">TXT_M_M3_encodermotor</field> - <field name="direction_2">Motor.CCW</field> - <field name="instance_name_3">TXT_M_M4_encodermotor</field> - <field name="direction_3">Motor.CCW</field> - <value name="speed"> - <shadow type="motor_number" id="64D3bb)L:IYB~nq!(4hR"> - <field name="MOTOR_NUM">512</field> - </shadow> - </value> - <value name="distance"> - <shadow type="math_number" id="!vn0#[@_$kjeevcKcnqF"> - <field name="NUM">100</field> - </shadow> - </value> - <next> - <block type="util_wait_for" id="m3t4v%1!lE[H3:*p2qXE"> - <field name="format">ms</field> - <value name="value"> - <shadow type="math_number" id="[f5FG@r=T8wETvhgPjR#"> - <field name="NUM">50</field> - </shadow> - </value> - <next> - <block type="servomotor_set_position" id="[6Fc9E204i$BHgyH9F-W"> - <field name="instance_name">TXT_M_S1_servomotor</field> - <value name="position"> - <shadow type="servomotor_number" id="i.IOaM[DE:d3D.IL`53*"> - <field name="SERVOMOTOR_NUM">256</field> - </shadow> - </value> - <next> - <block type="util_wait_until" id="kEY!lgl3*DfU:CB]K2{%"> - <value name="value"> - <block type="encodermotor_position_read" id="bi9}0jIIDM*S92db?fO["> - <field name="instance_name">TXT_M_M1_encodermotor</field> - </block> - </value> - <next> - <block type="encodermotor_set_values" id="ZqZiW,6J)cdL38}.8Dp6"> - <mutation syncBlocks="3"/> - <field name="instance_name_0">TXT_M_M1_encodermotor</field> - <field name="direction_0">Motor.CW</field> - <field name="instance_name_1">TXT_M_M2_encodermotor</field> - <field name="direction_1">Motor.CW</field> - <field name="instance_name_2">TXT_M_M3_encodermotor</field> - <field name="direction_2">Motor.CW</field> - <field name="instance_name_3">TXT_M_M4_encodermotor</field> - <field name="direction_3">Motor.CW</field> - <value name="speed"> - <shadow type="motor_number" id="Q(^TrT!sMN6[NB-$y!`U"> - <field name="MOTOR_NUM">512</field> - </shadow> - </value> - <value name="distance"> - <shadow type="math_number" id="vv:iZ6tXN]M@jx0UY]0T"> - <field name="NUM">40</field> - </shadow> - </value> - <next> - <block type="util_wait_until" id="S:|a({u_(UrXi*)+(pyx"> - <value name="value"> - <block type="encodermotor_position_read" id="9n59:FNrXDFp`7c!3gb+"> - <field name="instance_name">TXT_M_M1_encodermotor</field> - </block> - </value> - <next> - <block type="sound_play_audio_file" id="-8bCV.(5yrq.DB#~[_}@"> - <field name="soundfile_name">26_Augenzwinkern.wav</field> - <field name="checkbox">FALSE</field> - <next> - <block type="util_wait_until" id="O|8(q6;n0}n@CgSBRQCl"> - <value name="value"> - <block type="logic_negate" id="g4~%p~r;1tU)2+XmU,@N"> - <value name="BOOL"> - <block type="sound_is_playing_audiofile" id="kaPo^8PCo^/;@S8JJp^2"/> - </value> - </block> - </value> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </statement> - </block> </xml> \ No newline at end of file diff --git a/omniwheels_x4_soccer_goal.py b/omniwheels_x4_soccer_goal.py index 148307325597526105b3af86eaced78c6befff3a..b19ca943b301ef258ddd89a25a7e33bc746212e1 100644 --- a/omniwheels_x4_soccer_goal.py +++ b/omniwheels_x4_soccer_goal.py @@ -67,6 +67,45 @@ def ball_callback23(event): ball_detector_goal_right.add_detection_listener(ball_callback23) +def callback(event): + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, speed_y, posy_ball, posx_goal, x_min, x_max, y_min, y_max, v_slow, v_fast + if TXT_M_I8_photo_transistor.is_dark(): + shotBall() + + +TXT_M_I8_photo_transistor.add_change_listener("dark", callback) + + +def shotBall(): + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, speed_y, posy_ball, posx_goal, x_min, x_max, y_min, y_max, v_slow, v_fast + TXT_M_S1_servomotor.set_position(int(400)) + TXT_M_M1_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M2_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M3_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M4_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M1_encodermotor.set_distance(int(100), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) + time.sleep(0.05) + TXT_M_S1_servomotor.set_position(int(256)) + while True: + if (not TXT_M_M1_encodermotor.is_running()): + break + time.sleep(0.010) + TXT_M_M1_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M2_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M3_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M4_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M1_encodermotor.set_distance(int(40), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) + while True: + if (not TXT_M_M1_encodermotor.is_running()): + break + time.sleep(0.010) + TXT_M.get_loudspeaker().play("26_Augenzwinkern.wav", False) + while True: + if (not (TXT_M.get_loudspeaker().is_playing())): + break + time.sleep(0.010) + + def fwd_v(v): global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, speed_y, posy_ball, posx_goal, x_min, x_max, y_min, y_max, v_slow, v_fast TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) @@ -196,45 +235,6 @@ def turnRight(): left(512, 100) -def callback(event): - global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, speed_y, posy_ball, posx_goal, x_min, x_max, y_min, y_max, v_slow, v_fast - if TXT_M_I8_photo_transistor.is_dark(): - shotBall() - - -TXT_M_I8_photo_transistor.add_change_listener("dark", callback) - - -def shotBall(): - global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, speed_y, posy_ball, posx_goal, x_min, x_max, y_min, y_max, v_slow, v_fast - TXT_M_S1_servomotor.set_position(int(400)) - TXT_M_M1_encodermotor.set_speed(int(512), Motor.CCW) - TXT_M_M2_encodermotor.set_speed(int(512), Motor.CCW) - TXT_M_M3_encodermotor.set_speed(int(512), Motor.CCW) - TXT_M_M4_encodermotor.set_speed(int(512), Motor.CCW) - TXT_M_M1_encodermotor.set_distance(int(100), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) - time.sleep(0.05) - TXT_M_S1_servomotor.set_position(int(256)) - while True: - if (not TXT_M_M1_encodermotor.is_running()): - break - time.sleep(0.010) - TXT_M_M1_encodermotor.set_speed(int(512), Motor.CW) - TXT_M_M2_encodermotor.set_speed(int(512), Motor.CW) - TXT_M_M3_encodermotor.set_speed(int(512), Motor.CW) - TXT_M_M4_encodermotor.set_speed(int(512), Motor.CW) - TXT_M_M1_encodermotor.set_distance(int(40), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) - while True: - if (not TXT_M_M1_encodermotor.is_running()): - break - time.sleep(0.010) - TXT_M.get_loudspeaker().play("26_Augenzwinkern.wav", False) - while True: - if (not (TXT_M.get_loudspeaker().is_playing())): - break - time.sleep(0.010) - - factor_x = 0.2 factor_y = 3.5 speed_y = 300