-{"name": "cat_follower", "dom_code": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable id=\",?YI{f}$o~t3-v%!oOh`\">object</variable><variable id=\"9layCHw;-1P!)]pX+m2W\">class</variable><variable id=\"80w]HhW?e7QM%yfJ*[BS\">position</variable><variable id=\"fRn/=2s}a[[jcCloxlyH\">pos_x</variable></variables><block type=\"controls_whileUntil\" id=\"[^a!+/Zsc!iXdJ*Z-Go#\" x=\"43\" y=\"19\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"logic_boolean\" id=\"2Qi5#s+x(vg-{l2glVGI\"><field name=\"BOOL\">TRUE</field></block></value><statement name=\"DO\"><block type=\"variables_set\" id=\"0Y_GS_fw!h^YTb,XeKz#\"><field name=\"VAR\" id=\",?YI{f}$o~t3-v%!oOh`\">object</field><value name=\"VALUE\"><block type=\"lists_getIndex\" id=\"_GYqAA5bQtVd@ICQGW(U\"><mutation statement=\"false\" at=\"false\"></mutation><field name=\"MODE\">GET</field><field name=\"WHERE\">FIRST</field><value name=\"VALUE\"><block type=\"coderbot_adv_cnn_detect_objects\" id=\"m(x+AUHK}k[f:xAb;!iH\"><field name=\"MODEL\">generic_object_detect</field></block></value></block></value><next><block type=\"variables_set\" id=\":mq1jiC7D(V_yjV]p+bj\"><field name=\"VAR\" id=\"9layCHw;-1P!)]pX+m2W\">class</field><value name=\"VALUE\"><block type=\"lists_getIndex\" id=\"gg?Rm?i]1V[@Sk0~,6}U\"><mutation statement=\"false\" at=\"false\"></mutation><field name=\"MODE\">GET</field><field name=\"WHERE\">FIRST</field><value name=\"VALUE\"><block type=\"variables_get\" id=\"jWBE:9@+HD)M5w(R6-+R\"><field name=\"VAR\" id=\",?YI{f}$o~t3-v%!oOh`\">object</field></block></value></block></value><next><block type=\"controls_if\" id=\"SoONo/Qzd^PSRs3kDLW4\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"girWO4BMe2k@24#mK9W|\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get\" id=\"9oEqGs$i`cb!|tDMGcUs\"><field name=\"VAR\" id=\"9layCHw;-1P!)]pX+m2W\">class</field></block></value><value name=\"B\"><block type=\"text\" id=\"57hUIBHt5-};Ur^Ym(`p\"><field name=\"TEXT\">cat</field></block></value></block></value><statement name=\"DO0\"><block type=\"variables_set\" id=\":krqJ`zM+j//B~motZ@5\"><field name=\"VAR\" id=\"80w]HhW?e7QM%yfJ*[BS\">position</field><value name=\"VALUE\"><block type=\"lists_getIndex\" id=\"n*i|7Ey@DqvX+8X;^2fb\"><mutation statement=\"false\" at=\"true\"></mutation><field name=\"MODE\">GET</field><field name=\"WHERE\">FROM_START</field><value name=\"VALUE\"><block type=\"variables_get\" id=\"$p#z76Ff-*8z$I:6(%:F\"><field name=\"VAR\" id=\",?YI{f}$o~t3-v%!oOh`\">object</field></block></value><value name=\"AT\"><block type=\"math_number\" id=\"?s]?2J@-Pc6i1f-y{[09\"><field name=\"NUM\">3</field></block></value></block></value><next><block type=\"variables_set\" id=\"[:tR1VyS6qeSU?!D)`sN\"><field name=\"VAR\" id=\"fRn/=2s}a[[jcCloxlyH\">pos_x</field><value name=\"VALUE\"><block type=\"math_arithmetic\" id=\"*U,nQR1[HxPKn8W%pkCz\"><field name=\"OP\">DIVIDE</field><value name=\"A\"><block type=\"math_arithmetic\" id=\"uc.~ggYr?xqXV/.F7s1u\"><field name=\"OP\">ADD</field><value name=\"A\"><block type=\"lists_getIndex\" id=\"kuISxM{Klu36vQ]Jo+P@\"><mutation statement=\"false\" at=\"true\"></mutation><field name=\"MODE\">GET</field><field name=\"WHERE\">FROM_START</field><value name=\"VALUE\"><block type=\"variables_get\" id=\"?gyq($9~Uq.~3XY8_J9)\"><field name=\"VAR\" id=\"80w]HhW?e7QM%yfJ*[BS\">position</field></block></value><value name=\"AT\"><block type=\"math_number\" id=\"(1G%d4(*1Vqq?1xk.^{t\"><field name=\"NUM\">1</field></block></value></block></value><value name=\"B\"><block type=\"lists_getIndex\" id=\".Xk?/{p+tLXc=}|OA82n\"><mutation statement=\"false\" at=\"true\"></mutation><field name=\"MODE\">GET</field><field name=\"WHERE\">FROM_START</field><value name=\"VALUE\"><block type=\"variables_get\" id=\"|IdyV?|5py+=3,0!:z_A\"><field name=\"VAR\" id=\"80w]HhW?e7QM%yfJ*[BS\">position</field></block></value><value name=\"AT\"><block type=\"math_number\" id=\",Me8:/`3uBpfuBZrA)sp\"><field name=\"NUM\">3</field></block></value></block></value></block></value><value name=\"B\"><block type=\"math_number\" id=\"m~K8F`G6T$ha/a^LdD5Z\"><field name=\"NUM\">2</field></block></value></block></value><next><block type=\"text_print\" id=\"|,^zQ|VUQq/(lt,K`8y0\"><value name=\"TEXT\"><block type=\"variables_get\" id=\"#QdSbUp(4Hn;Xk(4xe0G\"><field name=\"VAR\" id=\"9layCHw;-1P!)]pX+m2W\">class</field></block></value><next><block type=\"controls_if\" id=\"}1i(Om9l5~9.WOIq!=W`\"><mutation elseif=\"1\" else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"~.k].tdW8FF4#-(AeXsM\"><field name=\"OP\">LT</field><value name=\"A\"><block type=\"variables_get\" id=\")KUmL+N6#~?rM~GnqH[G\"><field name=\"VAR\" id=\"fRn/=2s}a[[jcCloxlyH\">pos_x</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"l*=6l=SR/g6%(|]$i;}C\"><field name=\"NUM\">40</field></block></value></block></value><statement name=\"DO0\"><block type=\"coderbot_adv_move\" id=\":YSGyu*XL_u{)zQBD:{X\"><field name=\"ACTION\">LEFT</field><value name=\"SPEED\"><block type=\"math_number\" id=\"de??^JX,i_mkb$RsmNXs\"><field name=\"NUM\">60</field></block></value><value name=\"ELAPSE\"><block type=\"math_number\" id=\"zs-Cre_[w%5@VNoMwi;l\"><field name=\"NUM\">0.1</field></block></value></block></statement><value name=\"IF1\"><block type=\"logic_compare\" id=\"+S5!K$WfFhj@QhRSokhV\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"variables_get\" id=\"J%|{#:u3(!lcF4.B~gQt\"><field name=\"VAR\" id=\"fRn/=2s}a[[jcCloxlyH\">pos_x</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"[gg?3(+hO-?.%qW,`@t~\"><field name=\"NUM\">60</field></block></value></block></value><statement name=\"DO1\"><block type=\"coderbot_adv_move\" id=\"vA*_d?-Bwh55o,{*%v:G\"><field name=\"ACTION\">RIGHT</field><value name=\"SPEED\"><block type=\"math_number\" id=\"W}pFMYn/}2RnG+E86e~v\"><field name=\"NUM\">60</field></block></value><value name=\"ELAPSE\"><block type=\"math_number\" id=\"as/ZY,XwrTw`@Z~O9B`$\"><field name=\"NUM\">0.1</field></block></value></block></statement><statement name=\"ELSE\"><block type=\"coderbot_adv_move\" id=\"Xs:ewoKw*Fg3UK*sRCNm\"><field name=\"ACTION\">FORWARD</field><value name=\"SPEED\"><block type=\"math_number\" id=\"qSFO9:h}?s~cD:hj(r:(\"><field name=\"NUM\">100</field></block></value><value name=\"ELAPSE\"><block type=\"math_number\" id=\"Nh^fXOiu1$x8[$i1C2IV\"><field name=\"NUM\">0.2</field></block></value></block></statement></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"text_print\" id=\"PAYJ[1S)`0Gl#=M`cX=g\"><value name=\"TEXT\"><block type=\"variables_get\" id=\"2nPmKkqF|Y:u3?r=5y|n\"><field name=\"VAR\" id=\",?YI{f}$o~t3-v%!oOh`\">object</field></block></value></block></statement></block></next></block></next></block></statement></block></xml>", "code": "object2 = None\nclass2 = None\nposition = None\npos_x = None\n\n\nwhile True:\n get_prog_eng().check_end()\n object2 = get_cam().cnn_detect_objects(\"generic_object_detect\")[0]\n class2 = object2[0]\n if class2 == 'cat':\n position = object2[2]\n pos_x = (position[0] + position[2]) / 2\n get_cam().set_text(class2)\n if pos_x < 40:\n get_bot().left(speed=60, elapse=0.1)\n elif pos_x > 60:\n get_bot().right(speed=60, elapse=0.1)\n else:\n get_bot().forward(speed=100, elapse=0.2)\n else:\n get_cam().set_text(object2)\n", "default": false}
0 commit comments