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

commit by robo pro coding

parents
No related branches found
No related tags found
No related merge requests found
{"name":"omniwheels_x4_soccer_goal","mode":"ADVANCED","uuid":"5cee2f40-1592-343a-6d7e-a28532502696"}
\ No newline at end of file
# auto generated content from camera configuration
from lib.controller import *
import fischertechnik.factories as txt_factory
TXT_M_USB_1_camera.set_rotate(False)
TXT_M_USB_1_camera.set_height(240)
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, [255,143,81], 10)
TXT_M_USB_1_camera.add_detector(ball_detector)
blocked_area_right = txt_factory.camera_factory.create_blocked_area(240, 190, 80, 50)
TXT_M_USB_1_camera.add_blocked_area(blocked_area_right)
blocked_area_left = txt_factory.camera_factory.create_blocked_area(0, 190, 80, 50)
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, [245,194,79], 25)
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, [192,57,54], 25)
TXT_M_USB_1_camera.add_detector(ball_detector_goal_left)
<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>#ff8f51</color><tolerance>10</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>#f5c24f</color><tolerance>25</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>#c03936</color><tolerance>25</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 xmlns="https://developers.google.com/blockly/xml" version="12">
<block type="txt4_controller" id="sntDv!Tiig{o,Dn5u$|t" x="27" y="27">
<mutation>
<arg type="Input" name="Input-0" value="I8"/>
<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="M3"/>
<arg type="Motor" name="Motor-3" value="M4"/>
<arg type="Servomotor" name="Servomotor-0" value="S1"/>
<arg type="Servomotor" name="Servomotor-1" value="-"/>
<arg type="Counter" name="Counter-0" value="C1"/>
<arg type="Counter" name="Counter-1" value="C2"/>
<arg type="Counter" name="Counter-2" value="C3"/>
<arg type="Counter" name="Counter-3" value="C4"/>
<arg type="I2C" name="I2C-0" value="-"/>
<arg type="USB" name="USB-0" value="USB_1"/>
<arg type="USB" name="USB-1" value="-"/>
</mutation>
<field name="mode">0</field>
<field name="controller_name">TXT</field>
<field name="Input-0">I8</field>
<field name="Output-0">-</field>
<field name="Motor-0">M1</field>
<field name="Motor-1">M2</field>
<field name="Motor-2">M3</field>
<field name="Motor-3">M4</field>
<field name="Servomotor-0">S1</field>
<field name="Servomotor-1">-</field>
<field name="Counter-0">C1</field>
<field name="Counter-1">C2</field>
<field name="Counter-2">C3</field>
<field name="Counter-3">C4</field>
<field name="I2C-0">-</field>
<field name="USB-0">USB_1</field>
<field name="USB-1">-</field>
<value name="Input-0">
<block type="photo_transistor" id="_7y+A9(=#S#C#aBLOH:P"/>
</value>
<value name="Motor-0">
<block type="encodermotor" id="*8OJtR8}RNdlVMAUz-+9"/>
</value>
<value name="Motor-1">
<block type="encodermotor" id="58S=,r8vw1!2Kd)wmT16"/>
</value>
<value name="Motor-2">
<block type="encodermotor" id="caWY[W%z[0LKsAi*i)H="/>
</value>
<value name="Motor-3">
<block type="encodermotor" id="@t*#k=[E=0j]@a3VU!./"/>
</value>
<value name="Servomotor-0">
<block type="servomotor" id="!U~ax;zrh#e{zXqJ86G3"/>
</value>
<value name="Counter-0">
<block type="motor_step_counter" id="sD8[5gCg~ME^kIJI/:28">
<field name="instance_name">M1</field>
</block>
</value>
<value name="Counter-1">
<block type="motor_step_counter" id=".W@p?}v_GmkKnM.hRwAV">
<field name="instance_name">M2</field>
</block>
</value>
<value name="Counter-2">
<block type="motor_step_counter" id="qle2YCIQo%{gP+nHz$QV">
<field name="instance_name">M3</field>
</block>
</value>
<value name="Counter-3">
<block type="motor_step_counter" id="khyboL4/hJ@)yil3lSo*">
<field name="instance_name">M4</field>
</block>
</value>
<value name="USB-0">
<block type="camera" id="^!_o6FtR`]6faZslb[]{"/>
</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()
txt_factory.init_servomotor_factory()
txt_factory.init_counter_factory()
txt_factory.init_usb_factory()
txt_factory.init_camera_factory()
TXT_M = txt_factory.controller_factory.create_graphical_controller()
TXT_M_I8_photo_transistor = txt_factory.input_factory.create_photo_transistor(TXT_M, 8)
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_M_USB_1_camera = txt_factory.usb_factory.create_camera(TXT_M, 1)
txt_factory.initialized()
\ No newline at end of file
import os
import time
import threading
import signal
import ftgui
display = ftgui.fttxt2_gui_connector("app")
display.open()
def display_monitoring():
while display.is_open():
time.sleep(1)
os.kill(os.getpid(), signal.SIGTERM)
exit()
threading.Thread(target=display_monitoring, daemon=True).start()
// auto generated content from display configuration
import QtQuick 2.2
import QtQuick.Window 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Extras 1.4
TXTWindow {
Rectangle {
id: rect
color: "grey"
anchors.fill: parent
}
TXTSwitch {
id: txt_switch_active
text: "active"
font.pixelSize: 16
enabled: true
checked: false
x: 60
y: 171
width: 100
height: 40
}
TXTLabel {
id: txt_label_ball
text: "-"
font.pixelSize: 16
elide: Text.ElideRight
x: 60
y: 40
width: 100
height: 40
}
TXTLabel {
id: txt_label_goal
text: "-"
font.pixelSize: 16
elide: Text.ElideRight
x: 60
y: 100
width: 100
height: 40
}
TXTLabel {
id: txt_label_ball_
text: "ball"
font.pixelSize: 16
elide: Text.ElideRight
x: 20
y: 40
width: 39
height: 40
}
TXTLabel {
id: txt_label_goal_
text: "goal"
font.pixelSize: 16
elide: Text.ElideRight
x: 20
y: 99
width: 39
height: 40
}
}
<xml type="display" version="2"><item id="4" class="TXTSwitch"><name>txt_switch_active</name><enabled>true</enabled><checked>false</checked><text>active</text><geometry><x>60</x><y>171</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>40</y><width>100</width><height>40</height></geometry></item><item id="6" class="TXTLabel"><name>txt_label_goal</name><text>-</text><geometry><x>60</x><y>100</y><width>100</width><height>40</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label_ball_</name><text>ball</text><geometry><x>20</x><y>40</y><width>39</width><height>40</height></geometry></item><item id="8" class="TXTLabel"><name>txt_label_goal_</name><text>goal</text><geometry><x>20</x><y>99</y><width>39</width><height>40</height></geometry></item></xml>
\ No newline at end of file
This diff is collapsed.
import time
import math
from lib.controller import *
from lib.display import *
from lib.camera import *
from fischertechnik.controller.Motor import Motor
v = None
ticks = None
factor_x = None
ts_ball = None
ts_goal_left = None
ts_goal_right = None
factor_y = None
dist_x = None
posx_ball = None
speed_y = None
posx_goal = None
posy_ball = None
x_min = None
x_max = None
y_min = None
y_max = None
v_slow = None
v_fast = None
def checkTimeouts():
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if (time.time() * 1000) - ts_ball > 500:
posx_ball = None
posy_ball = None
if (time.time() * 1000) - ts_goal_left > 500:
posx_goal[0] = None
if (time.time() * 1000) - ts_goal_right > 500:
posx_goal[1] = None
def ball_callback(event):
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
ts_ball = (time.time() * 1000)
dist_x = round(math.fabs(event.value.x) * factor_x)
speed_y = round(min(max(math.fabs(event.value.y) * factor_y + v_slow, 0), 512))
posx_ball = event.value.x
posy_ball = event.value.y
print('posx:{} posy:{} dist_x:{} speed_y:{}'.format(event.value.x, event.value.y, dist_x, speed_y))
ball_detector.add_detection_listener(ball_callback)
def ball_callback2(event):
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
ts_goal_left = (time.time() * 1000)
posx_goal[0] = event.value.x
print('goal left: posx:{} posy:{}'.format(event.value.x, event.value.y))
ball_detector_goal_left.add_detection_listener(ball_callback2)
def ball_callback23(event):
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
ts_goal_right = (time.time() * 1000)
posx_goal[1] = event.value.x
print('goal right: posx:{} posy:{}'.format(event.value.x, event.value.y))
ball_detector_goal_right.add_detection_listener(ball_callback23)
def fwd_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def bwd_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def left_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def sideleft_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def right_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def sideright_v(v):
global ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M1_encodermotor.start_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def stop():
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_M1_encodermotor.stop_sync(TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
def fwd(v, ticks):
global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if ticks > 0:
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M1_encodermotor.set_distance(int(ticks), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
def bwd(v, ticks):
global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if ticks > 0:
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M1_encodermotor.set_distance(int(ticks), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
def left(v, ticks):
global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if ticks > 0:
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M1_encodermotor.set_distance(int(ticks), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
def right(v, ticks):
global factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if ticks > 0:
TXT_M_M1_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M3_encodermotor.set_speed(int(v), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(v), Motor.CCW)
TXT_M_M1_encodermotor.set_distance(int(ticks), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
def turnLeft():
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
left(512, 100)
time.sleep(2)
right(512, 100)
def turnRight():
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
right(512, 100)
time.sleep(2)
left(512, 100)
def callback(event):
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
if TXT_M_I8_photo_transistor.is_dark():
shotBall()
TXT_M_I8_photo_transistor.add_change_listener("dark", callback)
def shotBall():
global v, ticks, factor_x, ts_ball, ts_goal_left, ts_goal_right, factor_y, dist_x, posx_ball, speed_y, posx_goal, posy_ball, x_min, x_max, y_min, y_max, v_slow, v_fast
TXT_M_S1_servomotor.set_position(int(400))
TXT_M_M1_encodermotor.set_speed(int(512), Motor.CCW)
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.CCW)
TXT_M_M1_encodermotor.set_distance(int(100), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
time.sleep(0.05)
TXT_M_S1_servomotor.set_position(int(256))
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
TXT_M_M1_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M2_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M3_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M4_encodermotor.set_speed(int(512), Motor.CW)
TXT_M_M1_encodermotor.set_distance(int(40), TXT_M_M2_encodermotor, TXT_M_M3_encodermotor, TXT_M_M4_encodermotor)
while True:
if (not TXT_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
TXT_M.get_loudspeaker().play("26_Augenzwinkern.wav", False)
while True:
if (not (TXT_M.get_loudspeaker().is_playing())):
break
time.sleep(0.010)
factor_x = 0.2
factor_y = 3.5
speed_y = 300
x_min = -3
x_max = 3
y_min = 7
y_max = 74
v_slow = 300
v_fast = 512
posx_goal = [None, None]
posx_ball = None
posy_ball = None
ts_ball = (time.time() * 1000)
ts_goal_left = (time.time() * 1000)
ts_goal_right = (time.time() * 1000)
while True:
checkTimeouts()
if display.get_attr("txt_switch_active.checked"):
if posx_ball != None and posy_ball != None and posx_goal[0] != None and posx_goal[1] != None:
if posx_goal < x_min:
sideleft_v(180)
elif posx_goal > x_max:
sideright_v(180)
elif posx_ball < x_min:
left(v_slow, dist_x)
elif posx_ball > x_max:
right(v_slow, dist_x)
else:
if posy_ball >= y_min:
fwd_v(v_fast)
elif posy_ball < y_max:
fwd_v(speed_y)
else:
left_v(speed_y)
else:
pass
display.set_attr("txt_label_ball.text", str('x:{}, y:{}'.format(posx_ball, posy_ball)))
display.set_attr("txt_label_goal.text", str('x:{}'.format(posx_goal)))
time.sleep(0.1)
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