diff --git a/lib/display.qml b/lib/display.qml index 88ea15352d455ef290ba8a5dc459606c3c8de098..53ad8d5391570c88587d12fcd3b3d0bbede6f972 100644 --- a/lib/display.qml +++ b/lib/display.qml @@ -16,7 +16,7 @@ TXTWindow { text: "active" font.pixelSize: 16 enabled: true - checked: false + checked: true x: 60 y: 171 width: 100 diff --git a/lib/display.xml b/lib/display.xml index 22cb52cd9760f1dd710ae44ea011d7cdaa439bff..cf1b4205f2c980c0bfae80c45ade432dda8aa5b2 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>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 +<xml type="display" version="2"><item id="4" class="TXTSwitch"><name>txt_switch_active</name><enabled>true</enabled><checked>true</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 54284845620163da181c123fdc3ef75fabea11fb..5677788ae0b99a1e3cfb0f23fe50a44a559856bd 100644 --- a/omniwheels_x4_soccer_goal.blockly +++ b/omniwheels_x4_soccer_goal.blockly @@ -9,13 +9,14 @@ <variable id="S~)Q:X5BHfQZe.ZJfdE)">factor_y</variable> <variable id="S4.mduNQC(va3iR{oSdB">posx_ball</variable> <variable id="AnbD2s`i`niJf7bj:WR.">dist_x</variable> - <variable id=";S3?%3)**s[[l~Aq3*,{">speed_y</variable> + <variable id="Ym/+Qo0YZe25;%N1d!*f">x_min</variable> <variable id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</variable> + <variable id=";S3?%3)**s[[l~Aq3*,{">speed_y</variable> <variable id="=2ARo+;2DS07SU~j29Fk">posx_goal</variable> - <variable id="Ym/+Qo0YZe25;%N1d!*f">x_min</variable> <variable id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</variable> - <variable id="}*jl@)UA_Hjh5rc,Gt)c">y_min</variable> - <variable id="xjf5O*w9;IZf$n55ytVF">y_max</variable> + <variable id="}*jl@)UA_Hjh5rc,Gt)c">y_ball_far</variable> + <variable id="09n]XF2CKURQs)nHOfam">y_ball_near</variable> + <variable id="xjf5O*w9;IZf$n55ytVF">y_ball_touch</variable> <variable id=")rK_fR,m=]b(j[{.CtBj">v_slow</variable> <variable id="1idj3sw*{G$j`2:II{^5">v_fast</variable> </variables> @@ -37,40 +38,40 @@ </block> </value> <next> - <block type="variables_set" id="]%ml*lOalIadLPpR7ile"> - <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">speed_y</field> + <block type="variables_set" id="/3.38rZxsC*ejKOW0%9:"> + <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> <value name="VALUE"> - <block type="math_number" id="cR-GPTpe,aC(~]x%10m)"> - <field name="NUM">300</field> + <block type="math_number" id="@Esp)^vGnSXO=QsK)N9~"> + <field name="NUM">-3</field> </block> </value> <next> - <block type="variables_set" id="/3.38rZxsC*ejKOW0%9:"> - <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> + <block type="variables_set" id="(ig6:SZ(u%_^VsKLJN=l"> + <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> <value name="VALUE"> - <block type="math_number" id="@Esp)^vGnSXO=QsK)N9~"> - <field name="NUM">-3</field> + <block type="math_number" id="[r2m=DpI#8/tg+.FmdbN"> + <field name="NUM">3</field> </block> </value> <next> - <block type="variables_set" id="(ig6:SZ(u%_^VsKLJN=l"> - <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> + <block type="variables_set" id="OMK@?HIgcaISEF?)F38m"> + <field name="VAR" id="}*jl@)UA_Hjh5rc,Gt)c">y_ball_far</field> <value name="VALUE"> - <block type="math_number" id="[r2m=DpI#8/tg+.FmdbN"> - <field name="NUM">3</field> + <block type="math_number" id="+Lh~UibuYaJ$9i{V2?E5"> + <field name="NUM">7</field> </block> </value> <next> - <block type="variables_set" id="OMK@?HIgcaISEF?)F38m"> - <field name="VAR" id="}*jl@)UA_Hjh5rc,Gt)c">y_min</field> + <block type="variables_set" id="S2nwP`o+%u[9kc]ctSrQ"> + <field name="VAR" id="09n]XF2CKURQs)nHOfam">y_ball_near</field> <value name="VALUE"> - <block type="math_number" id="+Lh~UibuYaJ$9i{V2?E5"> - <field name="NUM">7</field> + <block type="math_number" id="7S}[)qBEl/AotP|IAi0!"> + <field name="NUM">50</field> </block> </value> <next> <block type="variables_set" id="4)f*C0^w#HD@8ffuS.}."> - <field name="VAR" id="xjf5O*w9;IZf$n55ytVF">y_max</field> + <field name="VAR" id="xjf5O*w9;IZf$n55ytVF">y_ball_touch</field> <value name="VALUE"> <block type="math_number" id="LM`a65R18{B1Q,ON@MsQ"> <field name="NUM">74</field> @@ -81,7 +82,7 @@ <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> <value name="VALUE"> <block type="math_number" id="WI$:pL{1wYx/-L0!4NgB"> - <field name="NUM">300</field> + <field name="NUM">200</field> </block> </value> <next> @@ -93,571 +94,712 @@ </block> </value> <next> - <block type="variables_set" id="08j[^aKhj-mzD-up%28Q"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + <block type="variables_set" id="${6w(je.)JDx9*IU-]X%"> + <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">speed_y</field> <value name="VALUE"> - <block type="lists_create_with" id=")t9;_o5:Uk`S#-x6ceH."> - <mutation items="2"/> - <value name="ADD0"> - <block type="logic_null" id="x$j.V#h.,j3GQ?l*m7.^"/> - </value> - <value name="ADD1"> - <block type="logic_null" id="I%tVa0ny05XAmaVV:F.b"/> - </value> + <block type="math_number" id="HE{Fb0.3#.+inUWR}#c]"> + <field name="NUM">512</field> </block> </value> <next> - <block type="variables_set" id="PY^XT?g46JMYP[0)HO!l"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + <block type="variables_set" id="08j[^aKhj-mzD-up%28Q"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> <value name="VALUE"> - <block type="logic_null" id="^h(n6DKLT?~XLRAo4CRP"/> + <block type="lists_create_with" id=")t9;_o5:Uk`S#-x6ceH."> + <mutation items="2"/> + <value name="ADD0"> + <block type="logic_null" id="x$j.V#h.,j3GQ?l*m7.^"/> + </value> + <value name="ADD1"> + <block type="logic_null" id="I%tVa0ny05XAmaVV:F.b"/> + </value> + </block> </value> <next> - <block type="variables_set" id="aF_J-4Iq4Jy=)dS.]:62"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + <block type="variables_set" id="PY^XT?g46JMYP[0)HO!l"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> <value name="VALUE"> - <block type="logic_null" id="~`*jJ8l2,?]ICIb*0btf"/> + <block type="logic_null" id="^h(n6DKLT?~XLRAo4CRP"/> </value> <next> - <block type="variables_set" id="Vyrr#z=fQDk#C,Ymx5FJ"> - <field name="VAR" id="v3eHF0atAL+ouaa{W$=m">ts_ball</field> + <block type="variables_set" id="aF_J-4Iq4Jy=)dS.]:62"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> <value name="VALUE"> - <block type="util_runtime_measurement" id="O!p9@+{cCQ5ov3?1cB9F"> - <field name="TIME">MILLISECOND</field> - </block> + <block type="logic_null" id="~`*jJ8l2,?]ICIb*0btf"/> </value> <next> - <block type="variables_set" id=",#}P8.}lYXpT3LT`P:?w"> - <field name="VAR" id=";Ki:[qYaZnowqSa`]/aW">ts_goal_left</field> + <block type="variables_set" id="Vyrr#z=fQDk#C,Ymx5FJ"> + <field name="VAR" id="v3eHF0atAL+ouaa{W$=m">ts_ball</field> <value name="VALUE"> - <block type="util_runtime_measurement" id="GONAj}Dx[0?0CBm%nsU6"> + <block type="util_runtime_measurement" id="O!p9@+{cCQ5ov3?1cB9F"> <field name="TIME">MILLISECOND</field> </block> </value> <next> - <block type="variables_set" id="8`mdTp}$]{VWKH.cNxI;"> - <field name="VAR" id="z^z{Ev+IMfS6[W1raY;l">ts_goal_right</field> + <block type="variables_set" id=",#}P8.}lYXpT3LT`P:?w"> + <field name="VAR" id=";Ki:[qYaZnowqSa`]/aW">ts_goal_left</field> <value name="VALUE"> - <block type="util_runtime_measurement" id="iQYX(E[,RbI0z8A#M9o%"> + <block type="util_runtime_measurement" id="GONAj}Dx[0?0CBm%nsU6"> <field name="TIME">MILLISECOND</field> </block> </value> <next> - <block type="loop_endless" id="V,Gw25li,3_,;92QCQLj"> - <statement name="DO"> - <block type="procedures_callnoreturn" id="O6U,(~H4n-^0fP^x)_,{"> - <mutation name="checkTimeouts"/> - <next> - <block type="controls_if" id="LIzedxH5dle@WM!lcbM#"> - <value name="IF0"> - <block type="display_get_switch_state" id="/xkM7bR[)*BEY41xd)JA"> - <field name="instance_name">txt_switch_active</field> - <field name="property_name">checked</field> - </block> - </value> - <statement name="DO0"> - <block type="controls_if" id="MN`F(]itK#DR^wQxXz,."> - <mutation elseif="1" else="1"/> + <block type="variables_set" id="8`mdTp}$]{VWKH.cNxI;"> + <field name="VAR" id="z^z{Ev+IMfS6[W1raY;l">ts_goal_right</field> + <value name="VALUE"> + <block type="util_runtime_measurement" id="iQYX(E[,RbI0z8A#M9o%"> + <field name="TIME">MILLISECOND</field> + </block> + </value> + <next> + <block type="loop_endless" id="V,Gw25li,3_,;92QCQLj"> + <statement name="DO"> + <block type="procedures_callnoreturn" id="O6U,(~H4n-^0fP^x)_,{"> + <mutation name="checkTimeouts"/> + <next> + <block type="controls_if" id="LIzedxH5dle@WM!lcbM#"> <value name="IF0"> - <block type="logic_operation" id="QKmOZD,=Y4S|jqiAJ4.k" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_operation" id="Xu[n/TE:SYcd;s+dYubv" inline="false"> + <block type="display_get_switch_state" id="/xkM7bR[)*BEY41xd)JA"> + <field name="instance_name">txt_switch_active</field> + <field name="property_name">checked</field> + </block> + </value> + <statement name="DO0"> + <block type="controls_if" id="MN`F(]itK#DR^wQxXz,."> + <mutation elseif="2" else="1"/> + <value name="IF0"> + <block type="logic_operation" id="QKmOZD,=Y4S|jqiAJ4.k" inline="false"> <field name="OP">AND</field> <value name="A"> - <block type="logic_compare" id="OeAZ19W_g)]s*LP0=8r,"> - <field name="OP">NEQ</field> + <block type="logic_operation" id="Xu[n/TE:SYcd;s+dYubv" inline="false"> + <field name="OP">AND</field> <value name="A"> - <block type="variables_get" id="M/Nu-s2$K?+~7cG|vO,;"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + <block type="logic_compare" id="OeAZ19W_g)]s*LP0=8r,"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="M/Nu-s2$K?+~7cG|vO,;"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="B"> + <block type="logic_null" id="z~Da7_)q,Bo-$yJb73oH"/> + </value> </block> </value> <value name="B"> - <block type="logic_null" id="z~Da7_)q,Bo-$yJb73oH"/> + <block type="logic_compare" id="d9U8).!K)LC)*3RzV-$z"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="^H7sM5ajVqht|@UM.F/m"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="logic_null" id=":8|/_EWW~8cxsv_2[8XZ"/> + </value> + </block> </value> </block> </value> <value name="B"> - <block type="logic_compare" id="d9U8).!K)LC)*3RzV-$z"> - <field name="OP">NEQ</field> + <block type="logic_operation" id="?A+N_1,#}@kRY%dxQMa9" inline="false"> + <field name="OP">AND</field> <value name="A"> - <block type="variables_get" id="^H7sM5ajVqht|@UM.F/m"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + <block type="logic_compare" id="`~AJbhHRzn/)DgR4fRI;"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="lists_getIndex" id="wBVqviD0-D3E`(V(uiV~"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="variables_get" id="?uA|$zvDe+x4kMz%-{d."> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="3~ZXLDV~ZSV8RX_^%[6]"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="logic_null" id="vG[m`V+N^1KjrN:te9QO"/> + </value> </block> </value> <value name="B"> - <block type="logic_null" id=":8|/_EWW~8cxsv_2[8XZ"/> + <block type="logic_compare" id=";P}d!ou6kF,_]Y}2c}oU"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="lists_getIndex" id="9qxZzDB=dlHB#35+H*!N"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="variables_get" id="D3C[P^f3vp}xb!,-2#r5"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="@69b4byUu7@Wfx)U/;Xp"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="logic_null" id="1@:,7WVUfe~r2),.)v7f"/> + </value> + </block> </value> </block> </value> </block> </value> - <value name="B"> - <block type="logic_operation" id="?A+N_1,#}@kRY%dxQMa9" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_compare" id="`~AJbhHRzn/)DgR4fRI;"> - <field name="OP">NEQ</field> + <statement name="DO0"> + <block type="controls_if" id="KJ#o$M|scI;Nb]boFDzc"> + <mutation elseif="1" else="1"/> + <value name="IF0"> + <block type="logic_compare" id="Hvw%^q~Hu5/N%}1^$97E"> + <field name="OP">LT</field> <value name="A"> - <block type="lists_getIndex" id="wBVqviD0-D3E`(V(uiV~"> + <block type="lists_getIndex" id="XiNY`%tpd`~0oRax[?wl"> <mutation statement="false" at="true"/> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> - <block type="variables_get" id="?uA|$zvDe+x4kMz%-{d."> + <block type="variables_get" id="]Pnwg,R0`8-u%~|{ySI)"> <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> </block> </value> <value name="AT"> - <block type="math_number" id="3~ZXLDV~ZSV8RX_^%[6]"> + <block type="math_number" id=",`#W`9DPbV_Z3Ay]AI7y"> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> - <block type="logic_null" id="vG[m`V+N^1KjrN:te9QO"/> + <block type="variables_get" id=")Y^E1(LwkP6u5Zr]E#v/"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> </value> </block> </value> - <value name="B"> - <block type="logic_compare" id=";P}d!ou6kF,_]Y}2c}oU"> - <field name="OP">NEQ</field> + <statement name="DO0"> + <block type="procedures_callnoreturn" id="/Dyv@Uq8HyBO`zJkGf%H" inline="true"> + <mutation name="sideleft_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="0~3b0e(US%D-.mrk9B9]"> + <field name="NUM">180</field> + </block> + </value> + </block> + </statement> + <value name="IF1"> + <block type="logic_compare" id="nUbsUlJ45(hnk!)6CNAr"> + <field name="OP">GT</field> <value name="A"> - <block type="lists_getIndex" id="9qxZzDB=dlHB#35+H*!N"> + <block type="lists_getIndex" id="yIp~#Cn:I`9g1gyN4|22"> <mutation statement="false" at="true"/> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> - <block type="variables_get" id="D3C[P^f3vp}xb!,-2#r5"> + <block type="variables_get" id="tchE8Qc)Kp|9?UE;Fpe%"> <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> </block> </value> <value name="AT"> - <block type="math_number" id="@69b4byUu7@Wfx)U/;Xp"> - <field name="NUM">2</field> + <block type="math_number" id="saTD#QpS5Cx+?U!E/:[:"> + <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> - <block type="logic_null" id="1@:,7WVUfe~r2),.)v7f"/> + <block type="variables_get" id="M9wjV+z*e*Hh*PspIXEY"> + <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> + </block> </value> </block> </value> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="controls_if" id="KJ#o$M|scI;Nb]boFDzc"> - <mutation elseif="3" else="1"/> - <value name="IF0"> - <block type="logic_compare" id="Hvw%^q~Hu5/N%}1^$97E"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="X1^+LJneX7N!jy6J]@;v"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id=")Y^E1(LwkP6u5Zr]E#v/"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="procedures_callnoreturn" id="/Dyv@Uq8HyBO`zJkGf%H" inline="true"> - <mutation name="sideleft_v"> - <arg name="v"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="0~3b0e(US%D-.mrk9B9]"> - <field name="NUM">180</field> - </block> - </value> - </block> - </statement> - <value name="IF1"> - <block type="logic_compare" id="nUbsUlJ45(hnk!)6CNAr"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="$Gcp.[t#1r{E5q/q(8nE"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="M9wjV+z*e*Hh*PspIXEY"> - <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> - </block> - </value> - </block> - </value> - <statement name="DO1"> - <block type="procedures_callnoreturn" id="$a(P8}p#iy{V.L*Qd5S-" inline="true"> - <mutation name="sideright_v"> - <arg name="v"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="D}g?6A6[y!i,A_?rI7vT"> - <field name="NUM">180</field> - </block> - </value> - </block> - </statement> - <value name="IF2"> - <block type="logic_compare" id="J%?mBh)[A7BsM@RD[LL5"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="pM-ticxUIK#qr]1woJ~P"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="wrIeSTCCcbSMCRhVhaRo"> - <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> - </block> - </value> - </block> - </value> - <statement name="DO2"> - <block type="procedures_callnoreturn" id="dkT`%q5FBeJ{iKupE~$b" inline="true"> - <mutation name="left"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="variables_get" id="geK2^Cu@:u4qgd~m0Nf,"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> - </block> - </value> - <value name="ARG1"> - <block type="variables_get" id="ooFsLNRl;=i~B=`Qp:SK"> - <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> - </block> - </value> - </block> - </statement> - <value name="IF3"> - <block type="logic_compare" id="|uy*q}0w4)yxY`=hg=Qx"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="PWIj/MW+jX3VAU7:T-T)"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="3KF;#Z~Ft^8{dfQ-K0-1"> - <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> - </block> - </value> - </block> - </value> - <statement name="DO3"> - <block type="procedures_callnoreturn" id="SF5C]WGRrZa8/]-iDIyL" inline="true"> - <mutation name="right"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="variables_get" id="5?@ol7,I#`PPey,AEdJN"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> - </block> - </value> - <value name="ARG1"> - <block type="variables_get" id="Y[BTA;4/ZM,mW{P}X}rz"> - <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> - </block> - </value> - </block> - </statement> - </block> - </statement> - <value name="IF1"> - <block type="logic_operation" id="Bv(kvR*xIzb%RfmRxg3N" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_compare" id="?#JnnyzAeNU`MJL^+ZOa"> - <field name="OP">NEQ</field> - <value name="A"> - <block type="variables_get" id="vft:66IZzutoOz+ig;R="> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="B"> - <block type="logic_null" id="f)RPYpZoWG5Mz!bJ?IKJ"/> - </value> - </block> - </value> - <value name="B"> - <block type="logic_compare" id="muiUUW_{}49WVL]?fJ8F"> - <field name="OP">NEQ</field> - <value name="A"> - <block type="variables_get" id="{RI1+Kc:gz]:()FPOMRR"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> - </block> - </value> - <value name="B"> - <block type="logic_null" id="7%fYG^;I?g7^n6Vy{BV5"/> - </value> - </block> - </value> - </block> - </value> - <statement name="DO1"> - <block type="controls_if" id="KvGY3!$zq%]{SYcSc[7m"> - <mutation elseif="3" else="1"/> - <value name="IF0"> - <block type="logic_compare" id="B=vu#kuU;qn.;,!Q)zvZ"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="43+{28}!O+y0#yUJ:8R)"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="AgRmYvSA6@z6mYB6@fFA"> - <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="procedures_callnoreturn" id="+EAOut)hnbN;,CctGcIN" inline="true"> - <mutation name="sideleft_v"> - <arg name="v"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="k8E(D2NZYJGR/LxfRAe`"> - <field name="NUM">180</field> + <statement name="DO1"> + <block type="procedures_callnoreturn" id="$a(P8}p#iy{V.L*Qd5S-" inline="true"> + <mutation name="sideright_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="D}g?6A6[y!i,A_?rI7vT"> + <field name="NUM">180</field> + </block> + </value> </block> - </value> + </statement> </block> </statement> <value name="IF1"> - <block type="logic_compare" id="%Sv9J|%0l}R*#ixcN^Ek"> - <field name="OP">GT</field> + <block type="logic_operation" id="Bv(kvR*xIzb%RfmRxg3N" inline="false"> + <field name="OP">AND</field> <value name="A"> - <block type="variables_get" id="gUF.?VCJ.+dlQ|PNR1eF"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + <block type="logic_compare" id="?#JnnyzAeNU`MJL^+ZOa"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="vft:66IZzutoOz+ig;R="> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="B"> + <block type="logic_null" id="f)RPYpZoWG5Mz!bJ?IKJ"/> + </value> </block> </value> <value name="B"> - <block type="variables_get" id="6nz_eq9+/Xkxe:eT^[z@"> - <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> + <block type="logic_compare" id="muiUUW_{}49WVL]?fJ8F"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="{RI1+Kc:gz]:()FPOMRR"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="logic_null" id="7%fYG^;I?g7^n6Vy{BV5"/> + </value> </block> </value> </block> </value> <statement name="DO1"> - <block type="procedures_callnoreturn" id="-JdEwEQT.ATb$i67ISiG" inline="true"> - <mutation name="sideright_v"> - <arg name="v"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="Vg6E?/KRoI+:^TRbYc~O"> - <field name="NUM">180</field> - </block> - </value> - </block> - </statement> - <value name="IF2"> - <block type="logic_compare" id="L_I_ad:9wl}-TbpYbPOj"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="@76pQj66r^uAxD,(F4/f"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="ol/ail=b}-NHf4K|Fl9J"> - <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> - </block> - </value> - </block> - </value> - <statement name="DO2"> - <block type="procedures_callnoreturn" id="V_|wVa),nGw8gHM,NPMX" inline="true"> - <mutation name="left"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="variables_get" id="@%Nu(|2.Fg]01{l,W#GY"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> - </block> - </value> - <value name="ARG1"> - <block type="variables_get" id="Y9pX#d1sri_Td5@bhaTb"> - <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> - </block> - </value> - </block> - </statement> - <value name="IF3"> - <block type="logic_compare" id="WSZ312,]FI|*3JtYdw:b"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="8R^4V:#9m8rQ=d4Vo30$"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="wr7|`R0V:O?5n;pG_oV~"> - <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> - </block> - </value> - </block> - </value> - <statement name="DO3"> - <block type="procedures_callnoreturn" id="UDr4(wRdDParoZEUs:w@" inline="true"> - <mutation name="right"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="variables_get" id="kx00*p[#V~+nhAVcJWd)"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> - </block> - </value> - <value name="ARG1"> - <block type="variables_get" id="G1i7[~dv_Aff}11SL/~X"> - <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> - </block> - </value> - </block> - </statement> - <statement name="ELSE"> - <block type="controls_if" id="1W5U1#HIVC#sFf,=}aPk"> + <block type="controls_if" id="+oz+[YfRRkvCLn10-B4d"> <mutation elseif="1" else="1"/> <value name="IF0"> - <block type="logic_compare" id="UG6JrG`G%RjgLMd^~Ql)"> - <field name="OP">GTE</field> + <block type="logic_compare" id="sFua#TKb}~WWPqj6KeIW"> + <field name="OP">LT</field> <value name="A"> - <block type="variables_get" id="plWMHX+zH[B*)Z,!PdFG"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + <block type="variables_get" id="J{E0oBqm),8kwbHyQ?=."> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> </block> </value> <value name="B"> - <block type="variables_get" id="d52]DnV:k]`,vbs2Owx@"> - <field name="VAR" id="}*jl@)UA_Hjh5rc,Gt)c">y_min</field> + <block type="variables_get" id=".ts{wyW$c]RydnDM,}dN"> + <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> </block> </value> </block> </value> <statement name="DO0"> - <block type="procedures_callnoreturn" id="op;Gb+2E6qWV#_xTw%*f" inline="true"> - <mutation name="fwd_v"> + <block type="procedures_callnoreturn" id="Ox/XsK4e~+Q~K3.6ZN=|" inline="true"> + <mutation name="left_v"> <arg name="v"/> </mutation> <value name="ARG0"> - <block type="variables_get" id="%,dj%LP)z^+F=bAaT2y4"> - <field name="VAR" id="1idj3sw*{G$j`2:II{^5">v_fast</field> + <block type="variables_get" id="Ur=9P[d2~h+UuLiecS=0"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> </block> </value> </block> </statement> <value name="IF1"> - <block type="logic_compare" id="Yr?8v,ne7CHC3J@.tG~K"> - <field name="OP">LT</field> + <block type="logic_compare" id="@i?;*nt)I.q@3:as9$CV"> + <field name="OP">GT</field> <value name="A"> - <block type="variables_get" id=".b9fq3}BRfR%4GA[G)OY"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + <block type="variables_get" id="r6YxtH4C]YX0#d={f!-G"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> </block> </value> <value name="B"> - <block type="variables_get" id="C#~[c+~*VLa)Bs#/bb8e"> - <field name="VAR" id="xjf5O*w9;IZf$n55ytVF">y_max</field> + <block type="variables_get" id="/*nplOY#VKPMyS,KOq3!"> + <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> </block> </value> </block> </value> <statement name="DO1"> - <block type="procedures_callnoreturn" id="{8;:MqS_MFU5y`-[u:mG" inline="true"> - <mutation name="fwd_v"> + <block type="procedures_callnoreturn" id="a{Dykh`c.ZHp3#QzywaK" inline="true"> + <mutation name="right_v"> <arg name="v"/> </mutation> <value name="ARG0"> - <block type="variables_get" id="aqXd,2m3/|Vs0Z|8wWEn"> - <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">speed_y</field> + <block type="variables_get" id=",KoGdtd-~NDCr4a3[S}!"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> </block> </value> </block> </statement> + <statement name="ELSE"> + <block type="controls_if" id="Bp.|BTULdy(,]aAoN,l["> + <mutation elseif="2" else="1"/> + <value name="IF0"> + <block type="logic_compare" id="Y-Fctm`Flpx7MN)@x%-u"> + <field name="OP">LTE</field> + <value name="A"> + <block type="variables_get" id="=t4?53|MsS#r1P:M`ZP4"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="nkMArfis6_;l59N|,9yJ"> + <field name="VAR" id="}*jl@)UA_Hjh5rc,Gt)c">y_ball_far</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="procedures_callnoreturn" id="n=@SEs?8o@WHm;Ad7A2k" inline="true"> + <mutation name="fwd_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="fZlf#E.-0%/`U+X#~UvW"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + </block> + </value> + </block> + </statement> + <value name="IF1"> + <block type="logic_compare" id="!r4f:gx)bYp.aGG:gEck"> + <field name="OP">LTE</field> + <value name="A"> + <block type="variables_get" id="t$DoS#o~XI)VEHk9e7sN"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="lEUT-.WcN]l3/82:-voJ"> + <field name="VAR" id="09n]XF2CKURQs)nHOfam">y_ball_near</field> + </block> + </value> + </block> + </value> + <statement name="DO1"> + <block type="text_print" id="Q{ZCYfb|6,V:pY*E_~o:"> + <value name="TEXT"> + <shadow type="text" id="t!h(B6qXqJ1~!1X~UsG%"> + <field name="TEXT">turn</field> + </shadow> + </value> + <next> + <block type="procedures_callnoreturn" id="5?xr%Un4{ZZP/*kbTrS4"> + <mutation name="turnBallLeft"/> + </block> + </next> + </block> + </statement> + <value name="IF2"> + <block type="logic_compare" id="O3!qDGS(I#FcP9l5t9T!"> + <field name="OP">LTE</field> + <value name="A"> + <block type="variables_get" id="a_^h(hS^A_Nr^XWwIDo9"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="cgnlj~O=P[`vJ5ggLQ{z"> + <field name="VAR" id="xjf5O*w9;IZf$n55ytVF">y_ball_touch</field> + </block> + </value> + </block> + </value> + <statement name="DO2"> + <block type="text_print" id="-QNu$mGl!qCxqMjTX:`~"> + <value name="TEXT"> + <shadow type="text" id="be.9t#Dm^sd1QKvcb~,z"> + <field name="TEXT">touch</field> + </shadow> + </value> + </block> + </statement> + </block> + </statement> </block> - </statement> - </block> - </statement> - <statement name="ELSE"> - <block type="procedures_callnoreturn" id="~e,9WDXasUar9~[eQ#bq" inline="true"> - <mutation name="left_v"> - <arg name="v"/> - </mutation> - <value name="ARG0"> - <block type="variables_get" id="a6~lQO=iKTa%P$.9vwF`"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> - </block> - </value> - </block> - </statement> - </block> - </statement> - <next> - <block type="display_set_label_text" id="QDZ)v?E3iW-Liq4HKvUn"> - <field name="instance_name">txt_label_ball</field> - <value name="value"> - <shadow type="text" id="B`M|)AOBioxQGjue#9y^"> - <field name="TEXT">abc</field> - </shadow> - <block type="text_format" id="bMzX7EzL+}J^dowK5pv|"> - <mutation items="2"/> - <value name="value"> - <shadow type="text" id="(C2/oN~6=q7Bw[A5`Pz)"> - <field name="TEXT">x:{}, y:{}</field> - </shadow> - </value> - <value name="ADD0"> - <block type="variables_get" id="N3bK$!XutDL@t?7tqOnB"> - <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> - </block> - </value> - <value name="ADD1"> - <block type="variables_get" id="CIUI@k|{^~}vfJeTSYP2"> - <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </statement> + <value name="IF2"> + <block type="logic_boolean" id="xuIk1@=PZ@V7jq%*R5t%"> + <field name="BOOL">FALSE</field> </block> </value> + <statement name="DO2"> + <block type="controls_if" id="KvGY3!$zq%]{SYcSc[7m"> + <mutation elseif="3" else="1"/> + <value name="IF0"> + <block type="logic_compare" id="B=vu#kuU;qn.;,!Q)zvZ"> + <field name="OP">LT</field> + <value name="A"> + <block type="lists_getIndex" id="+P.a$BTLIN[F|%}FN$_F"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="variables_get" id="dZ4u4Y]208l5,n^p/=qf"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="_d5c3vTK-dt?#mV]X%D/"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="variables_get" id="AgRmYvSA6@z6mYB6@fFA"> + <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="procedures_callnoreturn" id="+EAOut)hnbN;,CctGcIN" inline="true"> + <mutation name="sideleft_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="k8E(D2NZYJGR/LxfRAe`"> + <field name="NUM">180</field> + </block> + </value> + </block> + </statement> + <value name="IF1"> + <block type="logic_compare" id="%Sv9J|%0l}R*#ixcN^Ek"> + <field name="OP">GT</field> + <value name="A"> + <block type="lists_getIndex" id="fJJ$CZG+EKmA[pAj?`{)"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="variables_get" id="dF-xGlJu@cqC3pN_9/V5"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + <value name="AT"> + <block type="math_number" id="br`CrQ/t+;jQG-ikq;i{"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="variables_get" id="6nz_eq9+/Xkxe:eT^[z@"> + <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> + </block> + </value> + </block> + </value> + <statement name="DO1"> + <block type="procedures_callnoreturn" id="-JdEwEQT.ATb$i67ISiG" inline="true"> + <mutation name="sideright_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="Vg6E?/KRoI+:^TRbYc~O"> + <field name="NUM">180</field> + </block> + </value> + </block> + </statement> + <value name="IF2"> + <block type="logic_compare" id="L_I_ad:9wl}-TbpYbPOj"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id="@76pQj66r^uAxD,(F4/f"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="ol/ail=b}-NHf4K|Fl9J"> + <field name="VAR" id="Ym/+Qo0YZe25;%N1d!*f">x_min</field> + </block> + </value> + </block> + </value> + <statement name="DO2"> + <block type="procedures_callnoreturn" id="V_|wVa),nGw8gHM,NPMX" inline="true"> + <mutation name="left"> + <arg name="v"/> + <arg name="ticks"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="@%Nu(|2.Fg]01{l,W#GY"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + </block> + </value> + <value name="ARG1"> + <block type="variables_get" id="Y9pX#d1sri_Td5@bhaTb"> + <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> + </block> + </value> + </block> + </statement> + <value name="IF3"> + <block type="logic_compare" id="WSZ312,]FI|*3JtYdw:b"> + <field name="OP">GT</field> + <value name="A"> + <block type="variables_get" id="8R^4V:#9m8rQ=d4Vo30$"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="wr7|`R0V:O?5n;pG_oV~"> + <field name="VAR" id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</field> + </block> + </value> + </block> + </value> + <statement name="DO3"> + <block type="procedures_callnoreturn" id="UDr4(wRdDParoZEUs:w@" inline="true"> + <mutation name="right"> + <arg name="v"/> + <arg name="ticks"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="kx00*p[#V~+nhAVcJWd)"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + </block> + </value> + <value name="ARG1"> + <block type="variables_get" id="G1i7[~dv_Aff}11SL/~X"> + <field name="VAR" id="AnbD2s`i`niJf7bj:WR.">dist_x</field> + </block> + </value> + </block> + </statement> + <statement name="ELSE"> + <block type="controls_if" id="1W5U1#HIVC#sFf,=}aPk"> + <mutation elseif="1" else="1"/> + <value name="IF0"> + <block type="logic_compare" id="UG6JrG`G%RjgLMd^~Ql)"> + <field name="OP">GTE</field> + <value name="A"> + <block type="variables_get" id="plWMHX+zH[B*)Z,!PdFG"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="d52]DnV:k]`,vbs2Owx@"> + <field name="VAR" id="}*jl@)UA_Hjh5rc,Gt)c">y_ball_far</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="procedures_callnoreturn" id="op;Gb+2E6qWV#_xTw%*f" inline="true"> + <mutation name="fwd_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="%,dj%LP)z^+F=bAaT2y4"> + <field name="VAR" id="1idj3sw*{G$j`2:II{^5">v_fast</field> + </block> + </value> + </block> + </statement> + <value name="IF1"> + <block type="logic_compare" id="Yr?8v,ne7CHC3J@.tG~K"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id=".b9fq3}BRfR%4GA[G)OY"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="C#~[c+~*VLa)Bs#/bb8e"> + <field name="VAR" id="xjf5O*w9;IZf$n55ytVF">y_ball_touch</field> + </block> + </value> + </block> + </value> + <statement name="DO1"> + <block type="procedures_callnoreturn" id="{8;:MqS_MFU5y`-[u:mG" inline="true"> + <mutation name="fwd_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="aqXd,2m3/|Vs0Z|8wWEn"> + <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">speed_y</field> + </block> + </value> + </block> + </statement> + </block> + </statement> + </block> + </statement> + <statement name="ELSE"> + <block type="procedures_callnoreturn" id="~e,9WDXasUar9~[eQ#bq" inline="true"> + <mutation name="left_v"> + <arg name="v"/> + </mutation> + <value name="ARG0"> + <block type="variables_get" id="a6~lQO=iKTa%P$.9vwF`"> + <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + </block> + </value> + </block> + </statement> </block> - </value> + </statement> <next> - <block type="display_set_label_text" id="2Ac72_SmdOYaC#|w[dk%"> - <field name="instance_name">txt_label_goal</field> + <block type="display_set_label_text" id="QDZ)v?E3iW-Liq4HKvUn"> + <field name="instance_name">txt_label_ball</field> <value name="value"> - <shadow type="text"> + <shadow type="text" id="B`M|)AOBioxQGjue#9y^"> <field name="TEXT">abc</field> </shadow> - <block type="text_format" id="xXJlH+s%1,D1WcfOkt#6"> - <mutation items="1"/> + <block type="text_format" id="bMzX7EzL+}J^dowK5pv|"> + <mutation items="2"/> <value name="value"> - <shadow type="text" id=":(AhX7mg_fQeOGz*xR@g"> - <field name="TEXT">x:{}</field> + <shadow type="text" id="(C2/oN~6=q7Bw[A5`Pz)"> + <field name="TEXT">x:{}, y:{}</field> </shadow> </value> <value name="ADD0"> - <block type="variables_get" id="ppSdz+]@cvkJ)r-5HdD^"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + <block type="variables_get" id="N3bK$!XutDL@t?7tqOnB"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="CIUI@k|{^~}vfJeTSYP2"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> </block> </value> </block> </value> <next> - <block type="util_wait_for" id="U4XL;U0gG@tD~]*kp|L{"> - <field name="format">ms</field> + <block type="display_set_label_text" id="2Ac72_SmdOYaC#|w[dk%"> + <field name="instance_name">txt_label_goal</field> <value name="value"> - <shadow type="math_number" id="E9K@*OZ(Ftp5CGt}.9cT"> - <field name="NUM">100</field> + <shadow type="text"> + <field name="TEXT">abc</field> </shadow> + <block type="text_format" id="xXJlH+s%1,D1WcfOkt#6"> + <mutation items="1"/> + <value name="value"> + <shadow type="text" id=":(AhX7mg_fQeOGz*xR@g"> + <field name="TEXT">x:{}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="ppSdz+]@cvkJ)r-5HdD^"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal</field> + </block> + </value> + </block> </value> + <next> + <block type="util_wait_for" id="U4XL;U0gG@tD~]*kp|L{"> + <field name="format">ms</field> + <value name="value"> + <shadow type="math_number" id="E9K@*OZ(Ftp5CGt}.9cT"> + <field name="NUM">10</field> + </shadow> + </value> + </block> + </next> </block> </next> </block> @@ -665,9 +807,9 @@ </block> </next> </block> - </next> + </statement> </block> - </statement> + </next> </block> </next> </block> @@ -691,9 +833,155 @@ </block> </next> </block> - </next> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="2455"> + <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> - </next> + </statement> </block> </next> </block> @@ -701,7 +989,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="2039"> + <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="2908"> <field name="instance_name">ball_detector</field> <statement name="statement"> <block type="variables_set" id="=2/,IQfcLO{_5PNd3UK~"> @@ -831,7 +1119,7 @@ <mutation items="4"/> <value name="value"> <shadow type="text" id="l2A3xrw.^!j6.QD:k]?b"> - <field name="TEXT">posx:{} posy:{} dist_x:{} speed_y:{}</field> + <field name="TEXT">ball posx:{} posy:{} dist_x:{} speed_y:{}</field> </shadow> </value> <value name="ADD0"> @@ -875,7 +1163,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="2600"> + <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="3469"> <field name="instance_name">ball_detector_goal_left</field> <statement name="statement"> <block type="variables_set" id="kvK,D4e%04[?+!jq*Lch"> @@ -946,7 +1234,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="2861"> + <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="3730"> <field name="instance_name">ball_detector_goal_right</field> <statement name="statement"> <block type="variables_set" id="0!1?#@4|tcM8+U6E[$Tl"> @@ -1017,153 +1305,7 @@ </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"> + <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="3991"> <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> @@ -1173,10 +1315,20 @@ <statement name="statement"> <block type="procedures_callnoreturn" id="5g}yP+C``b}R[T#xBtg|"> <mutation name="shotBall"/> + <next> + <block type="util_wait_for" id="@8txnh!Ya]x^TH^rCQ[`"> + <field name="format">s</field> + <value name="value"> + <shadow type="math_number" id="~EE*}gb]K3*yvGqjvkYb"> + <field name="NUM">5</field> + </shadow> + </value> + </block> + </next> </block> </statement> </block> - <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="3684"> + <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" collapsed="true" x="0" y="4128"> <field name="NAME">shotBall</field> <statement name="STACK"> <block type="servomotor_set_position" id="9C*rGH2+bsy8H4Xzz#gk"> @@ -1290,7 +1442,19 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" collapsed="true" x="0" y="4242"> + <block type="procedures_defnoreturn" id="+FKt%DE[[q%Zp0T.Fn}d" collapsed="true" x="0" y="4195"> + <field name="NAME">stop</field> + <statement name="STACK"> + <block type="encodermotor_stop" id="}]1#.xeDc*.k9aGX5P?4"> + <mutation syncBlocks="3"/> + <field name="instance_name_0">TXT_M_M1_encodermotor</field> + <field name="instance_name_1">TXT_M_M2_encodermotor</field> + <field name="instance_name_2">TXT_M_M3_encodermotor</field> + <field name="instance_name_3">TXT_M_M4_encodermotor</field> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" collapsed="true" x="0" y="4262"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -1318,7 +1482,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" collapsed="true" x="0" y="4309"> + <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" collapsed="true" x="0" y="4329"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -1346,7 +1510,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" collapsed="true" x="0" y="4376"> + <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" collapsed="true" x="0" y="4396"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1374,19 +1538,19 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" collapsed="true" x="0" y="4443"> + <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" collapsed="true" x="0" y="4463"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> - <field name="NAME">sideleft_v</field> + <field name="NAME">right_v</field> <field name=",q%qjDTJ~Z@[BoMwORuq">v</field> <statement name="STACK"> - <block type="encodermotor_set_speed" id="pLk^0]/}JZa5O5XBdTkw"> + <block type="encodermotor_set_speed" id="nx1gdpc@IPQ^`H:CbI[*"> <mutation syncBlocks="3"/> <field name="instance_name_0">TXT_M_M1_encodermotor</field> - <field name="direction_0">Motor.CCW</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="direction_1">Motor.CCW</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> @@ -1395,26 +1559,26 @@ <shadow type="motor_number"> <field name="MOTOR_NUM">512</field> </shadow> - <block type="variables_get" id="+]RiX%o.`5?mErIL~B$V"> + <block type="variables_get" id="$@n1C^pw7z*pgx,V+kbX"> <field name="VAR" id="DfDz@$]?^P=(6r:%^xC*">v</field> </block> </value> </block> </statement> </block> - <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" collapsed="true" x="0" y="4510"> + <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" collapsed="true" x="0" y="4530"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> - <field name="NAME">right_v</field> + <field name="NAME">sideleft_v</field> <field name=",q%qjDTJ~Z@[BoMwORuq">v</field> <statement name="STACK"> - <block type="encodermotor_set_speed" id="nx1gdpc@IPQ^`H:CbI[*"> + <block type="encodermotor_set_speed" id="pLk^0]/}JZa5O5XBdTkw"> <mutation syncBlocks="3"/> <field name="instance_name_0">TXT_M_M1_encodermotor</field> - <field name="direction_0">Motor.CW</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="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> @@ -1423,14 +1587,14 @@ <shadow type="motor_number"> <field name="MOTOR_NUM">512</field> </shadow> - <block type="variables_get" id="$@n1C^pw7z*pgx,V+kbX"> + <block type="variables_get" id="+]RiX%o.`5?mErIL~B$V"> <field name="VAR" id="DfDz@$]?^P=(6r:%^xC*">v</field> </block> </value> </block> </statement> </block> - <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" collapsed="true" x="0" y="4577"> + <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" collapsed="true" x="0" y="4597"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -1458,19 +1622,7 @@ </block> </statement> </block> - <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"> - <mutation syncBlocks="3"/> - <field name="instance_name_0">TXT_M_M1_encodermotor</field> - <field name="instance_name_1">TXT_M_M2_encodermotor</field> - <field name="instance_name_2">TXT_M_M3_encodermotor</field> - <field name="instance_name_3">TXT_M_M4_encodermotor</field> - </block> - </statement> - </block> - <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" collapsed="true" x="0" y="4711"> + <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" collapsed="true" x="0" y="4664"> <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{"/> @@ -1536,7 +1688,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" collapsed="true" x="0" y="4778"> + <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" collapsed="true" x="0" y="4731"> <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"/> @@ -1602,7 +1754,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" collapsed="true" x="0" y="4845"> + <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" collapsed="true" x="0" y="4798"> <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"/> @@ -1668,7 +1820,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" collapsed="true" x="0" y="4912"> + <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" collapsed="true" x="0" y="4865"> <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#"/> @@ -1734,99 +1886,63 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" collapsed="true" x="0" y="4979"> - <field name="NAME">turnLeft</field> + <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="4932"> + <field name="NAME">turnBallLeft</field> <statement name="STACK"> - <block type="procedures_callnoreturn" id="n2^-(/I;nyLq_t.8g0Hh" inline="true"> - <mutation name="left"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="L]KBm_q}pUYcN_R9$Td*"> - <field name="NUM">512</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="XL@`?$Meb0G?=O^(bcN`"> - <field name="NUM">100</field> - </block> + <block type="encodermotor_set_speed" id="I[S{vjf1EdjHVhk32Irr"> + <mutation syncBlocks="1"/> + <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.CW</field> + <value name="speed"> + <shadow type="motor_number" id="KbM1XwSZ`0p4OfObK%2d"> + <field name="MOTOR_NUM">150</field> + </shadow> </value> <next> - <block type="util_wait_for" id="R(dhDnY~?k[7gqG+2x~g"> - <field name="format">s</field> - <value name="value"> - <shadow type="math_number" id="3]SXvlb7u^(WBc%.4WHy"> - <field name="NUM">2</field> + <block type="encodermotor_set_speed" id="?-}PDl2[=K?(SrBgJg-U"> + <mutation syncBlocks="1"/> + <field name="instance_name_0">TXT_M_M3_encodermotor</field> + <field name="direction_0">Motor.CW</field> + <field name="instance_name_1">TXT_M_M4_encodermotor</field> + <field name="direction_1">Motor.CCW</field> + <value name="speed"> + <shadow type="motor_number" id="=efoF`lj-~A7g]Ka]qr."> + <field name="MOTOR_NUM">512</field> </shadow> </value> - <next> - <block type="procedures_callnoreturn" id="BSxVt0)n-UE(][{}Zt;^" inline="true"> - <mutation name="right"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="hv[6sv=-hB.R^tw#]Gz="> - <field name="NUM">512</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="P]X~f;N4(]+(%xPouOI7"> - <field name="NUM">100</field> - </block> - </value> - </block> - </next> </block> </next> </block> </statement> </block> - <block type="procedures_defnoreturn" id="$nY7HNz^i}wlpk/f(Dja" collapsed="true" x="0" y="5046"> - <field name="NAME">turnRight</field> + <block type="procedures_defnoreturn" id="*i[s2YTWD*g9HS4dxkPq" x="0" y="5125"> + <field name="NAME">turnBallRight</field> <statement name="STACK"> - <block type="procedures_callnoreturn" id="%_T=@p6r8~Uq5{@hAFr2" inline="true"> - <mutation name="right"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="bw3[f)0Q(9PF,!}X!x{/"> - <field name="NUM">512</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="+5OU#:=YOM`vK{]flY`%"> - <field name="NUM">100</field> - </block> + <block type="encodermotor_set_speed" id="c8~SXys:o35ETKj;GX?m"> + <mutation syncBlocks="1"/> + <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.CCW</field> + <value name="speed"> + <shadow type="motor_number" id="dD.1u9Pwx-^rnKZyWQx/"> + <field name="MOTOR_NUM">150</field> + </shadow> </value> <next> - <block type="util_wait_for" id="/W7.[SC_c4y$_}LjB86s"> - <field name="format">s</field> - <value name="value"> - <shadow type="math_number" id="6;@I%dFl,h,%#D)ZIbaq"> - <field name="NUM">2</field> + <block type="encodermotor_set_speed" id="b:w42I;ulm2~l(S-#ER("> + <mutation syncBlocks="1"/> + <field name="instance_name_0">TXT_M_M3_encodermotor</field> + <field name="direction_0">Motor.CCW</field> + <field name="instance_name_1">TXT_M_M4_encodermotor</field> + <field name="direction_1">Motor.CW</field> + <value name="speed"> + <shadow type="motor_number" id=";zG8,Fnh@=jNAT#Br68/"> + <field name="MOTOR_NUM">512</field> </shadow> </value> - <next> - <block type="procedures_callnoreturn" id="YGQ{1/dmc!iFfIy.x/2m" inline="true"> - <mutation name="left"> - <arg name="v"/> - <arg name="ticks"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="OMM56z]B8;G//6yQPVOc"> - <field name="NUM">512</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="=Y*_@^k,{$YH-`gO^nSk"> - <field name="NUM">100</field> - </block> - </value> - </block> - </next> </block> </next> </block> diff --git a/omniwheels_x4_soccer_goal.py b/omniwheels_x4_soccer_goal.py index b19ca943b301ef258ddd89a25a7e33bc746212e1..3614165f589286f5fee460add7fd2c9c983cb0bc 100644 --- a/omniwheels_x4_soccer_goal.py +++ b/omniwheels_x4_soccer_goal.py @@ -16,17 +16,18 @@ ts_goal_right = None factor_y = None posx_ball = None dist_x = None -speed_y = None +x_min = None posy_ball = None +speed_y = None posx_goal = None -x_min = None x_max = None -y_min = None -y_max = None +y_ball_far = None +y_ball_near = None +y_ball_touch = None v_slow = None v_fast = None def checkTimeouts(): - 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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if (time.time() * 1000) - ts_ball > 500: posx_ball = None posy_ball = None @@ -38,19 +39,19 @@ def checkTimeouts(): def ball_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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast ts_ball = (time.time() * 1000) dist_x = round(math.fabs(event.value.x) * factor_x) speed_y = round(min(max(math.fabs(event.value.y) * factor_y + v_slow, 0), 512)) posx_ball = event.value.x posy_ball = event.value.y - print('posx:{} posy:{} dist_x:{} speed_y:{}'.format(event.value.x, event.value.y, dist_x, speed_y)) + print('ball posx:{} posy:{} dist_x:{} speed_y:{}'.format(event.value.x, event.value.y, dist_x, speed_y)) ball_detector.add_detection_listener(ball_callback) def ball_callback2(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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast ts_goal_left = (time.time() * 1000) posx_goal[0] = event.value.x print('goal left: posx:{} posy:{}'.format(event.value.x, event.value.y)) @@ -59,7 +60,7 @@ ball_detector_goal_left.add_detection_listener(ball_callback2) def ball_callback23(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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast ts_goal_right = (time.time() * 1000) posx_goal[1] = event.value.x print('goal right: posx:{} posy:{}'.format(event.value.x, event.value.y)) @@ -68,16 +69,17 @@ 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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if TXT_M_I8_photo_transistor.is_dark(): shotBall() + time.sleep(5) 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 + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, 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) @@ -106,8 +108,13 @@ def shotBall(): time.sleep(0.010) +def stop(): + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast + TXT_M_M1_encodermotor.stop_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) + + 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 + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW) @@ -116,7 +123,7 @@ def fwd_v(v): def bwd_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 + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW) @@ -125,7 +132,7 @@ def bwd_v(v): def left_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 + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW) @@ -133,26 +140,26 @@ def left_v(v): TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) -def sideleft_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) - TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) +def right_v(v): + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast + TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) + TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) -def right_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.CW) - TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) +def sideleft_v(v): + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast + TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) + TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) def sideright_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 + global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW) @@ -160,13 +167,8 @@ def sideright_v(v): TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) -def stop(): - 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_M1_encodermotor.stop_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor) - - def fwd(v, ticks): - global 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 + global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if ticks > 0: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) @@ -180,7 +182,7 @@ def fwd(v, ticks): def bwd(v, ticks): - global 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 + global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if ticks > 0: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) @@ -194,7 +196,7 @@ def bwd(v, ticks): def left(v, ticks): - global 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 + global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if ticks > 0: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW) @@ -208,7 +210,7 @@ def left(v, ticks): def right(v, ticks): - global 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 + global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast if ticks > 0: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW) @@ -221,29 +223,36 @@ def right(v, ticks): time.sleep(0.010) -def turnLeft(): - 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 - left(512, 100) - time.sleep(2) - right(512, 100) +def turnBallLeft(): + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast + TXT_M_M1_encodermotor.set_speed(int(150), Motor.CCW) + TXT_M_M2_encodermotor.set_speed(int(150), Motor.CW) + TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor) + TXT_M_M3_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M4_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M3_encodermotor.start_sync(TXT_M_M4_encodermotor) -def turnRight(): - 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 - right(512, 100) - time.sleep(2) - left(512, 100) +def turnBallRight(): + global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, posx_ball, dist_x, x_min, posy_ball, speed_y, posx_goal, x_max, y_ball_far, y_ball_near, y_ball_touch, v_slow, v_fast + TXT_M_M1_encodermotor.set_speed(int(150), Motor.CW) + TXT_M_M2_encodermotor.set_speed(int(150), Motor.CCW) + TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor) + TXT_M_M3_encodermotor.set_speed(int(512), Motor.CCW) + TXT_M_M4_encodermotor.set_speed(int(512), Motor.CW) + TXT_M_M3_encodermotor.start_sync(TXT_M_M4_encodermotor) factor_x = 0.2 factor_y = 3.5 -speed_y = 300 x_min = -3 x_max = 3 -y_min = 7 -y_max = 74 -v_slow = 300 +y_ball_far = 7 +y_ball_near = 50 +y_ball_touch = 74 +v_slow = 200 v_fast = 512 +speed_y = 512 posx_goal = [None, None] posx_ball = None posy_ball = None @@ -254,29 +263,40 @@ while True: checkTimeouts() if display.get_attr("txt_switch_active.checked"): if posx_ball != None and posy_ball != None and posx_goal[0] != None and posx_goal[1] != None: - if posx_goal < posx_ball: + if posx_goal[0] < posx_ball: sideleft_v(180) - elif posx_goal > x_max: + elif posx_goal[0] > x_max: sideright_v(180) - elif posx_ball < x_min: - left(v_slow, dist_x) - elif posx_ball > x_max: - right(v_slow, dist_x) else: pass elif posx_ball != None and posy_ball != None: - if posx_goal < x_min: + if posx_ball < x_min: + left_v(v_slow) + elif posx_ball > x_max: + right_v(v_slow) + else: + if posy_ball <= y_ball_far: + fwd_v(v_slow) + elif posy_ball <= y_ball_near: + print('turn') + turnBallLeft() + elif posy_ball <= y_ball_touch: + print('touch') + else: + pass + elif False: + if posx_goal[0] < x_min: sideleft_v(180) - elif posx_goal > x_max: + elif posx_goal[0] > x_max: sideright_v(180) elif posx_ball < x_min: left(v_slow, dist_x) elif posx_ball > x_max: right(v_slow, dist_x) else: - if posy_ball >= y_min: + if posy_ball >= y_ball_far: fwd_v(v_fast) - elif posy_ball < y_max: + elif posy_ball < y_ball_touch: fwd_v(speed_y) else: pass @@ -284,6 +304,6 @@ while True: left_v(v_slow) display.set_attr("txt_label_ball.text", str('x:{}, y:{}'.format(posx_ball, posy_ball))) display.set_attr("txt_label_goal.text", str('x:{}'.format(posx_goal))) - time.sleep(0.1) + time.sleep(0.01)