From 6f1343649ec0e5b1beb5197a5cee5f09f5f004d3 Mon Sep 17 00:00:00 2001 From: ft-Demo <fischertechnik-team@fischer.de> Date: Mon, 25 Oct 2021 08:09:37 +0000 Subject: [PATCH] commit by robo pro coding --- omniwheels_x4_soccer_goal.blockly | 154 +++++++++++++++++++++--------- omniwheels_x4_soccer_goal.py | 26 ++--- 2 files changed, 120 insertions(+), 60 deletions(-) diff --git a/omniwheels_x4_soccer_goal.blockly b/omniwheels_x4_soccer_goal.blockly index 762bd45..0763965 100644 --- a/omniwheels_x4_soccer_goal.blockly +++ b/omniwheels_x4_soccer_goal.blockly @@ -517,7 +517,7 @@ </value> <statement name="DO2"> <block type="procedures_callnoreturn" id="5?xr%Un4{ZZP/*kbTrS4"> - <mutation name="turnBallLeft"/> + <mutation name="turnSideLeft"/> </block> </statement> <value name="IF3"> @@ -853,7 +853,7 @@ </value> <statement name="DO0"> <block type="procedures_callnoreturn" id="),QhMk?KFwaoqgIh6A~w"> - <mutation name="turnBallRight"/> + <mutation name="turnSideRight"/> </block> </statement> <value name="IF1"> @@ -885,7 +885,7 @@ </value> <statement name="DO1"> <block type="procedures_callnoreturn" id="_q6X5`*YO|;FU%~(RZ2?"> - <mutation name="turnBallLeft"/> + <mutation name="turnSideLeft"/> </block> </statement> <statement name="ELSE"> @@ -1107,7 +1107,7 @@ </value> <statement name="DO0"> <block type="procedures_callnoreturn" id="@$;_yG?U8opM|/]Of75$"> - <mutation name="turnBallRight"/> + <mutation name="turnSideRight"/> </block> </statement> <value name="IF1"> @@ -1139,7 +1139,7 @@ </value> <statement name="DO1"> <block type="procedures_callnoreturn" id="0il^Cdoc`7I6eVmi6htz"> - <mutation name="turnBallLeft"/> + <mutation name="turnSideLeft"/> </block> </statement> <statement name="ELSE"> @@ -1463,8 +1463,8 @@ </block> </value> <statement name="DO1"> - <block type="procedures_callnoreturn" id="fs3R{xW/!NZ+huwii|WQ"> - <mutation name="turnBallLeft"/> + <block type="procedures_callnoreturn" id="|6(M2ayv;Mt,H:l*)L@e"> + <mutation name="turnSideLeft"/> </block> </statement> <value name="IF2"> @@ -1527,8 +1527,8 @@ </block> </value> <statement name="DO2"> - <block type="procedures_callnoreturn" id="`g//e~_r%pQ[)DUR;?`F"> - <mutation name="turnBallRight"/> + <block type="procedures_callnoreturn" id="R590b9iY$aQ~B7!m8f2l"> + <mutation name="turnSideRight"/> </block> </statement> <statement name="ELSE"> @@ -1785,13 +1785,43 @@ </block> </value> <statement name="DO1"> - <block type="procedures_callnoreturn" id="xH1rS2h$??lsC(b5|}S%" inline="true"> - <mutation name="left_v"> + <block type="procedures_callnoreturn" id="mG-?FU_hknyuqCH{oWJT"> + <mutation name="left"> <arg name="v"/> + <arg name="ticks"/> </mutation> <value name="ARG0"> - <block type="variables_get" id="J/%Oa`9f,Y13y_bOs_ef"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + <block type="variables_get" id="R%Oe)=kR9%E%`E3L[QVN"> + <field name="VAR" id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</field> + </block> + </value> + <value name="ARG1"> + <block type="math_constrain" id="@In6j?EErn]hK})TS[jd" inline="false"> + <value name="VALUE"> + <block type="math_arithmetic" id="9e@Xpj!L)E*5)/BWxD;,"> + <field name="OP">MULTIPLY</field> + <value name="A"> + <block type="variables_get" id="|5*]zYtMm]955K1])q46"> + <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="#5;psA_RhR%yG7b(w2_o"> + <field name="VAR" id="rOE96qIEVvA5gBu*K^?x">factor_ball_rot</field> + </block> + </value> + </block> + </value> + <value name="LOW"> + <block type="math_number" id="JYPL-h1Mqs4eUAnK^1.:"> + <field name="NUM">3</field> + </block> + </value> + <value name="HIGH"> + <block type="math_number" id="M2ZTdr0Emu8qUo79k/Mh"> + <field name="NUM">100</field> + </block> + </value> </block> </value> </block> @@ -1812,13 +1842,43 @@ </block> </value> <statement name="DO2"> - <block type="procedures_callnoreturn" id="jYQXBtRHSn.adQq~G7@Z" inline="true"> - <mutation name="right_v"> + <block type="procedures_callnoreturn" id="oGweCRo;|ZbP%1KR7B]a"> + <mutation name="right"> <arg name="v"/> + <arg name="ticks"/> </mutation> <value name="ARG0"> - <block type="variables_get" id="nCzWllccVaUk{$/gd9*b"> - <field name="VAR" id=")rK_fR,m=]b(j[{.CtBj">v_slow</field> + <block type="variables_get" id="Vc7Fp*A$WDu^X7t.%1`9"> + <field name="VAR" id="O=Lc:FQ[]f3iuM/V@.mv">v_var_ball_xpos</field> + </block> + </value> + <value name="ARG1"> + <block type="math_constrain" id="e7X.Xy9YU#DtGWto8(nZ" inline="false"> + <value name="VALUE"> + <block type="math_arithmetic" id="i.w=wor*D`.oFqZ~n,,="> + <field name="OP">MULTIPLY</field> + <value name="A"> + <block type="variables_get" id="KZSMf^5ZkNQv1qqwiZd3"> + <field name="VAR" id="v0BvP7[91TGaMpQG$r0f">goal_width</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="*Sc|AprtAT]]mE.FST|Z"> + <field name="VAR" id="rOE96qIEVvA5gBu*K^?x">factor_ball_rot</field> + </block> + </value> + </block> + </value> + <value name="LOW"> + <block type="math_number" id="BoQu)s$L=Rc2L5S(D@ma"> + <field name="NUM">3</field> + </block> + </value> + <value name="HIGH"> + <block type="math_number" id=".!t|yj:@W/3s;L{GOC@@"> + <field name="NUM">100</field> + </block> + </value> </block> </value> </block> @@ -2328,7 +2388,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="6171"> + <block type="procedures_defnoreturn" id="N2EC5uK:$~0ERXAdK0!y" x="0" y="6395"> <field name="NAME">checkTimeouts</field> <statement name="STACK"> <block type="controls_if" id="o.;j7*F0}TW}ju0E18(_"> @@ -2474,7 +2534,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="6624"> + <block type="camera_on_ball_detected" id="dgC*A|KHMC_R5S#ZRk}d" x="0" y="6848"> <field name="instance_name">ball_detector</field> <statement name="statement"> <block type="variables_set" id="=2/,IQfcLO{_5PNd3UK~"> @@ -2675,7 +2735,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="7291"> + <block type="camera_on_ball_detected" id="Rg2Gt(0WT:J2|Us~[j.3" x="0" y="7515"> <field name="instance_name">ball_detector_goal_left</field> <statement name="statement"> <block type="variables_set" id="kvK,D4e%04[?+!jq*Lch"> @@ -2755,7 +2815,7 @@ </block> </statement> </block> - <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="7594"> + <block type="camera_on_ball_detected" id="(?slhGsN^:d1`vP{j9#|" x="0" y="7818"> <field name="instance_name">ball_detector_goal_right</field> <statement name="statement"> <block type="variables_set" id="0!1?#@4|tcM8+U6E[$Tl"> @@ -2835,7 +2895,7 @@ </block> </statement> </block> - <block type="counter_event" id="T^aHOKaV|bU#ZeZfn[GJ" x="0" y="7897"> + <block type="counter_event" id="T^aHOKaV|bU#ZeZfn[GJ" x="0" y="8121"> <value name="condition"> <shadow type="counter_if_value" id="9`P*eh,|:Wnytp?G[|;{"> <field name="instance_name">TXT_M_C1_motor_step_counter</field> @@ -2883,7 +2943,7 @@ </block> </statement> </block> - <block type="counter_event" id="7wA~J+BkZ5~nV6aI|fLZ" x="0" y="8044"> + <block type="counter_event" id="7wA~J+BkZ5~nV6aI|fLZ" x="0" y="8268"> <value name="condition"> <shadow type="counter_if_value" id="RDF|2PoXWvG^_k{FB37U"> <field name="instance_name">TXT_M_C2_motor_step_counter</field> @@ -2931,7 +2991,7 @@ </block> </statement> </block> - <block type="counter_event" id="Nv;e.HwUkTK/=(qEs~82" x="0" y="8191"> + <block type="counter_event" id="Nv;e.HwUkTK/=(qEs~82" x="0" y="8415"> <value name="condition"> <shadow type="counter_if_value" id="05ihu;VYh*tmqA78pJQL"> <field name="instance_name">TXT_M_C3_motor_step_counter</field> @@ -2979,7 +3039,7 @@ </block> </statement> </block> - <block type="counter_event" id="j|Pz^uHewb7]si9}3az3" x="0" y="8338"> + <block type="counter_event" id="j|Pz^uHewb7]si9}3az3" x="0" y="8562"> <value name="condition"> <shadow type="counter_if_value" id="N9]b*Kn_Nxk}[I9e!^Z."> <field name="instance_name">TXT_M_C4_motor_step_counter</field> @@ -3027,7 +3087,7 @@ </block> </statement> </block> - <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="8485"> + <block type="input_event" id="j(TuhJ0G}{^qGSq:26FY" x="0" y="8709"> <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> @@ -3050,7 +3110,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="8622"> + <block type="procedures_defnoreturn" id="RyK*td9aN5aR;@gw4f)+" x="0" y="8846"> <field name="NAME">shotBall</field> <statement name="STACK"> <block type="variables_set" id="l,2u2WF|]I#%kDS#5O7-"> @@ -3185,7 +3245,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="+FKt%DE[[q%Zp0T.Fn}d" x="0" y="9236"> + <block type="procedures_defnoreturn" id="+FKt%DE[[q%Zp0T.Fn}d" x="0" y="9460"> <field name="NAME">stop</field> <statement name="STACK"> <block type="variables_set" id="0lb+=KDkMxl8Q(.f(!U4"> @@ -3207,7 +3267,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" x="0" y="9457"> + <block type="procedures_defnoreturn" id="/pGK)WReTLfX`L_7oAMD" x="0" y="9681"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -3245,7 +3305,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" x="0" y="9706"> + <block type="procedures_defnoreturn" id="qX~e_RBh^tj];fOb=cq6" x="0" y="9930"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid="{M*n_!I)eN0.4..0Bzo#"/> </mutation> @@ -3283,7 +3343,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" x="0" y="9955"> + <block type="procedures_defnoreturn" id="!zD7YDZ.5n?En8cYle4R" x="0" y="10179"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -3321,7 +3381,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" x="0" y="10204"> + <block type="procedures_defnoreturn" id="}KXL0=RKLgCT~yQ];aw:" x="0" y="10428"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -3359,7 +3419,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="0R.p||vBpkt08x[mI=z[" x="0" y="10453"> + <block type="procedures_defnoreturn" id="0R.p||vBpkt08x[mI=z[" x="0" y="10677"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -3410,14 +3470,14 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="10722"> - <field name="NAME">turnBallLeft</field> + <block type="procedures_defnoreturn" id="UFM0X7|X:*ja#f+^7kz;" x="0" y="10946"> + <field name="NAME">turnSideLeft</field> <statement name="STACK"> <block type="variables_set" id="nf?K,a/5MLaj.5?J/IGs"> <field name="VAR" id="fPH`.@]riH+=v{,A)bP5">cmd</field> <value name="VALUE"> <block type="text" id="?Di@nJ_~eE%u(u]_u-7U"> - <field name="TEXT">turnBallLeft</field> + <field name="TEXT">turnSideLeft</field> </block> </value> <next> @@ -3457,14 +3517,14 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="*i[s2YTWD*g9HS4dxkPq" x="0" y="10943"> - <field name="NAME">turnBallRight</field> + <block type="procedures_defnoreturn" id="*i[s2YTWD*g9HS4dxkPq" x="0" y="11167"> + <field name="NAME">turnSideRight</field> <statement name="STACK"> <block type="variables_set" id="$K=E,g/}k}au~ZyqB!+S"> <field name="VAR" id="fPH`.@]riH+=v{,A)bP5">cmd</field> <value name="VALUE"> <block type="text" id="Zx@baj[/7x8~`_@h3IgQ"> - <field name="TEXT">turnBallRight</field> + <field name="TEXT">turnSideRight</field> </block> </value> <next> @@ -3504,7 +3564,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" x="0" y="11164"> + <block type="procedures_defnoreturn" id="dhS+rZWE[`RZz:fU3A)e" x="0" y="11388"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -3542,7 +3602,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" x="0" y="11413"> + <block type="procedures_defnoreturn" id=")G33?J{l2sdl+nL3hpBp" x="0" y="11637"> <mutation> <arg name="v" varid="DfDz@$]?^P=(6r:%^xC*" argid=",q%qjDTJ~Z@[BoMwORuq"/> </mutation> @@ -3580,7 +3640,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" x="0" y="11662"> + <block type="procedures_defnoreturn" id="oSa9Ly*^-c^M{$gkMZt1" x="0" y="11886"> <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{"/> @@ -3656,7 +3716,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" x="0" y="12047"> + <block type="procedures_defnoreturn" id="G@]xamrhDPW$7uQ6oPo#" x="0" y="12271"> <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"/> @@ -3732,7 +3792,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" x="0" y="12432"> + <block type="procedures_defnoreturn" id="5Hv=PFtVvPQA=IZrkJfU" x="0" y="12656"> <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"/> @@ -3808,7 +3868,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="0yb4y~)e=F^~rds6/HYd" x="0" y="12817"> + <block type="procedures_defnoreturn" id="0yb4y~)e=F^~rds6/HYd" x="0" y="13041"> <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"/> @@ -3880,7 +3940,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" x="0" y="13146"> + <block type="procedures_defnoreturn" id="[S@[MO!Z/cNt:Jsg4dd}" x="0" y="13370"> <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#"/> @@ -3956,7 +4016,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="qiCJ8lc,P.U`J8k0us:C" x="0" y="13531"> + <block type="procedures_defnoreturn" id="qiCJ8lc,P.U`J8k0us:C" x="0" y="13755"> <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 3e0d996..154036c 100644 --- a/omniwheels_x4_soccer_goal.py +++ b/omniwheels_x4_soccer_goal.py @@ -215,9 +215,9 @@ def search_ball_rot(v): right_v(v) -def turnBallLeft(): +def turnSideLeft(): global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, posx_ball, counters, factor_ball_rot, posy_ball, posx_goal, search_dir_left, v_slow, x_min, v_var_ball_xpos, x_max, v_var_ball_ypos, y_ball_far, y_ball_near, y_ball_touch, v_fast, goal_width, pos_goal_both, state - cmd = 'turnBallLeft' + cmd = 'turnSideLeft' TXT_M_M1_encodermotor.set_speed(int(v_slow), Motor.CCW) TXT_M_M2_encodermotor.set_speed(int(v_slow), Motor.CW) TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor) @@ -226,9 +226,9 @@ def turnBallLeft(): TXT_M_M3_encodermotor.start_sync(TXT_M_M4_encodermotor) -def turnBallRight(): +def turnSideRight(): global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, posx_ball, counters, factor_ball_rot, posy_ball, posx_goal, search_dir_left, v_slow, x_min, v_var_ball_xpos, x_max, v_var_ball_ypos, y_ball_far, y_ball_near, y_ball_touch, v_fast, goal_width, pos_goal_both, state - cmd = 'turnBallRight' + cmd = 'turnSideRight' TXT_M_M1_encodermotor.set_speed(int(v_slow), Motor.CW) TXT_M_M2_encodermotor.set_speed(int(v_slow), Motor.CCW) TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor) @@ -379,7 +379,7 @@ while True: elif posy_ball > y_ball_far and posy_ball <= y_ball_near: fwd_v(v_slow) elif posy_ball > y_ball_near and posy_ball <= y_ball_touch: - turnBallLeft() + turnSideLeft() elif posy_ball <= y_ball_touch: bwd_v(v_slow) else: @@ -396,9 +396,9 @@ while True: fwd_v(v_slow) elif posy_ball <= y_ball_near: if posx_goal[0] < posx_ball: - turnBallRight() + turnSideRight() elif posx_goal[0] > posx_ball: - turnBallLeft() + turnSideLeft() else: stop() elif posy_ball <= y_ball_touch: @@ -411,9 +411,9 @@ while True: fwd_v(v_slow) elif posy_ball <= y_ball_near: if posx_goal[1] < posx_ball: - turnBallRight() + turnSideRight() elif posx_goal[1] > posx_ball: - turnBallLeft() + turnSideLeft() else: stop() elif posy_ball <= y_ball_touch: @@ -428,9 +428,9 @@ while True: if posx_ball > posx_goal[0] and posx_ball < posx_goal[1]: fwd_v(v_slow) elif posx_ball < posx_goal[0] and posx_ball < posx_goal[1]: - turnBallLeft() + turnSideLeft() elif posx_ball > posx_goal[0] and posx_ball > posx_goal[1]: - turnBallRight() + turnSideRight() else: stop() elif posy_ball <= y_ball_touch: @@ -444,9 +444,9 @@ while True: if pos_goal_both >= x_min and pos_goal_both <= x_max: fwd_v(v_slow) elif pos_goal_both < x_min: - left_v(v_slow) + left(v_var_ball_xpos, min(max(goal_width * factor_ball_rot, 3), 100)) elif pos_goal_both > x_max: - right_v(v_slow) + right(v_var_ball_xpos, min(max(goal_width * factor_ball_rot, 3), 100)) else: stop() elif (posx_ball == None or posy_ball == None) and (posx_goal[0] != None or posx_goal[1] == None): -- GitLab