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

commit by robo pro coding

parent 7baf261c
No related branches found
No related tags found
No related merge requests found
<xml xmlns="https://developers.google.com/blockly/xml" version="14">
<block type="start_block" id="$#]ESP+D}J$B]GY;Y`zp" deletable="false" x="0" y="125">
<block type="start_block" id="$#]ESP+D}J$B]GY;Y`zp" deletable="false" x="-68" y="-133">
<statement name="statement">
<block type="util_thread" id="nOZkJ)D$n=;X^0bV*uy_">
<field name="dropdown_event">]$}!d~iPi$faCfYn-,02</field>
<next>
<block type="loop_endless" id="]bji@o6zCyG=6j.U__2I"/>
<block type="util_thread" id="(0KVNNY(~d{_r/:Z)Y^$">
<field name="dropdown_event">O(u{V%63EG)8#o`:]GxN</field>
<next>
<block type="loop_endless" id="]bji@o6zCyG=6j.U__2I"/>
</next>
</block>
</next>
</block>
</statement>
......
......@@ -6,5 +6,6 @@ from lib.sorting_line import *
threading.Thread(target=thread_SLD, daemon=True).start()
threading.Thread(target=thread_blink, daemon=True).start()
while True:
pass
......@@ -5,10 +5,10 @@
<arg type="Input" name="Input-1" value="I2"/>
<arg type="Input" name="Input-2" value="-"/>
<arg type="Output" name="Output-0" value="O5"/>
<arg type="Output" name="Output-1" value="-"/>
<arg type="Output" name="Output-1" value="O7"/>
<arg type="Output" name="Output-2" 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="C1"/>
<arg type="Counter" name="Counter-1" value="C2"/>
......@@ -23,10 +23,10 @@
<field name="Input-1">I2</field>
<field name="Input-2">-</field>
<field name="Output-0">O5</field>
<field name="Output-1">-</field>
<field name="Output-1">O7</field>
<field name="Output-2">-</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">C1</field>
<field name="Counter-1">C2</field>
......@@ -43,6 +43,9 @@
<value name="Output-0">
<block type="led" id=":^baCXt_)quR(#FAUAv_"/>
</value>
<value name="Output-1">
<block type="led" id="p_cvEg8,=lbXzv}$b![7"/>
</value>
<value name="Motor-0">
<block type="encodermotor" id="ueH%w!w?!F?z}pP!QiP7"/>
</value>
......
......@@ -12,6 +12,7 @@ TXT_SLD_M = txt_factory.controller_factory.create_graphical_controller()
TXT_SLD_M_I1_photo_transistor = txt_factory.input_factory.create_photo_transistor(TXT_SLD_M, 1)
TXT_SLD_M_I2_mini_switch = txt_factory.input_factory.create_mini_switch(TXT_SLD_M, 2)
TXT_SLD_M_O5_led = txt_factory.output_factory.create_led(TXT_SLD_M, 5)
TXT_SLD_M_O7_led = txt_factory.output_factory.create_led(TXT_SLD_M, 7)
TXT_SLD_M_M1_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_SLD_M, 1)
TXT_SLD_M_M2_encodermotor = txt_factory.motor_factory.create_encodermotor(TXT_SLD_M, 2)
TXT_SLD_M_C1_motor_step_counter = txt_factory.counter_factory.create_encodermotor_counter(TXT_SLD_M, 1)
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -19,6 +19,7 @@ num = None
color = None
ts = None
filename = None
led_on = None
sat = None
hue = None
duration = None
......@@ -34,8 +35,20 @@ ts_process = None
key = None
def thread_blink():
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
while True:
if led_on:
TXT_SLD_M_O7_led.set_brightness(int(512))
time.sleep(0.2)
TXT_SLD_M_O7_led.set_brightness(int(0))
time.sleep(0.2)
else:
TXT_SLD_M_O7_led.set_brightness(int(0))
def MakePictureRunKiReturnFoundPart():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
reset_inteface()
TXT_SLD_M_O5_led.set_brightness(int(512))
time.sleep(0.2)
......@@ -56,7 +69,9 @@ def MakePictureRunKiReturnFoundPart():
ts_process0 = (time.time() * 1000)
detector = ObjectDetector('/opt/ft/workspaces/machine-learning/object-detection/sorting_line/model.tflite', '/opt/ft/workspaces/machine-learning/object-detection/sorting_line/labels.txt')
ts_process1 = (time.time() * 1000)
led_on = True
result = detector.process_image(frame)
led_on = False
ts_process = (time.time() * 1000)
print('processing time: {:.0f} ms {:.0f} ms'.format(ts_process1 - ts_process0, ts_process - ts_process1))
color = get_color()
......@@ -110,7 +125,7 @@ def MakePictureRunKiReturnFoundPart():
def reset_inteface():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
display.set_attr("part_pass_fail.text", str(containInHTML('i', 'Not analysed yet')))
display.set_attr("red.active", str(False).lower())
display.set_attr("blue.active", str(False).lower())
......@@ -118,12 +133,12 @@ def reset_inteface():
def containInHTML(tag, value):
global num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
return ''.join([str(x) for x in ['<', tag, '>', value, '</', tag, '>']])
def get_color():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
if hue >= 85 and hue < 130 and sat >= 40:
color = 3
elif (hue >= 130 and hue <= 180 or hue >= 0 and hue < 15) and sat >= 40:
......@@ -134,13 +149,13 @@ def get_color():
def timestamp():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
ts = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
return ts
def saveFileandPublish():
global tag, value, num, color, ts, filename, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
global tag, value, num, color, ts, filename, led_on, sat, hue, duration, prob, keytext, pos, frame, ts_process0, detector, ts_process1, result, ts_process, key
filename = '/opt/ft/workspaces/last-image.png'
if(pos != ""):
image = cv2.rectangle(frame, (pos[0], pos[1]), (pos[2], pos[3]), (180,105,0), 2)
......
......@@ -383,7 +383,7 @@
</shadow>
</value>
<value name="distance">
<shadow type="math_number">
<shadow type="math_number" id="NhW1Ds(ogg!pC}WO?UY#">
<field name="NUM">100</field>
</shadow>
<block type="variables_get" id="3Gm:9W@}pV?qp.tqb^AC">
......
......@@ -40,18 +40,6 @@ def moveRefM2():
TXT_SLD_M_M2_encodermotor.stop()
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)
def mainSLDexternal():
global MovementSpeedCam, MovementSpeed, posRED, posBLUE, posCam, i, posFinish, num
if TXT_SLD_M_I1_photo_transistor.is_dark():
......@@ -60,7 +48,7 @@ def mainSLDexternal():
print('start')
TXT_SLD_M_M1_encodermotor.set_speed(int(MovementSpeed * 0.5), Motor.CCW)
TXT_SLD_M_M1_encodermotor.start_sync()
for i in (0 <= float(posCam)) and upRange(0, float(posCam), 1) or downRange(0, float(posCam), 1):
for i in (0 <= posCam) and upRange(0, posCam, 1) or downRange(0, posCam, 1):
if not (TXT_SLD_M_I1_photo_transistor.is_dark()):
break
time.sleep(0.01)
......@@ -109,3 +97,13 @@ def mainSLDexternal():
if (not TXT_SLD_M_M1_encodermotor.is_running()):
break
time.sleep(0.010)
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)
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