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

commit by robo pro coding

parent 490c3ec4
Branches master
No related tags found
No related merge requests found
{"name":"omniwheels_x4_ball_gui","mode":"ADVANCED","uuid":"6ec6b5d7-4b7e-c7f3-0e27-2e1a1e3d7675"}
\ No newline at end of file
{"uuid":"6ec6b5d7-4b7e-c7f3-0e27-2e1a1e3d7675","name":"omniwheels_x4_ball_gui","mode":"ADVANCED","version":"1.0","controller":"TXT4"}
\ No newline at end of file
<xml xmlns="https://developers.google.com/blockly/xml" version="9">
<xml xmlns="https://developers.google.com/blockly/xml" version="16">
<block type="txt4_controller" id="8{TptiUJZcEtNILDxQ{v" x="33" y="40">
<mutation>
<arg type="Input" name="Input-0" value="-"/>
......
import fischertechnik.factories as txt_factory
txt_factory.init_controller_factory()
txt_factory.init()
txt_factory.init_motor_factory()
txt_factory.init_servomotor_factory()
txt_factory.init_counter_factory()
TXT_M = txt_factory.controller_factory.create_graphical_controller()
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_M_M3_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_M, 3)
TXT_M_M4_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_M, 4)
TXT_M_S1_servomotor = txt_factory.servomotor_factory.create_servomotor(TXT_M, 1)
TXT_M_C1_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT_M, 1)
TXT_M_C1_motor_step_counter.set_motor(TXT_M_M1_encodermotor)
TXT_M_C2_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT_M, 2)
TXT_M_C2_motor_step_counter.set_motor(TXT_M_M2_encodermotor)
TXT_M_C3_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT_M, 3)
TXT_M_C3_motor_step_counter.set_motor(TXT_M_M3_encodermotor)
TXT_M_C4_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT_M, 4)
TXT_M_C4_motor_step_counter.set_motor(TXT_M_M4_encodermotor)
TXT = txt_factory.controller_factory.create_graphical_controller()
TXT_M1_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT, 1)
TXT_M2_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT, 2)
TXT_M3_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT, 3)
TXT_M4_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT, 4)
TXT_S1_servomotor = txt_factory.servomotor_factory.create_servomotor(TXT, 1)
TXT_C1_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT, 1)
TXT_C1_motor_step_counter.set_motor(TXT_M1_encodermotor)
TXT_C2_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT, 2)
TXT_C2_motor_step_counter.set_motor(TXT_M2_encodermotor)
TXT_C3_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT, 3)
TXT_C3_motor_step_counter.set_motor(TXT_M3_encodermotor)
TXT_C4_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT, 4)
TXT_C4_motor_step_counter.set_motor(TXT_M4_encodermotor)
txt_factory.initialized()
\ No newline at end of file
......@@ -14,7 +14,10 @@ TXTWindow {
TXTButton {
id: txt_button_sideways
text: "sideways"
font.pixelSize: 24
font.pixelSize: 22
font.bold: false
font.italic: false
font.underline: false
enabled: true
x: 20
y: 40
......@@ -24,7 +27,10 @@ TXTWindow {
TXTButton {
id: txt_button_fire
text: "FIRE"
font.pixelSize: 24
font.pixelSize: 22
font.bold: false
font.italic: false
font.underline: false
enabled: true
x: 60
y: 160
......@@ -34,7 +40,10 @@ TXTWindow {
TXTButton {
id: txt_button_rotation
text: "rotation"
font.pixelSize: 24
font.pixelSize: 22
font.bold: false
font.italic: false
font.underline: false
enabled: true
x: 20
y: 90
......@@ -44,7 +53,10 @@ TXTWindow {
TXTCheckBox {
id: txt_checkbox
text: "fire ball"
font.pixelSize: 24
font.pixelSize: 22
font.bold: false
font.italic: false
font.underline: false
checked: false
enabled: true
x: 130
......
<xml xmlns="https://developers.google.com/blockly/xml" version="9">
<xml xmlns="https://developers.google.com/blockly/xml" version="16">
<variables>
<variable id="K0Gtdk#Vo1Aoxm-21zA9">pos_load</variable>
<variable id="yrAHI1`;y]_]WX.Xh:G5">ball_fire</variable>
......@@ -12,7 +12,7 @@
<field name="VAR" id="K0Gtdk#Vo1Aoxm-21zA9">pos_load</field>
<value name="VALUE">
<block type="math_number" id="54;I5)ibSz6#Mw@Dp@_^">
<field name="NUM">110</field>
<field name="NUM">20</field>
</block>
</value>
<next>
......@@ -28,7 +28,7 @@
</value>
<value name="B">
<block type="math_number" id="BTU}G8=3$F#bkfEZ/8|x">
<field name="NUM">120</field>
<field name="NUM">210</field>
</block>
</value>
</block>
......@@ -46,7 +46,7 @@
</value>
<value name="B">
<block type="math_number" id="2j)VURoGQH!49h)=y2Dz">
<field name="NUM">250</field>
<field name="NUM">300</field>
</block>
</value>
</block>
......@@ -71,7 +71,7 @@
</block>
</statement>
</block>
<block type="display_on_button_clicked" id="Rb)T`*)ZljgN5@iHfoT4" x="0" y="311">
<block type="display_on_button_clicked" id="Rb)T`*)ZljgN5@iHfoT4" x="0" y="281">
<field name="instance_name">txt_button_sideways</field>
<statement name="statement">
<block type="procedures_callnoreturn" id="+8oXS#j|71)NgQRtTt]n">
......@@ -79,7 +79,7 @@
</block>
</statement>
</block>
<block type="display_on_button_clicked" id=";4n4ySQCV.[-*H:ZS!15" x="0" y="432">
<block type="display_on_button_clicked" id=";4n4ySQCV.[-*H:ZS!15" x="0" y="392">
<field name="instance_name">txt_button_rotation</field>
<statement name="statement">
<block type="procedures_callnoreturn" id="~6zs7huaFHitcDSq3qHp">
......@@ -87,7 +87,7 @@
</block>
</statement>
</block>
<block type="display_on_button_clicked" id="R_c*EUhhLF;Q{#efzh~u" x="0" y="553">
<block type="display_on_button_clicked" id="R_c*EUhhLF;Q{#efzh~u" x="0" y="503">
<field name="instance_name">txt_button_fire</field>
<statement name="statement">
<block type="procedures_callnoreturn" id="%pA_0IjJ)jlhV+~TykEL">
......@@ -109,7 +109,7 @@
</block>
</statement>
</block>
<block type="display_on_checkbox_checked" id="-O~5kjZL9FD1O$HQJ.Or" x="0" y="766">
<block type="display_on_checkbox_checked" id="-O~5kjZL9FD1O$HQJ.Or" x="0" y="696">
<field name="instance_name">txt_checkbox</field>
<statement name="statement">
<block type="variables_set" id="FUT/gP!2z-@Mz{Kx9VA/">
......@@ -123,7 +123,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="*ZBBSL{rLjb#j7QmLB$3" x="0" y="887">
<block type="procedures_defnoreturn" id="*ZBBSL{rLjb#j7QmLB$3" x="0" y="807">
<field name="NAME">move_sideways</field>
<statement name="STACK">
<block type="controls_repeat_ext" id="MZPR[ubL}m0Yup)Emk9S">
......@@ -135,13 +135,13 @@
<statement name="DO">
<block type="encodermotor_set_values" id="0nkU{D%HN^CqJ#^sJeh?">
<mutation syncBlocks="3"/>
<field name="instance_name_0">TXT_M1_encodermotor</field>
<field name="instance_name_0">8{TptiUJZcEtNILDxQ{v-{rysZI,3YP_6v#XhNpvZ</field>
<field name="direction_0">Motor.CW</field>
<field name="instance_name_1">TXT_M2_encodermotor</field>
<field name="instance_name_1">8{TptiUJZcEtNILDxQ{v-yO1I)s#C@g%c_dj0j5XX</field>
<field name="direction_1">Motor.CCW</field>
<field name="instance_name_2">TXT_M3_encodermotor</field>
<field name="instance_name_2">8{TptiUJZcEtNILDxQ{v-=]cP{EP0D#,_n-9CH*3$</field>
<field name="direction_2">Motor.CCW</field>
<field name="instance_name_3">TXT_M4_encodermotor</field>
<field name="instance_name_3">8{TptiUJZcEtNILDxQ{v-B=Qh@$y54:z`*fY6uxyn</field>
<field name="direction_3">Motor.CW</field>
<value name="speed">
<shadow type="motor_number" id="42+TW3Hk84|RaxeL{P/3">
......@@ -157,7 +157,7 @@
<block type="util_wait_until" id="2%!TzJVEAiBT@OcyA)J5">
<value name="value">
<block type="encodermotor_position_read" id="HqocORz;/aVIKc:$Zfv)">
<field name="instance_name_0">TXT_M1_encodermotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-{rysZI,3YP_6v#XhNpvZ</field>
</block>
</value>
<next>
......@@ -181,7 +181,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id=")bSGwzYJzA=zl)G$s_]^" x="0" y="1318">
<block type="procedures_defnoreturn" id=")bSGwzYJzA=zl)G$s_]^" x="0" y="1188">
<field name="NAME">move_rotate</field>
<statement name="STACK">
<block type="controls_repeat_ext" id="Y-5m,bG1GvYo0KcctER[">
......@@ -193,13 +193,13 @@
<statement name="DO">
<block type="encodermotor_set_values" id="ZJmASoqCfOfnI^Hk6q*_">
<mutation syncBlocks="3"/>
<field name="instance_name_0">TXT_M1_encodermotor</field>
<field name="instance_name_0">8{TptiUJZcEtNILDxQ{v-{rysZI,3YP_6v#XhNpvZ</field>
<field name="direction_0">Motor.CW</field>
<field name="instance_name_1">TXT_M2_encodermotor</field>
<field name="instance_name_1">8{TptiUJZcEtNILDxQ{v-yO1I)s#C@g%c_dj0j5XX</field>
<field name="direction_1">Motor.CCW</field>
<field name="instance_name_2">TXT_M3_encodermotor</field>
<field name="instance_name_2">8{TptiUJZcEtNILDxQ{v-=]cP{EP0D#,_n-9CH*3$</field>
<field name="direction_2">Motor.CW</field>
<field name="instance_name_3">TXT_M4_encodermotor</field>
<field name="instance_name_3">8{TptiUJZcEtNILDxQ{v-B=Qh@$y54:z`*fY6uxyn</field>
<field name="direction_3">Motor.CCW</field>
<value name="speed">
<shadow type="motor_number" id="@gj%f#!R/JDJ4b-u*F3)">
......@@ -215,7 +215,7 @@
<block type="util_wait_until" id="v/Qoi5n/}_Hj2D$18Rww">
<value name="value">
<block type="encodermotor_position_read" id="~%V*2j+_5Ld|n`#_c^T$">
<field name="instance_name_0">TXT_M1_encodermotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-{rysZI,3YP_6v#XhNpvZ</field>
</block>
</value>
<next>
......@@ -239,12 +239,12 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="1Dw7E1(|5Avp9gB^X.eR" x="0" y="1749">
<block type="procedures_defnoreturn" id="1Dw7E1(|5Avp9gB^X.eR" x="0" y="1569">
<field name="NAME">load</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="servomotor_set_position" id="H$J`%NZ1y`h6;4uDlN0(">
<field name="instance_name">TXT_S1_servomotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-)DP%aR*=GdIU+-QrMmRa</field>
<value name="position">
<shadow type="servomotor_number" id="A7pPSxIhH-%.pn_QG,_H">
<field name="SERVOMOTOR_NUM">150</field>
......@@ -287,7 +287,7 @@
</value>
<statement name="DO">
<block type="servomotor_set_position" id="TaEboacteY3[7Xt4YP?B">
<field name="instance_name">TXT_S1_servomotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-)DP%aR*=GdIU+-QrMmRa</field>
<value name="position">
<shadow type="servomotor_number" id="~|A!4OBbH-=.~IPrP-e+">
<field name="SERVOMOTOR_NUM">0</field>
......@@ -315,12 +315,12 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="JX?1wChDV;hs:_eGfmwP" x="0" y="2030">
<block type="procedures_defnoreturn" id="JX?1wChDV;hs:_eGfmwP" x="0" y="1820">
<field name="NAME">fire</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>
<statement name="STACK">
<block type="servomotor_set_position" id="IrV+%M@g!dtB,9x_w@xJ">
<field name="instance_name">TXT_S1_servomotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-)DP%aR*=GdIU+-QrMmRa</field>
<value name="position">
<shadow type="servomotor_number" id="OKI74T,;l0l{rGOm#^.l">
<field name="SERVOMOTOR_NUM">310</field>
......@@ -334,12 +334,12 @@
<field name="format">ms</field>
<value name="value">
<shadow type="math_number" id="Tt}%EwlUkH~^l-%xMMkM">
<field name="NUM">200</field>
<field name="NUM">100</field>
</shadow>
</value>
<next>
<block type="servomotor_set_position" id="Ic[I/o1cGvq1n6I!g%{)">
<field name="instance_name">TXT_S1_servomotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-)DP%aR*=GdIU+-QrMmRa</field>
<value name="position">
<shadow type="servomotor_number" id="9[!!^la[FL|n?Ha^cXJy">
<field name="SERVOMOTOR_NUM">100</field>
......@@ -358,7 +358,7 @@
</value>
<next>
<block type="servomotor_set_position" id="2x53fWkg,yqbP,eL.xe3">
<field name="instance_name">TXT_S1_servomotor</field>
<field name="instance_name">8{TptiUJZcEtNILDxQ{v-)DP%aR*=GdIU+-QrMmRa</field>
<value name="position">
<shadow type="servomotor_number" id="/Ws_fy,#ujFj:|lOd]d`">
<field name="SERVOMOTOR_NUM">260</field>
......
from lib.display import *
from lib.controller import *
from fischertechnik.controller.Motor import Motor
import time
from fischertechnik.controller.Motor import Motor
from lib.controller import *
from lib.display import *
pos_load = None
ball_fire = None
......@@ -10,36 +9,39 @@ pos_n = None
pos_f = None
i = None
def on_txt_button_sideways_clicked(event):
global pos_load, ball_fire, pos_n, pos_f, i
move_sideways()
def on_txt_button_rotation_clicked(event):
global pos_load, ball_fire, pos_n, pos_f, i
move_rotate()
def on_txt_button_fire_clicked(event):
global pos_load, ball_fire, pos_n, pos_f, i
load()
for count in range(3):
fire()
def on_txt_checkbox_toggled(event):
global pos_load, ball_fire, pos_n, pos_f, i
ball_fire = bool(event['checked'])
def move_sideways():
global pos_load, ball_fire, pos_n, pos_f, i
for count2 in range(3):
TXT_M1_encodermotor.set_speed(int(512), Motor.CW)
TXT_M2_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M3_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M4_encodermotor.set_speed(int(512), Motor.CW)
TXT_M1_encodermotor.set_distance(int(200), TXT_M2_encodermotor, TXT_M3_encodermotor, TXT_M4_encodermotor)
TXT_M_M1_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M1_encodermotor.set_distance(int(200), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M1_encodermotor.is_running()):
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
if ball_fire:
......@@ -49,47 +51,37 @@ def move_sideways():
def move_rotate():
global pos_load, ball_fire, pos_n, pos_f, i
for count3 in range(3):
TXT_M1_encodermotor.set_speed(int(512), Motor.CW)
TXT_M2_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M3_encodermotor.set_speed(int(512), Motor.CW)
TXT_M4_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M1_encodermotor.set_distance(int(100), TXT_M2_encodermotor, TXT_M3_encodermotor, TXT_M4_encodermotor)
TXT_M_M1_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(512), Motor.CCW)
TXT_M_M1_encodermotor.set_distance(int(100), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M1_encodermotor.is_running()):
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
if ball_fire:
fire()
def upRange(start, stop, step):
while start <= stop:
yield start
start += abs(step)
def downRange(start, stop, step):
while start >= stop:
yield start
start -= abs(step)
# Describe this function...
def load():
global pos_load, ball_fire, pos_n, pos_f, i
TXT_S1_servomotor.set_position(int(pos_load))
TXT_M_S1_servomotor.set_position(int(pos_load))
time.sleep(0.3)
for i in (float(pos_load) <= float(pos_n)) and upRange(float(pos_load), float(pos_n), 5) or downRange(float(pos_load), float(pos_n), 5):
TXT_S1_servomotor.set_position(int(i))
for i in (pos_load <= pos_n) and upRange(pos_load, pos_n, 5) or downRange(pos_load, pos_n, 5):
TXT_M_S1_servomotor.set_position(int(i))
time.sleep(0.005)
# Describe this function...
def fire():
global pos_load, ball_fire, pos_n, pos_f, i
TXT_S1_servomotor.set_position(int(pos_f))
time.sleep(0.2)
TXT_S1_servomotor.set_position(int(pos_load))
TXT_M_S1_servomotor.set_position(int(pos_f))
time.sleep(0.1)
TXT_M_S1_servomotor.set_position(int(pos_load))
time.sleep(0.3)
TXT_S1_servomotor.set_position(int(pos_n))
TXT_M_S1_servomotor.set_position(int(pos_n))
time.sleep(0.3)
......@@ -98,12 +90,20 @@ display.button_clicked("txt_button_rotation", on_txt_button_rotation_clicked)
display.button_clicked("txt_button_fire", on_txt_button_fire_clicked)
display.checkbox_toggled("txt_checkbox", on_txt_checkbox_toggled)
def upRange(start, stop, step):
while start <= stop:
yield start
start += abs(step)
def downRange(start, stop, step):
while start >= stop:
yield start
start -= abs(step)
pos_load = 110
pos_n = pos_load + 120
pos_f = pos_load + 250
pos_load = 20
pos_n = pos_load + 210
pos_f = pos_load + 300
ball_fire = False
while True:
pass
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