diff --git a/lib/camera.py b/lib/camera.py index 43e038cfc2ac6e0d1da1c1d2e5e17cbbb1f154f5..397eb0dec0fbe164fb438d3d890999eb995ae72e 100644 --- a/lib/camera.py +++ b/lib/camera.py @@ -8,7 +8,7 @@ TXT_M_USB_1_camera.set_width(320) TXT_M_USB_1_camera.set_fps(15) TXT_M_USB_1_camera.start() -ball_detector = txt_factory.camera_factory.create_ball_detector(0, 0, 320, 240, 5, 80, -100, 100, [200,113,52], 20) +ball_detector = txt_factory.camera_factory.create_ball_detector(0, 0, 320, 240, 5, 80, -100, 100, [223,151,123], 20) TXT_M_USB_1_camera.add_detector(ball_detector) blocked_area_right = txt_factory.camera_factory.create_blocked_area(240, 190, 80, 50) @@ -20,6 +20,6 @@ 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, [183,137,26], 20) 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, [57,117,47], 20) +ball_detector_goal_left = txt_factory.camera_factory.create_ball_detector(0, 70, 320, 120, 10, 120, -100, 100, [109,152,108], 20) TXT_M_USB_1_camera.add_detector(ball_detector_goal_left) diff --git a/lib/camera.xml b/lib/camera.xml index 7d01b6909a65664fcb386d9d235cb04a6514dedd..beff0a7931c664e0bbdd606075a4d0823eaf03c1 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>#c87134</color><tolerance>20</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>#b7891a</color><tolerance>20</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>#39752f</color><tolerance>20</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>#df977b</color><tolerance>20</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>#b7891a</color><tolerance>20</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>#6d986c</color><tolerance>20</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 477ad3f11e5a5a3f18846aaa289724796c897a01..7b6c451feca2bf20aaf82360abd99fb1869ae04f 100644 --- a/lib/display.qml +++ b/lib/display.qml @@ -12,14 +12,14 @@ TXTWindow { anchors.fill: parent } TXTSwitch { - id: txt_switch_active - text: "START" + id: txt_switch_ball + text: "" font.pixelSize: 16 enabled: true - checked: true - x: 60 - y: 178 - width: 100 + checked: false + x: 170 + y: 10 + width: 60 height: 40 } TXTLabel { @@ -27,49 +27,77 @@ TXTWindow { text: "-" font.pixelSize: 16 elide: Text.ElideRight - x: 60 - y: 20 - width: 179 + x: 50 + y: 10 + width: 120 height: 40 } TXTLabel { - id: txt_label_goal + id: txt_label_goal_left text: "-" font.pixelSize: 16 elide: Text.ElideRight - x: 60 - y: 80 - width: 180 + x: 50 + y: 70 + width: 120 height: 40 } TXTLabel { - id: txt_label_ball_ - text: "ball" + id: txt_label_goal_right + text: "-" font.pixelSize: 16 elide: Text.ElideRight + x: 50 + y: 110 + width: 120 + height: 40 + } + StatusIndicator { + id: txt_status_indicator_ball + color: "#FFB700" + active: false x: 20 y: 20 - width: 40 - height: 40 + width: 20 + height: 20 } - TXTLabel { - id: txt_label_goal_ - text: "goal" - font.pixelSize: 16 - elide: Text.ElideRight + StatusIndicator { + id: txt_status_indicator_goal_left + color: "#19FF00" + active: false x: 20 y: 80 - width: 40 + width: 20 + height: 20 + } + StatusIndicator { + id: txt_status_indicator_goal_right + color: "#F8FF00" + active: false + x: 20 + y: 120 + width: 20 + height: 20 + } + TXTSwitch { + id: txt_switch_goal + text: "" + font.pixelSize: 16 + enabled: true + checked: false + x: 170 + y: 150 + width: 60 height: 40 } TXTLabel { - id: txt_label_goal_x + id: txt_label_goal_both text: "-" font.pixelSize: 16 elide: Text.ElideRight - x: 60 - y: 120 - width: 180 + x: 50 + y: 150 + width: 120 height: 40 } } diff --git a/lib/display.xml b/lib/display.xml index 503a00da799e0faf73aa49e84651de3f0e989b20..d8eb86d35322b0c7efa0102ddea90095a951d0ab 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>true</checked><text>START</text><geometry><x>60</x><y>178</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>20</y><width>179</width><height>40</height></geometry></item><item id="6" class="TXTLabel"><name>txt_label_goal</name><text>-</text><geometry><x>60</x><y>80</y><width>180</width><height>40</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label_ball_</name><text>ball</text><geometry><x>20</x><y>20</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>80</y><width>40</width><height>40</height></geometry></item><item id="10" class="TXTLabel"><name>txt_label_goal_x</name><text>-</text><geometry><x>60</x><y>120</y><width>180</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_ball</name><enabled>true</enabled><checked>false</checked><text/><geometry><x>170</x><y>10</y><width>60</width><height>40</height></geometry></item><item id="5" class="TXTLabel"><name>txt_label_ball</name><text>-</text><geometry><x>50</x><y>10</y><width>120</width><height>40</height></geometry></item><item id="6" class="TXTLabel"><name>txt_label_goal_left</name><text>-</text><geometry><x>50</x><y>70</y><width>120</width><height>40</height></geometry></item><item id="10" class="TXTLabel"><name>txt_label_goal_right</name><text>-</text><geometry><x>50</x><y>110</y><width>120</width><height>40</height></geometry></item><item id="11" class="StatusIndicator"><name>txt_status_indicator_ball</name><color>#FFB700</color><active>false</active><geometry><x>20</x><y>20</y><width>20</width><height>20</height></geometry></item><item id="12" class="StatusIndicator"><name>txt_status_indicator_goal_left</name><color>#19FF00</color><active>false</active><geometry><x>20</x><y>80</y><width>20</width><height>20</height></geometry></item><item id="13" class="StatusIndicator"><name>txt_status_indicator_goal_right</name><color>#F8FF00</color><active>false</active><geometry><x>20</x><y>120</y><width>20</width><height>20</height></geometry></item><item id="14" class="TXTSwitch"><name>txt_switch_goal</name><enabled>true</enabled><checked>false</checked><text/><geometry><x>170</x><y>150</y><width>60</width><height>40</height></geometry></item><item id="15" class="TXTLabel"><name>txt_label_goal_both</name><text>-</text><geometry><x>50</x><y>150</y><width>120</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 0171ba07333129f8bb680f1c1f43559860ddc2e6..a0bccfcbb0cb6a4fbc47e6fd5a9c226f15305c1d 100644 --- a/omniwheels_x4_soccer_goal.blockly +++ b/omniwheels_x4_soccer_goal.blockly @@ -1,14 +1,14 @@ <xml xmlns="https://developers.google.com/blockly/xml" version="12"> <variables> + <variable id="ymkMx:g,wGvcvRtYUanL">shot</variable> <variable id="DfDz@$]?^P=(6r:%^xC*">v</variable> <variable id="l9lR0!)Laya}3RYVW(ZQ">ticks</variable> - <variable id="ymkMx:g,wGvcvRtYUanL">shot</variable> <variable id="L([~[g+MhSG}}P1bZ{oS">factor_x</variable> + <variable id="vH;^OzJY7dOdepMScU1s">state</variable> <variable id="v3eHF0atAL+ouaa{W$=m">ts_ball</variable> <variable id=";Ki:[qYaZnowqSa`]/aW">ts_goal_left</variable> <variable id="z^z{Ev+IMfS6[W1raY;l">ts_goal_right</variable> <variable id="fPH`.@]riH+=v{,A)bP5">cmd</variable> - <variable id="vH;^OzJY7dOdepMScU1s">state</variable> <variable id="S~)Q:X5BHfQZe.ZJfdE)">factor_y</variable> <variable id="v0BvP7[91TGaMpQG$r0f">goal_width</variable> <variable id="S4.mduNQC(va3iR{oSdB">posx_ball</variable> @@ -20,12 +20,12 @@ <variable id="a8;eFhj+gj?)7exUyU;p">posy_goal_left</variable> <variable id="+j/X+RCIMajR28(u#7DG">posy_goal_right</variable> <variable id="2G]XEQ3Lhl$dG]=:]8Ge">x_max</variable> - <variable id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</variable> <variable id=")rK_fR,m=]b(j[{.CtBj">v_slow</variable> + <variable id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</variable> <variable id="}*jl@)UA_Hjh5rc,Gt)c">y_ball_far</variable> - <variable id=";S3?%3)**s[[l~Aq3*,{">v_var_ball_ypos</variable> <variable id="1idj3sw*{G$j`2:II{^5">v_fast</variable> <variable id="xjf5O*w9;IZf$n55ytVF">y_ball_touch</variable> + <variable id=";S3?%3)**s[[l~Aq3*,{">v_var_ball_ypos</variable> <variable id="09n]XF2CKURQs)nHOfam">y_ball_near</variable> <variable id="2Lkg^#Z.uZy(%Nr[26)6">search_dir_left</variable> </variables> @@ -232,7 +232,7 @@ <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="instance_name">txt_switch_ball</field> <field name="property_name">checked</field> </block> </value> @@ -1003,179 +1003,260 @@ </block> </statement> <next> - <block type="display_set_label_text" id="QDZ)v?E3iW-Liq4HKvUn"> - <field name="instance_name">txt_label_ball</field> + <block type="display_set_status_indicator_active" id="Ol/kdywTz9GJZec|QWMS"> + <field name="instance_name">txt_status_indicator_ball</field> <value name="value"> - <shadow type="text" id="B`M|)AOBioxQGjue#9y^"> - <field name="TEXT">abc</field> + <shadow type="logic_boolean" id="C/tmfzzEp6H,:Q-Cbzm5"> + <field name="BOOL">TRUE</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"> + <block type="logic_compare" id="A*?Wn/psphIs}+%SxVmh"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="s5*njiZc=^N+p)4eIr:g"> <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 name="B"> + <block type="logic_null" id="e!/:${Wq/7lIg8.F`rU:"/> </value> </block> </value> <next> - <block type="display_set_label_text" id="2Ac72_SmdOYaC#|w[dk%"> - <field name="instance_name">txt_label_goal</field> + <block type="display_set_status_indicator_active" id="6raPw1+,67bp]Ic#!]_h"> + <field name="instance_name">txt_status_indicator_goal_left</field> <value name="value"> - <shadow type="text"> - <field name="TEXT">abc</field> + <shadow type="logic_boolean"> + <field name="BOOL">TRUE</field> </shadow> - <block type="text_format" id="xXJlH+s%1,D1WcfOkt#6"> - <mutation items="4"/> - <value name="value"> - <shadow type="text" id=":(AhX7mg_fQeOGz*xR@g"> - <field name="TEXT">left:{} {}, right:{} {}</field> - </shadow> - </value> - <value name="ADD0"> - <block type="variables_get" id="ppSdz+]@cvkJ)r-5HdD^"> + <block type="logic_compare" id="(Gd1pOPhbD[]9blVQC|s"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="d)kKqkwH4O9u46e{zBnP"> <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal_left</field> </block> </value> - <value name="ADD1"> - <block type="variables_get" id="Fe?~n3W$cZh6_K]^Dsyx"> - <field name="VAR" id="a8;eFhj+gj?)7exUyU;p">posy_goal_left</field> - </block> - </value> - <value name="ADD2"> - <block type="variables_get" id="^dcWdBa0xHuSF#~S44{U"> - <field name="VAR" id="7Tp~7_.qfmJN0SR]5p}F">posx_goal_right</field> - </block> - </value> - <value name="ADD3"> - <block type="variables_get" id="kuo|)Aebqd#k+PebfFA^"> - <field name="VAR" id="+j/X+RCIMajR28(u#7DG">posy_goal_right</field> - </block> + <value name="B"> + <block type="logic_null" id="/s%hwOAf=LC]:$PjiZy?"/> </value> </block> </value> <next> - <block type="display_set_label_text" id="Fn{?O{el^_@qD+)BLOev"> - <field name="instance_name">txt_label_goal_x</field> + <block type="display_set_status_indicator_active" id="^O{W3G$em_v6~A^t1K$]"> + <field name="instance_name">txt_status_indicator_goal_right</field> <value name="value"> - <shadow type="text" id="}wMC[[!{mYT9LBcx}EtT"> - <field name="TEXT">abc</field> + <shadow type="logic_boolean"> + <field name="BOOL">TRUE</field> </shadow> - <block type="text_format" id="zV,[,3k$`H2B5D[4-c.d"> - <mutation items="2"/> - <value name="value"> - <shadow type="text" id="pLr%-2L|$X9_^)k~m;J("> - <field name="TEXT">p:{}, w:{}</field> - </shadow> - </value> - <value name="ADD0"> - <block type="variables_get" id="1/;a8^BqFI^^?=Ea;HdL"> - <field name="VAR" id="{]]L-TSC^#XtGnVinxf[">posx_goal_both</field> + <block type="logic_compare" id="2S2X?GGT8}tBgMGb3x=["> + <field name="OP">NEQ</field> + <value name="A"> + <block type="variables_get" id="4yKol;}{*yD|UJzvYN83"> + <field name="VAR" id="7Tp~7_.qfmJN0SR]5p}F">posx_goal_right</field> </block> </value> - <value name="ADD1"> - <block type="variables_get" id="CD]^^%xF/1z=fT)6mSMr"> - <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> - </block> + <value name="B"> + <block type="logic_null" id="?MiF_jh!]il%Rhf3lN~~"/> </value> </block> </value> <next> - <block type="text_print" id="##1hG%c^2!NKjN~e1lyg"> - <value name="TEXT"> - <shadow type="text" id="p_E`2=Fj^pN,D}gxPEvW"> - <field name="TEXT"/> + <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="mB*d7.SSna@S_Ds5Y4[o"> - <mutation items="12"/> + <block type="text_format" id="bMzX7EzL+}J^dowK5pv|"> + <mutation items="2"/> <value name="value"> - <shadow type="text" id="a{L7ErJR}=Flx|}3~+X4"> - <field name="TEXT">{}:{} GOAL left: {} {}, right:{} {}, p:{}, w:{} BALL_pos:{},{} v_x:{} v_y:{}</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="UGc[vu*b~9D^!p.3?7mo"> - <field name="VAR" id="vH;^OzJY7dOdepMScU1s">state</field> - </block> - </value> - <value name="ADD1"> - <block type="variables_get" id="wVt[k#I:X+:T`RVkRf]K"> - <field name="VAR" id="fPH`.@]riH+=v{,A)bP5">cmd</field> - </block> - </value> - <value name="ADD2"> - <block type="variables_get" id="+?O{K7(C)vw`Y6!T4L(o"> - <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal_left</field> - </block> - </value> - <value name="ADD3"> - <block type="variables_get" id="kiYnqn=QqrO`bh^F{AQ#"> - <field name="VAR" id="a8;eFhj+gj?)7exUyU;p">posy_goal_left</field> - </block> - </value> - <value name="ADD4"> - <block type="variables_get" id="/(B3zJewppd~EofXj-kV"> - <field name="VAR" id="7Tp~7_.qfmJN0SR]5p}F">posx_goal_right</field> - </block> - </value> - <value name="ADD5"> - <block type="variables_get" id=",3+x;7D(bN-41WySQn.v"> - <field name="VAR" id="+j/X+RCIMajR28(u#7DG">posy_goal_right</field> - </block> - </value> - <value name="ADD6"> - <block type="variables_get" id="u$4~ei085+j]JF61p!Kz"> - <field name="VAR" id="{]]L-TSC^#XtGnVinxf[">posx_goal_both</field> - </block> - </value> - <value name="ADD7"> - <block type="variables_get" id="#umK_pdUK0;[tcAYO_7s"> - <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> - </block> - </value> - <value name="ADD8"> - <block type="variables_get" id="sPxj5C*ZzYUH*$WCe4|q"> + <block type="variables_get" id="N3bK$!XutDL@t?7tqOnB"> <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> </block> </value> - <value name="ADD9"> - <block type="variables_get" id="~vY0WPr#jWq#SxvDb1@n"> + <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> - <value name="ADD10"> - <block type="variables_get" id="r!O8lsSDk:Xs*=-;)LRu"> - <field name="VAR" id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</field> - </block> - </value> - <value name="ADD11"> - <block type="variables_get" id="`fG05b:bzq8[q?bquCg6"> - <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">v_var_ball_ypos</field> - </block> - </value> </block> </value> <next> - <block type="procedures_callnoreturn" id="O6U,(~H4n-^0fP^x)_,{"> - <mutation name="checkTimeoutsSetGoalBoth"/> + <block type="display_set_label_text" id="2Ac72_SmdOYaC#|w[dk%"> + <field name="instance_name">txt_label_goal_left</field> + <value name="value"> + <shadow type="text"> + <field name="TEXT">abc</field> + </shadow> + <block type="text_format" id="xXJlH+s%1,D1WcfOkt#6"> + <mutation items="2"/> + <value name="value"> + <shadow type="text" id=":(AhX7mg_fQeOGz*xR@g"> + <field name="TEXT">{} {}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="ppSdz+]@cvkJ)r-5HdD^"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal_left</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="Fe?~n3W$cZh6_K]^Dsyx"> + <field name="VAR" id="a8;eFhj+gj?)7exUyU;p">posy_goal_left</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="a{S3p;wE$+yu^C@/gbFc"> + <field name="instance_name">txt_label_goal_right</field> <value name="value"> - <shadow type="math_number" id="E9K@*OZ(Ftp5CGt}.9cT"> - <field name="NUM">80</field> + <shadow type="text"> + <field name="TEXT">abc</field> </shadow> + <block type="text_format" id="aM8~sP`fYChiSu}cXXcR"> + <mutation items="2"/> + <value name="value"> + <shadow type="text" id="iEm4r;N9H6ZV_0W/huA7"> + <field name="TEXT">{} {}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="86hRDB1XQ4so2N5SUnF_"> + <field name="VAR" id="7Tp~7_.qfmJN0SR]5p}F">posx_goal_right</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="%A3W)E/]zAMtqytEd%-*"> + <field name="VAR" id="+j/X+RCIMajR28(u#7DG">posy_goal_right</field> + </block> + </value> + </block> </value> + <next> + <block type="display_set_label_text" id="Fn{?O{el^_@qD+)BLOev"> + <field name="instance_name">txt_label_goal_both</field> + <value name="value"> + <shadow type="text" id="}wMC[[!{mYT9LBcx}EtT"> + <field name="TEXT">abc</field> + </shadow> + <block type="text_format" id="zV,[,3k$`H2B5D[4-c.d"> + <mutation items="2"/> + <value name="value"> + <shadow type="text" id="pLr%-2L|$X9_^)k~m;J("> + <field name="TEXT">p:{}, w:{}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="1/;a8^BqFI^^?=Ea;HdL"> + <field name="VAR" id="{]]L-TSC^#XtGnVinxf[">posx_goal_both</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="CD]^^%xF/1z=fT)6mSMr"> + <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> + </block> + </value> + </block> + </value> + <next> + <block type="text_print" id="##1hG%c^2!NKjN~e1lyg"> + <value name="TEXT"> + <shadow type="text" id="p_E`2=Fj^pN,D}gxPEvW"> + <field name="TEXT"/> + </shadow> + <block type="text_format" id="mB*d7.SSna@S_Ds5Y4[o"> + <mutation items="12"/> + <value name="value"> + <shadow type="text" id="a{L7ErJR}=Flx|}3~+X4"> + <field name="TEXT">{}:{} GOAL left: {} {}, right:{} {}, p:{}, w:{} BALL_pos:{},{} v_x:{} v_y:{}</field> + </shadow> + </value> + <value name="ADD0"> + <block type="variables_get" id="UGc[vu*b~9D^!p.3?7mo"> + <field name="VAR" id="vH;^OzJY7dOdepMScU1s">state</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="wVt[k#I:X+:T`RVkRf]K"> + <field name="VAR" id="fPH`.@]riH+=v{,A)bP5">cmd</field> + </block> + </value> + <value name="ADD2"> + <block type="variables_get" id="+?O{K7(C)vw`Y6!T4L(o"> + <field name="VAR" id="=2ARo+;2DS07SU~j29Fk">posx_goal_left</field> + </block> + </value> + <value name="ADD3"> + <block type="variables_get" id="kiYnqn=QqrO`bh^F{AQ#"> + <field name="VAR" id="a8;eFhj+gj?)7exUyU;p">posy_goal_left</field> + </block> + </value> + <value name="ADD4"> + <block type="variables_get" id="/(B3zJewppd~EofXj-kV"> + <field name="VAR" id="7Tp~7_.qfmJN0SR]5p}F">posx_goal_right</field> + </block> + </value> + <value name="ADD5"> + <block type="variables_get" id=",3+x;7D(bN-41WySQn.v"> + <field name="VAR" id="+j/X+RCIMajR28(u#7DG">posy_goal_right</field> + </block> + </value> + <value name="ADD6"> + <block type="variables_get" id="u$4~ei085+j]JF61p!Kz"> + <field name="VAR" id="{]]L-TSC^#XtGnVinxf[">posx_goal_both</field> + </block> + </value> + <value name="ADD7"> + <block type="variables_get" id="#umK_pdUK0;[tcAYO_7s"> + <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> + </block> + </value> + <value name="ADD8"> + <block type="variables_get" id="sPxj5C*ZzYUH*$WCe4|q"> + <field name="VAR" id="S4.mduNQC(va3iR{oSdB">posx_ball</field> + </block> + </value> + <value name="ADD9"> + <block type="variables_get" id="~vY0WPr#jWq#SxvDb1@n"> + <field name="VAR" id="q#H`+Gwt~43Dh@fu;G-D">posy_ball</field> + </block> + </value> + <value name="ADD10"> + <block type="variables_get" id="r!O8lsSDk:Xs*=-;)LRu"> + <field name="VAR" id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</field> + </block> + </value> + <value name="ADD11"> + <block type="variables_get" id="`fG05b:bzq8[q?bquCg6"> + <field name="VAR" id=";S3?%3)**s[[l~Aq3*,{">v_var_ball_ypos</field> + </block> + </value> + </block> + </value> + <next> + <block type="procedures_callnoreturn" id="O6U,(~H4n-^0fP^x)_,{"> + <mutation name="checkTimeoutsSetGoalBoth"/> + <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">80</field> + </shadow> + </value> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> </block> </next> </block> @@ -1245,7 +1326,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="BJV|hZc!#JXq:io7MmM`" x="0" y="4119"> + <block type="procedures_defnoreturn" id="BJV|hZc!#JXq:io7MmM`" x="0" y="4261"> <mutation> <arg name="shot" varid="ymkMx:g,wGvcvRtYUanL" argid=":62/?4I]sXmWy2!AnMxj"/> </mutation> @@ -1610,7 +1691,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="5358"> + <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="5500"> <field name="NAME">checkTimeoutsSetGoalBoth</field> <statement name="STACK"> <block type="controls_if" id="fRY+n0,2r=7:t9`dVQYz"> @@ -1850,7 +1931,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="6093"> + <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="6235"> <field name="instance_name">ball_detector</field> <statement name="statement"> <block type="variables_set" id="=2/,IQfcLO{_5PNd3UK~"> @@ -2051,7 +2132,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="6760"> + <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="6902"> <field name="instance_name">ball_detector_goal_left</field> <statement name="statement"> <block type="variables_set" id="kvK,D4e%04[?+!jq*Lch"> @@ -2132,7 +2213,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="7091"> + <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="7233"> <field name="instance_name">ball_detector_goal_right</field> <statement name="statement"> <block type="variables_set" id="0!1?#@4|tcM8+U6E[$Tl"> @@ -2213,7 +2294,7 @@ </block> </statement> </block> - <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="7422"> + <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="7564"> <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> @@ -2236,7 +2317,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="7559"> + <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="7701"> <field name="NAME">shotBall</field> <statement name="STACK"> <block type="variables_set" id="l,2u2WF|]I#%kDS#5O7-"> @@ -2348,7 +2429,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="na=DVwj{P1Npv6z`ZSY{" x="0" y="8116"> + <block type="procedures_defnoreturn" id="na=DVwj{P1Npv6z`ZSY{" x="0" y="8258"> <field name="NAME">soundGoal</field> <statement name="STACK"> <block type="variables_set" id="o^c1yss2pIv%8YmX`=6X"> @@ -2364,7 +2445,7 @@ <field name="checkbox">FALSE</field> <next> <block type="display_set_switch_checked" id=")N/~DtYFy8cPbOpo-I50"> - <field name="instance_name">txt_switch_active</field> + <field name="instance_name">txt_switch_ball</field> <field name="property_name">checked</field> <value name="value"> <shadow type="logic_boolean" id="@Yk!SDjWfHi4@-ozuu_d"> @@ -2389,7 +2470,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="8310"> + <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="8452"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="-fFb#6a:h}yA(|L+pf*l"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="h?@dWX*~x|BDzo:O{is["/> @@ -2486,7 +2567,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="*i[s2YTWD*g9HS4dxkPq" x="0" y="8723"> + <block type="procedures_defnoreturn" id="*i[s2YTWD*g9HS4dxkPq" x="0" y="8865"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="k6At@e}Qga_x|SmVlf6C"/> <arg name="ticks" varid="l9lR0!)Laya}3RYVW(ZQ" argid="~VyZflQ+9HCPP`ynQ/=Y"/> @@ -2583,7 +2664,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" x="0" y="9136"> + <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" x="0" y="9278"> <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{"/> @@ -2659,7 +2740,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" x="0" y="9521"> + <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" x="0" y="9663"> <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"/> @@ -2735,7 +2816,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" x="0" y="9906"> + <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" x="0" y="10048"> <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"/> @@ -2826,7 +2907,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" x="0" y="10347"> + <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" x="0" y="10489"> <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#"/> diff --git a/omniwheels_x4_soccer_goal.py b/omniwheels_x4_soccer_goal.py index 9f1bc42cd7974801606f74abbdbfdb18362d4d24..d482ef9c584b029bd6296edf452cc348215788f9 100644 --- a/omniwheels_x4_soccer_goal.py +++ b/omniwheels_x4_soccer_goal.py @@ -7,15 +7,15 @@ from lib.camera import * from fischertechnik.controller.Motor import Motor +shot = None v = None ticks = None -shot = None factor_x = None +state = None ts_ball = None ts_goal_left = None ts_goal_right = None cmd = None -state = None factor_y = None goal_width = None posx_ball = None @@ -27,16 +27,16 @@ posy_ball = None posy_goal_left = None posy_goal_right = None x_max = None -v_var_ball_xpos = None v_slow = None +v_var_ball_xpos = None y_ball_far = None -v_var_ball_ypos = None v_fast = None y_ball_touch = None +v_var_ball_ypos = None y_ball_near = None search_dir_left = None def checkTimeoutsSetGoalBoth(): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left if posx_goal_left != None and posx_goal_right != None: goal_width = posx_goal_right - posx_goal_left posx_goal_both = posx_goal_left + goal_width / 2 @@ -56,7 +56,7 @@ def checkTimeoutsSetGoalBoth(): def stepBall(shot): - global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left state = 'stepBall' if posx_ball < x_min: left(v_slow, round(math.fabs(posx_ball) * 0.07)) @@ -78,7 +78,7 @@ def stepBall(shot): def ball_callback(event): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left ts_ball = (time.time() * 1000) posx_ball = event.value.x posy_ball = event.value.y @@ -91,7 +91,7 @@ ball_detector.add_detection_listener(ball_callback) def ball_callback2(event): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left ts_goal_left = (time.time() * 1000) posx_goal_left = event.value.x posy_goal_left = event.value.y @@ -102,7 +102,7 @@ ball_detector_goal_left.add_detection_listener(ball_callback2) def ball_callback23(event): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left ts_goal_right = (time.time() * 1000) posx_goal_right = event.value.x posy_goal_right = event.value.y @@ -113,7 +113,7 @@ ball_detector_goal_right.add_detection_listener(ball_callback23) def callback(event): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left if TXT_M_I8_photo_transistor.is_dark(): shotBall() time.sleep(5) @@ -123,7 +123,7 @@ TXT_M_I8_photo_transistor.add_change_listener("dark", callback) def shotBall(): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'shotBall' TXT_M_S1_servomotor.set_position(int(400)) TXT_M_M1_encodermotor.set_speed(int(512), Motor.CCW) @@ -150,10 +150,10 @@ def shotBall(): def soundGoal(): - global v, ticks, shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'soundGOAL' TXT_M.get_loudspeaker().play("26_Augenzwinkern.wav", False) - display.set_attr("txt_switch_active.checked", str(False).lower()) + display.set_attr("txt_switch_ball.checked", str(False).lower()) while True: if (not (TXT_M.get_loudspeaker().is_playing())): break @@ -161,7 +161,7 @@ def soundGoal(): def turnSideLeft(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'turnSideLeft' if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v_slow), Motor.CCW) @@ -177,7 +177,7 @@ def turnSideLeft(v, ticks): def turnSideRight(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'turnSideRight' if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v_slow), Motor.CW) @@ -193,7 +193,7 @@ def turnSideRight(v, ticks): def fwd(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'fwd' if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) @@ -208,7 +208,7 @@ def fwd(v, ticks): def bwd(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'bwd' if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) @@ -223,7 +223,7 @@ def bwd(v, ticks): def left(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'left ({}, {})'.format(v, ticks) if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW) @@ -238,7 +238,7 @@ def left(v, ticks): def right(v, ticks): - global shot, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, state, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_var_ball_xpos, v_slow, y_ball_far, v_var_ball_ypos, v_fast, y_ball_touch, y_ball_near, search_dir_left + global shot, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, x_max, v_slow, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left cmd = 'right ({}, {})'.format(v, ticks) if ticks >= 1: TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW) @@ -279,7 +279,7 @@ state = 'NONE' cmd = 'NONE' time.sleep(2) while True: - if display.get_attr("txt_switch_active.checked"): + if display.get_attr("txt_switch_ball.checked"): if posx_ball != None and posy_ball != None: if posx_goal_left != None and posx_goal_right != None: state = 'BALL_GOAL_BOTH' @@ -326,9 +326,13 @@ while True: else: state = 'NONE' cmd = 'NONE' + display.set_attr("txt_status_indicator_ball.active", str(posx_ball != None).lower()) + display.set_attr("txt_status_indicator_goal_left.active", str(posx_goal_left != None).lower()) + display.set_attr("txt_status_indicator_goal_right.active", str(posx_goal_right != None).lower()) display.set_attr("txt_label_ball.text", str('x:{}, y:{}'.format(posx_ball, posy_ball))) - display.set_attr("txt_label_goal.text", str('left:{} {}, right:{} {}'.format(posx_goal_left, posy_goal_left, posx_goal_right, posy_goal_right))) - display.set_attr("txt_label_goal_x.text", str('p:{}, w:{}'.format(posx_goal_both, goal_width))) + display.set_attr("txt_label_goal_left.text", str('{} {}'.format(posx_goal_left, posy_goal_left))) + display.set_attr("txt_label_goal_right.text", str('{} {}'.format(posx_goal_right, posy_goal_right))) + display.set_attr("txt_label_goal_both.text", str('p:{}, w:{}'.format(posx_goal_both, goal_width))) print('{}:{} GOAL left: {} {}, right:{} {}, p:{}, w:{} BALL_pos:{},{} v_x:{} v_y:{}'.format(state, cmd, posx_goal_left, posy_goal_left, posx_goal_right, posy_goal_right, posx_goal_both, goal_width, posx_ball, posy_ball, v_var_ball_xpos, v_var_ball_ypos)) checkTimeoutsSetGoalBoth() time.sleep(0.08)