Skip to content
Snippets Groups Projects
Commit 590a49c8 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parents
Branches master
No related tags found
No related merge requests found
{"uuid":"d5afebef-2128-72cb-331e-53289dcee298","name":"RoboMission_line_fast","mode":"ADVANCED","version":"1.0","controller":"TXT4"}
\ No newline at end of file
<xml xmlns="https://developers.google.com/blockly/xml" version="16">
<variables>
<variable id="`-~qmBsd^FW,:3McFR[(">slow</variable>
<variable id="EF^3VAzkCSECRs.p30w!">fast</variable>
<variable id="/S;TpBF0lhzLj)aB*2}]">i1</variable>
<variable id="-lh`/}ub3Gn7HzXZS4A$">i2</variable>
</variables>
<block type="start_block" id="]g6@{k.Q^-{D(1wxbe-c" deletable="false" x="-1509" y="-2">
<statement name="statement">
<block type="variables_set" id="Jr}uKgCVvsa]:x2?/w}r">
<field name="VAR" id="`-~qmBsd^FW,:3McFR[(">slow</field>
<value name="VALUE">
<block type="math_number" id="6*KIhN^u|FI?948gb=TE">
<field name="NUM">150</field>
</block>
</value>
<next>
<block type="variables_set" id="?/w}w24$Skn9W]7^.vz:">
<field name="VAR" id="EF^3VAzkCSECRs.p30w!">fast</field>
<value name="VALUE">
<block type="math_number" id="Gif_M(6*evWtxHZ++~ZH">
<field name="NUM">512</field>
</block>
</value>
<next>
<block type="loop_endless" id="G5f!(a-=$]dr~ign7pW9">
<statement name="DO">
<block type="variables_set" id="t:kp0{oZTGctE$L,B*a4">
<field name="VAR" id="/S;TpBF0lhzLj)aB*2}]">i1</field>
<value name="VALUE">
<block type="input_color_sensor_get_value" id="okz7j[O9NP+-N2]}7?j%">
<field name="instance_name">v}Wf^VN(H6-Q3:$II]KJ-Cb,bm9+r7-7W74Hrl(#o</field>
</block>
</value>
<next>
<block type="variables_set" id=",-]cG3l.*lBrIA.FWLPI">
<field name="VAR" id="-lh`/}ub3Gn7HzXZS4A$">i2</field>
<value name="VALUE">
<block type="input_color_sensor_get_value" id="BZii2!11-+@CRv9JE}21">
<field name="instance_name">v}Wf^VN(H6-Q3:$II]KJ-.4E+)YDXvIU)Q,IEW_#k</field>
</block>
</value>
<next>
<block type="controls_if" id="p%pXC|ZHYqHkvTFsnc@c">
<mutation elseif="3" else="1"/>
<value name="IF0">
<block type="logic_operation" id="h8PrmbX+}U4!:S,j*!t^" inline="false">
<field name="OP">AND</field>
<value name="A">
<block type="logic_compare" id="^([pzH5?rQh@?dR[.mW#">
<field name="OP">LT</field>
<value name="A">
<block type="variables_get" id=",9vfp9n$rA(kMr2Q|)%o">
<field name="VAR" id="/S;TpBF0lhzLj)aB*2}]">i1</field>
</block>
</value>
<value name="B">
<block type="math_number" id=":Vh{89C6g2Z}yMs=l+T[">
<field name="NUM">200</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="logic_compare" id="jMMMTtS*N#KH0.P$u_DK">
<field name="OP">LT</field>
<value name="A">
<block type="variables_get" id="1A}^Rmwx3G/do!8aw-?C">
<field name="VAR" id="-lh`/}ub3Gn7HzXZS4A$">i2</field>
</block>
</value>
<value name="B">
<block type="math_number" id="Y+nu9bmSl6I1-?F3C{#/">
<field name="NUM">200</field>
</block>
</value>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="encodermotor_set_values" id="QHu3u9t]DZd7O[fA;B39">
<mutation syncBlocks="1"/>
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-WpKi`VJ3XVuCOUuTc^=w</field>
<field name="direction_0">Motor.CCW</field>
<field name="instance_name_1">v}Wf^VN(H6-Q3:$II]KJ-7E{.a)tBHsGHIm^uK-lc</field>
<field name="direction_1">Motor.CW</field>
<value name="speed">
<shadow type="motor_number" id="kEwK7:k,!{TPzDmD/SRn">
<field name="MOTOR_NUM">512</field>
</shadow>
</value>
<value name="distance">
<shadow type="math_number" id="W|ouJT1Bu997v_x?c13U">
<field name="NUM">161</field>
</shadow>
</value>
<next>
<block type="util_wait_until" id="aA/CDQ1e2}5,xHmquN0E">
<value name="value">
<block type="encodermotor_position_read" id="|w13Y![X:`wZ2P^V,K{k">
<field name="instance_name">v}Wf^VN(H6-Q3:$II]KJ-WpKi`VJ3XVuCOUuTc^=w</field>
</block>
</value>
</block>
</next>
</block>
</statement>
<value name="IF1">
<block type="logic_compare" id="=(ixcSRan@[Lj6RptkE:">
<field name="OP">LT</field>
<value name="A">
<block type="math_single" id="JN}#b]Cp05ngFH}}.e#l">
<field name="OP">ABS</field>
<value name="NUM">
<block type="math_arithmetic" id=":w?`r!Tvl12|YlNQ4szw">
<field name="OP">MINUS</field>
<value name="A">
<block type="variables_get" id="l5prc8PJZ;Fh-#0?=Y$Q">
<field name="VAR" id="/S;TpBF0lhzLj)aB*2}]">i1</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="t8wH+D%zEdAD[*brKtds">
<field name="VAR" id="-lh`/}ub3Gn7HzXZS4A$">i2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="00uYWrzDh{Q:W03r3IVe">
<field name="NUM">600</field>
</block>
</value>
</block>
</value>
<statement name="DO1">
<block type="encodermotor_set_speed" id="RrfH(0=%y6i,7Tx4_)Tm">
<mutation syncBlocks="1"/>
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-WpKi`VJ3XVuCOUuTc^=w</field>
<field name="direction_0">Motor.CCW</field>
<field name="instance_name_1">v}Wf^VN(H6-Q3:$II]KJ-7E{.a)tBHsGHIm^uK-lc</field>
<field name="direction_1">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="-m-C.Rqdsc22e1wLQs4r">
<field name="MOTOR_NUM">512</field>
</shadow>
<block type="variables_get" id="%XZMb**/rqBq6IBbZre5">
<field name="VAR" id="EF^3VAzkCSECRs.p30w!">fast</field>
</block>
</value>
</block>
</statement>
<value name="IF2">
<block type="logic_compare" id="3[j1mV)_l^8b(hbN!Xm4">
<field name="OP">LT</field>
<value name="A">
<block type="variables_get" id="d1DV9MQ`oRbv~1BuLqDG">
<field name="VAR" id="/S;TpBF0lhzLj)aB*2}]">i1</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="g{2];fXC;2m$([$/{g)6">
<field name="VAR" id="-lh`/}ub3Gn7HzXZS4A$">i2</field>
</block>
</value>
</block>
</value>
<statement name="DO2">
<block type="encodermotor_set_speed" id="n:ePeOQBnZG6g0dq~|jw">
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-WpKi`VJ3XVuCOUuTc^=w</field>
<field name="direction_0">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="J*=keX_T_{TYE0~^eL1H">
<field name="MOTOR_NUM">512</field>
</shadow>
<block type="variables_get" id="hDvjq[eUO.MUF2D9(GNF">
<field name="VAR" id="`-~qmBsd^FW,:3McFR[(">slow</field>
</block>
</value>
<next>
<block type="encodermotor_set_speed" id="a5`v+1bE3#3`bmFcdw08">
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-7E{.a)tBHsGHIm^uK-lc</field>
<field name="direction_0">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="3bI!F`M6O_:Wv_16HJ/a">
<field name="MOTOR_NUM">512</field>
</shadow>
<block type="variables_get" id="_;F0;EQnILM+[}G-^vy]">
<field name="VAR" id="EF^3VAzkCSECRs.p30w!">fast</field>
</block>
</value>
</block>
</next>
</block>
</statement>
<value name="IF3">
<block type="logic_compare" id="LAi[$QalCiL)0jR]QgeF">
<field name="OP">GT</field>
<value name="A">
<block type="variables_get" id="Pj/wEy7DZS=OGtpY.yYy">
<field name="VAR" id="/S;TpBF0lhzLj)aB*2}]">i1</field>
</block>
</value>
<value name="B">
<block type="variables_get" id=":*wvt@iv[%!Kch(:^X|2">
<field name="VAR" id="-lh`/}ub3Gn7HzXZS4A$">i2</field>
</block>
</value>
</block>
</value>
<statement name="DO3">
<block type="encodermotor_set_speed" id="^SN~NPzo|2-)|9AJb-BE">
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-WpKi`VJ3XVuCOUuTc^=w</field>
<field name="direction_0">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="Mq9i=-*31-ylklONp6.s">
<field name="MOTOR_NUM">512</field>
</shadow>
<block type="variables_get" id="afJt7{,Ow,RBb]K(A.Eg">
<field name="VAR" id="EF^3VAzkCSECRs.p30w!">fast</field>
</block>
</value>
<next>
<block type="encodermotor_set_speed" id="(b2ADqQcy#=Y^:(S2B,A">
<field name="instance_name_0">v}Wf^VN(H6-Q3:$II]KJ-7E{.a)tBHsGHIm^uK-lc</field>
<field name="direction_0">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="Zvj~BOKsrAxe-5s?]uM.">
<field name="MOTOR_NUM">512</field>
</shadow>
<block type="variables_get" id="Be7D*oXDeL{T#RpPb974">
<field name="VAR" id="`-~qmBsd^FW,:3McFR[(">slow</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>
\ No newline at end of file
import math
import time
from fischertechnik.controller.Motor import Motor
from lib.controller import *
slow = None
fast = None
i1 = None
i2 = None
slow = 150
fast = 512
while True:
i1 = TXT_M_I1_color_sensor.get_voltage()
i2 = TXT_M_I2_color_sensor.get_voltage()
if i1 < 200 and i2 < 200:
TXT_M_M1_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M1_encodermotor.set_distance(int(161), TXT_M_M2_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
elif math.fabs(i1 - i2) < 600:
TXT_M_M1_encodermotor.set_speed(int(fast), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(fast), Motor.CCW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor)
elif i1 < i2:
TXT_M_M1_encodermotor.set_speed(int(slow), Motor.CCW)
TXT_M_M1_encodermotor.start_sync()
TXT_M_M2_encodermotor.set_speed(int(fast), Motor.CCW)
TXT_M_M2_encodermotor.start_sync()
elif i1 > i2:
TXT_M_M1_encodermotor.set_speed(int(fast), Motor.CCW)
TXT_M_M1_encodermotor.start_sync()
TXT_M_M2_encodermotor.set_speed(int(slow), Motor.CCW)
TXT_M_M2_encodermotor.start_sync()
else:
pass
<xml xmlns="https://developers.google.com/blockly/xml" version="16">
<block type="txt4_controller" id="v}Wf^VN(H6-Q3:$II]KJ" x="-1192" y="0">
<mutation>
<arg type="Input" name="Input-0" value="I1"/>
<arg type="Input" name="Input-1" value="I2"/>
<arg type="Input" name="Input-2" value="-"/>
<arg type="Output" name="Output-0" value="-"/>
<arg type="Motor" name="Motor-0" value="M1"/>
<arg type="Motor" name="Motor-1" value="M2"/>
<arg type="Motor" name="Motor-2" value="-"/>
<arg type="Servomotor" name="Servomotor-0" value="-"/>
<arg type="Counter" name="Counter-0" value="-"/>
<arg type="I2C" name="I2C-0" value="-"/>
<arg type="USB" name="USB-0" value="-"/>
</mutation>
<field name="mode">0</field>
<field name="controller_name">TXT</field>
<field name="Input-0">I1</field>
<field name="Input-1">I2</field>
<field name="Input-2">-</field>
<field name="Output-0">-</field>
<field name="Motor-0">M1</field>
<field name="Motor-1">M2</field>
<field name="Motor-2">-</field>
<field name="Servomotor-0">-</field>
<field name="Counter-0">-</field>
<field name="I2C-0">-</field>
<field name="USB-0">-</field>
<value name="Input-0">
<block type="color_sensor" id="Cb,bm9+r7-7W74Hrl(#o"/>
</value>
<value name="Input-1">
<block type="color_sensor" id=".4E+)YDXvIU)Q,IEW_#k"/>
</value>
<value name="Motor-0">
<block type="encodermotor" id="WpKi`VJ3XVuCOUuTc^=w">
<comment pinned="true" h="42" w="83">left motor</comment>
</block>
</value>
<value name="Motor-1">
<block type="encodermotor" id="7E{.a)tBHsGHIm^uK-lc">
<comment pinned="true" h="46" w="91">right motor</comment>
</block>
</value>
</block>
</xml>
\ No newline at end of file
import fischertechnik.factories as txt_factory
txt_factory.init()
txt_factory.init_input_factory()
txt_factory.init_motor_factory()
# left motor
# right motor
TXT_M = txt_factory.controller_factory.create_graphical_controller()
TXT_M_I1_color_sensor = txt_factory.input_factory.create_color_sensor(TXT_M, 1)
TXT_M_I2_color_sensor = txt_factory.input_factory.create_color_sensor(TXT_M, 2)
TXT_M_M1_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_M, 1)
TXT_M_M2_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_M, 2)
txt_factory.initialized()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment