Simulation mode
This commit is contained in:
parent
d92ceafa57
commit
d0083ed33f
34
get_specs.py
34
get_specs.py
@ -30,24 +30,24 @@ def query_search(partnum, source):
|
|||||||
fprint("Searching for " + partnum)
|
fprint("Searching for " + partnum)
|
||||||
if source == "Belden":
|
if source == "Belden":
|
||||||
token_url = "https://www.belden.com/coveo/rest/token?t=" + str(int(time.time()))
|
token_url = "https://www.belden.com/coveo/rest/token?t=" + str(int(time.time()))
|
||||||
with requests.get(token_url) as r:
|
|
||||||
out = json.loads(r.content)
|
|
||||||
token = out["token"]
|
|
||||||
search_url = "https://www.belden.com/coveo/rest/search"
|
|
||||||
|
|
||||||
# Ridiculous search parameters extracted from website. Do not touch
|
|
||||||
search_data = r"""{ "q": "{QUERY}", "sortCriteria": "relevancy", "numberOfResults": "250", "sortCriteria": "@catalogitemwebdisplaypriority ascending", "searchHub": "products-only-search", "pipeline": "Site Search", "maximumAge": "900000", "tab": "products-search", "locale": "en", "aq": "(NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B)) ((@syssource==\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\" @catalogitemprimarycategorypublished==true)) ((@catalogitemregionavailable=Global) (@z95xlanguage==en))", "cq": "((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\"Coveo_web_index - rg-nc-prod-sitecore-prod\")) OR (@source==(\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\",\"website_001002_Category_index-rg-nc-prod-sitecore-prod\"))", "firstResult": "0" }, "categoryFacets": "[{\"field\":\"@catalogitemcategories\",\"path\":[],\"injectionDepth\":1000,\"maximumNumberOfValues\":6,\"delimitingCharacter\":\"|\"}]", "facetOptions": "{}", "groupBy": " [{\"field\":\"@contenttype\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[\"Products\"],\"queryOverride\":\"{QUERY}\",\"advancedQueryOverride\":\"(NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B)) ((((((((@z95xpath=3324AF2D58F64C0FB725521052F679D2 @z95xid<>3324AF2D58F64C0FB725521052F679D2) ((@z95xpath=C292F3A37B3A4E6BAB345DF87ADDE516 @z95xid<>C292F3A37B3A4E6BAB345DF87ADDE516) @z95xtemplate==E4EFEB787BDC4B1A908EFC64D56CB2A4)) OR ((@z95xpath=723501A864754FEEB8AE377E4C710271 @z95xid<>723501A864754FEEB8AE377E4C710271) ((@z95xpath=600114EAB0E5407A84AAA9F0985B6575 @z95xid<>600114EAB0E5407A84AAA9F0985B6575) @z95xtemplate==2BE4FD6B3B2C49EBBD9E1F6C92238B05))) OR (@syssource==\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\" @catalogitemprimarycategorypublished==true)) OR ((@z95xpath=3324AF2D58F64C0FB725521052F679D2 @z95xid<>3324AF2D58F64C0FB725521052F679D2) @z95xpath<>C292F3A37B3A4E6BAB345DF87ADDE516)) OR @syssource==\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\") NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B))) ((@catalogitemregionavailable=Global) (@z95xlanguage==en) OR (@contenttype=(Blogs,Resources,Other)) (NOT @ez120xcludefromcoveo==1))\",\"constantQueryOverride\":\"((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\\"Coveo_web_index - rg-nc-prod-sitecore-prod\\")) OR (@source==(\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\",\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\"))\"},{\"field\":\"@catalogitembrand\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@catalogitemenvironment\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@catalogitemregionalavailability\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@prez45xtez120xt\",\"maximumNumberOfValues\":5,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@tags\",\"maximumNumberOfValues\":4,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetassettype\",\"maximumNumberOfValues\":3,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetbrand\",\"maximumNumberOfValues\":3,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetmarket\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetsolution\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetsearchcontentpagetype\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]}]" }"""
|
|
||||||
search_data = search_data.replace(r"{QUERY}", partnum)
|
|
||||||
#"aq": "", "cq": "((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\\"Coveo_web_index - rg-nc-prod-sitecore-prod\\")) OR (@source==(\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\",\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\"))", "firstResult": "0", "categoryFacets": "[{\\"field\\":\\"@catalogitemcategories\\",\\"path\\":[],\\"injectionDepth\\":1000,\\"maximumNumberOfValues\\":6,\\"delimitingCharacter\\":\\"|\\"}]", "facetOptions": "{}", "groupBy": "" }'
|
|
||||||
#fprint(search_data)
|
|
||||||
#fprint(json.loads(search_data))
|
|
||||||
#search_data = '{ "q": "' + str(partnum) + '" }'
|
|
||||||
#fprint(search_data)
|
|
||||||
headers = headers = {
|
|
||||||
'Authorization': f'Bearer {token}',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
|
with requests.get(token_url) as r:
|
||||||
|
out = json.loads(r.content)
|
||||||
|
token = out["token"]
|
||||||
|
search_url = "https://www.belden.com/coveo/rest/search"
|
||||||
|
|
||||||
|
# Ridiculous search parameters extracted from website. Do not touch
|
||||||
|
search_data = r"""{ "q": "{QUERY}", "sortCriteria": "relevancy", "numberOfResults": "250", "sortCriteria": "@catalogitemwebdisplaypriority ascending", "searchHub": "products-only-search", "pipeline": "Site Search", "maximumAge": "900000", "tab": "products-search", "locale": "en", "aq": "(NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B)) ((@syssource==\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\" @catalogitemprimarycategorypublished==true)) ((@catalogitemregionavailable=Global) (@z95xlanguage==en))", "cq": "((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\"Coveo_web_index - rg-nc-prod-sitecore-prod\")) OR (@source==(\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\",\"website_001002_Category_index-rg-nc-prod-sitecore-prod\"))", "firstResult": "0" }, "categoryFacets": "[{\"field\":\"@catalogitemcategories\",\"path\":[],\"injectionDepth\":1000,\"maximumNumberOfValues\":6,\"delimitingCharacter\":\"|\"}]", "facetOptions": "{}", "groupBy": " [{\"field\":\"@contenttype\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[\"Products\"],\"queryOverride\":\"{QUERY}\",\"advancedQueryOverride\":\"(NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B)) ((((((((@z95xpath=3324AF2D58F64C0FB725521052F679D2 @z95xid<>3324AF2D58F64C0FB725521052F679D2) ((@z95xpath=C292F3A37B3A4E6BAB345DF87ADDE516 @z95xid<>C292F3A37B3A4E6BAB345DF87ADDE516) @z95xtemplate==E4EFEB787BDC4B1A908EFC64D56CB2A4)) OR ((@z95xpath=723501A864754FEEB8AE377E4C710271 @z95xid<>723501A864754FEEB8AE377E4C710271) ((@z95xpath=600114EAB0E5407A84AAA9F0985B6575 @z95xid<>600114EAB0E5407A84AAA9F0985B6575) @z95xtemplate==2BE4FD6B3B2C49EBBD9E1F6C92238B05))) OR (@syssource==\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\" @catalogitemprimarycategorypublished==true)) OR ((@z95xpath=3324AF2D58F64C0FB725521052F679D2 @z95xid<>3324AF2D58F64C0FB725521052F679D2) @z95xpath<>C292F3A37B3A4E6BAB345DF87ADDE516)) OR @syssource==\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\") NOT @z95xtemplate==(ADB6CA4F03EF4F47B9AC9CE2BA53FF97,FE5DD82648C6436DB87A7C4210C7413B))) ((@catalogitemregionavailable=Global) (@z95xlanguage==en) OR (@contenttype=(Blogs,Resources,Other)) (NOT @ez120xcludefromcoveo==1))\",\"constantQueryOverride\":\"((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\\"Coveo_web_index - rg-nc-prod-sitecore-prod\\")) OR (@source==(\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\",\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\"))\"},{\"field\":\"@catalogitembrand\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@catalogitemenvironment\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@catalogitemregionalavailability\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@prez45xtez120xt\",\"maximumNumberOfValues\":5,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@tags\",\"maximumNumberOfValues\":4,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetassettype\",\"maximumNumberOfValues\":3,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetbrand\",\"maximumNumberOfValues\":3,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetmarket\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetsolution\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]},{\"field\":\"@facetsearchcontentpagetype\",\"maximumNumberOfValues\":6,\"sortCriteria\":\"occurrences\",\"injectionDepth\":1000,\"completeFacetWithStandardValues\":true,\"allowedValues\":[]}]" }"""
|
||||||
|
search_data = search_data.replace(r"{QUERY}", partnum)
|
||||||
|
#"aq": "", "cq": "((@z95xlanguage==en) (@z95xlatestversion==1) (@source==\\"Coveo_web_index - rg-nc-prod-sitecore-prod\\")) OR (@source==(\\"website_001002_catalog_index-rg-nc-prod-sitecore-prod\\",\\"website_001002_Category_index-rg-nc-prod-sitecore-prod\\"))", "firstResult": "0", "categoryFacets": "[{\\"field\\":\\"@catalogitemcategories\\",\\"path\\":[],\\"injectionDepth\\":1000,\\"maximumNumberOfValues\\":6,\\"delimitingCharacter\\":\\"|\\"}]", "facetOptions": "{}", "groupBy": "" }'
|
||||||
|
#fprint(search_data)
|
||||||
|
#fprint(json.loads(search_data))
|
||||||
|
#search_data = '{ "q": "' + str(partnum) + '" }'
|
||||||
|
#fprint(search_data)
|
||||||
|
headers = headers = {
|
||||||
|
'Authorization': f'Bearer {token}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
with requests.post(search_url, headers=headers, data=search_data) as r:
|
with requests.post(search_url, headers=headers, data=search_data) as r:
|
||||||
a = r.text
|
a = r.text
|
||||||
a = json.loads(a)
|
a = json.loads(a)
|
||||||
|
@ -311,8 +311,6 @@ class LEDSystem():
|
|||||||
|
|
||||||
|
|
||||||
def setring(self, r,g,b,idx):
|
def setring(self, r,g,b,idx):
|
||||||
print(self.rings)
|
|
||||||
print(self.rings[idx])
|
|
||||||
ring = self.rings[idx]
|
ring = self.rings[idx]
|
||||||
for pixel in range(ring[2],ring[3]):
|
for pixel in range(ring[2],ring[3]):
|
||||||
self.setpixel(r,g,b,pixel)
|
self.setpixel(r,g,b,pixel)
|
||||||
@ -442,7 +440,7 @@ class LEDSystem():
|
|||||||
dgs /= sizerem
|
dgs /= sizerem
|
||||||
dbs /= sizerem
|
dbs /= sizerem
|
||||||
sum += abs(drs) + abs(dgs) + abs(dbs)
|
sum += abs(drs) + abs(dgs) + abs(dbs)
|
||||||
print(drs,dgs,dbs)
|
#print(drs,dgs,dbs)
|
||||||
for x in range(idxa,idxb):
|
for x in range(idxa,idxb):
|
||||||
old = self.exactdata[x]
|
old = self.exactdata[x]
|
||||||
new = list(old)
|
new = list(old)
|
||||||
|
56
run.py
56
run.py
@ -30,6 +30,8 @@ from search import JukeboxSearch
|
|||||||
from pyModbusTCP.client import ModbusClient
|
from pyModbusTCP.client import ModbusClient
|
||||||
from uptime import uptime
|
from uptime import uptime
|
||||||
|
|
||||||
|
# set to false to run without real hardware for development
|
||||||
|
real = False
|
||||||
|
|
||||||
mbconn = None
|
mbconn = None
|
||||||
config = None
|
config = None
|
||||||
@ -60,6 +62,7 @@ cable_list_state = list()
|
|||||||
just_placed = -1
|
just_placed = -1
|
||||||
ring_animation = None
|
ring_animation = None
|
||||||
led_set_mode = None
|
led_set_mode = None
|
||||||
|
sensors = [0,0,0,0]
|
||||||
|
|
||||||
def arm_start_callback(res):
|
def arm_start_callback(res):
|
||||||
fprint("Arm action complete.")
|
fprint("Arm action complete.")
|
||||||
@ -310,7 +313,10 @@ def setup_server(pool):
|
|||||||
global jbs
|
global jbs
|
||||||
|
|
||||||
arm = Rob(config)
|
arm = Rob(config)
|
||||||
pool.apply_async(ur5_control.powerup_arm, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
if real:
|
||||||
|
pool.apply_async(ur5_control.powerup_arm, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
global ledsys
|
global ledsys
|
||||||
ledsys = LEDSystem()
|
ledsys = LEDSystem()
|
||||||
#pool.apply_async(ledsys.init, callback=led_start_callback)
|
#pool.apply_async(ledsys.init, callback=led_start_callback)
|
||||||
@ -343,7 +349,8 @@ def setup_server(pool):
|
|||||||
while arm_ready is False:
|
while arm_ready is False:
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
ur5_control.init_arm(arm)
|
if real:
|
||||||
|
ur5_control.init_arm(arm)
|
||||||
fprint("Arm initialized.", sendqueue=to_server_queue)
|
fprint("Arm initialized.", sendqueue=to_server_queue)
|
||||||
|
|
||||||
|
|
||||||
@ -397,6 +404,7 @@ def get_open_spot(sensordata):
|
|||||||
|
|
||||||
def mainloop_server(pool):
|
def mainloop_server(pool):
|
||||||
# NON-blocking loop
|
# NON-blocking loop
|
||||||
|
global real
|
||||||
global ring_animation
|
global ring_animation
|
||||||
global led_set_mode
|
global led_set_mode
|
||||||
global just_placed
|
global just_placed
|
||||||
@ -416,7 +424,7 @@ def mainloop_server(pool):
|
|||||||
global mainloop_get
|
global mainloop_get
|
||||||
global cable_list_state
|
global cable_list_state
|
||||||
global scan_value
|
global scan_value
|
||||||
print(" ***** Running main system loop ***** ")
|
#print(" ***** Running main system loop ***** ")
|
||||||
if killme.value > 0:
|
if killme.value > 0:
|
||||||
killall()
|
killall()
|
||||||
|
|
||||||
@ -429,10 +437,12 @@ def mainloop_server(pool):
|
|||||||
ledsys.mainloop(led_set_mode, ring_animation)
|
ledsys.mainloop(led_set_mode, ring_animation)
|
||||||
led_set_mode = None
|
led_set_mode = None
|
||||||
else:
|
else:
|
||||||
fprint("Not triggering LED loop: no ring animation")
|
pass
|
||||||
|
#fprint("Not triggering LED loop: no ring animation")
|
||||||
|
|
||||||
if mode == "Startup":
|
if mode == "Startup":
|
||||||
#counter = 54 # remove for demo
|
if not real:
|
||||||
|
counter = 54
|
||||||
if counter < 54:
|
if counter < 54:
|
||||||
# scanning cables
|
# scanning cables
|
||||||
if arm_state is None:
|
if arm_state is None:
|
||||||
@ -512,7 +522,8 @@ def mainloop_server(pool):
|
|||||||
while len(tmp) < 54:
|
while len(tmp) < 54:
|
||||||
tmp.append(False) # must have 54 entries
|
tmp.append(False) # must have 54 entries
|
||||||
|
|
||||||
#cable_list = tmp # comment out for real demo
|
if not real:
|
||||||
|
cable_list = tmp # comment out for real demo
|
||||||
|
|
||||||
for idx in range(len(cable_list)):
|
for idx in range(len(cable_list)):
|
||||||
cable_list_state.append(True)
|
cable_list_state.append(True)
|
||||||
@ -556,7 +567,7 @@ def mainloop_server(pool):
|
|||||||
|
|
||||||
fprint("All cables added to database.")
|
fprint("All cables added to database.")
|
||||||
mode = "Idle"
|
mode = "Idle"
|
||||||
serverproc = Process(target=start_server_socket, args=(cable_list,), error_callback=handle_error)
|
serverproc = Process(target=start_server_socket, args=(cable_list,))
|
||||||
serverproc.start()
|
serverproc.start()
|
||||||
else:
|
else:
|
||||||
# TODO: manual input
|
# TODO: manual input
|
||||||
@ -566,8 +577,10 @@ def mainloop_server(pool):
|
|||||||
if mode == "Idle":
|
if mode == "Idle":
|
||||||
# do nothing
|
# do nothing
|
||||||
if arm_ready is False:
|
if arm_ready is False:
|
||||||
pool.apply_async(ur5_control.move_to_home, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
if real:
|
||||||
#arm_ready = True
|
pool.apply_async(ur5_control.move_to_home, (arm,), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
global mainloop_get
|
global mainloop_get
|
||||||
@ -585,14 +598,22 @@ def mainloop_server(pool):
|
|||||||
spot = get_open_spot(sensors)
|
spot = get_open_spot(sensors)
|
||||||
if spot is not False:
|
if spot is not False:
|
||||||
arm_ready = False
|
arm_ready = False
|
||||||
pool.apply_async(ur5_control.holder_to_tray, (arm, get_cable, spot), callback=arm_start_callback, error_callback=handle_error)
|
if real:
|
||||||
|
pool.apply_async(ur5_control.holder_to_tray, (arm, get_cable, spot), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
|
fprint("Getting cable at position " + str(get_cable))
|
||||||
mode = "Pickup"
|
mode = "Pickup"
|
||||||
cable_list_state[get_cable] = False # mark as removed
|
cable_list_state[get_cable] = False # mark as removed
|
||||||
get_sensors(sensors,flag=get_open_spot(sensors))
|
get_sensors()
|
||||||
|
|
||||||
if action == "return":
|
if action == "return":
|
||||||
arm_ready = False
|
arm_ready = False
|
||||||
pool.apply_async(ur5_control.tray_to_camera, (arm, get_cable), callback=arm_start_callback, error_callback=handle_error)
|
fprint("Returning cable from tray position " + str(get_cable))
|
||||||
|
if real:
|
||||||
|
pool.apply_async(ur5_control.tray_to_camera, (arm, get_cable), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
mode = "ReturnC"
|
mode = "ReturnC"
|
||||||
else:
|
else:
|
||||||
# LED idle anim
|
# LED idle anim
|
||||||
@ -615,7 +636,11 @@ def mainloop_server(pool):
|
|||||||
mode = "Scan"
|
mode = "Scan"
|
||||||
arm_ready = False
|
arm_ready = False
|
||||||
camera_ready = False
|
camera_ready = False
|
||||||
pool.apply_async(camera.read_qr, (10,), callback=camera_start_callback, error_callback=handle_error)
|
if real:
|
||||||
|
pool.apply_async(camera.read_qr, (10,), callback=camera_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
camera_ready = True
|
||||||
|
scan_value = "10GXS13"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# getting cable from and bringing to camera
|
# getting cable from and bringing to camera
|
||||||
@ -640,7 +665,10 @@ def mainloop_server(pool):
|
|||||||
if cable == scan_value and cable_list_state[idx] == False:
|
if cable == scan_value and cable_list_state[idx] == False:
|
||||||
cable_list_state[idx] = True # mark cable as returned
|
cable_list_state[idx] = True # mark cable as returned
|
||||||
arm_ready = False
|
arm_ready = False
|
||||||
pool.apply_async(ur5_control.camera_to_holder, (arm, idx), callback=arm_start_callback, error_callback=handle_error)
|
if real:
|
||||||
|
pool.apply_async(ur5_control.camera_to_holder, (arm, idx), callback=arm_start_callback, error_callback=handle_error)
|
||||||
|
else:
|
||||||
|
arm_ready = True
|
||||||
mode = "Return"
|
mode = "Return"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -59,9 +59,11 @@ def powerup_arm(robot):
|
|||||||
|
|
||||||
#
|
#
|
||||||
# wait for power up (this function runs async)
|
# wait for power up (this function runs async)
|
||||||
|
count = 0
|
||||||
while not ping(robot.ip):
|
while not ping(robot.ip) and count == 10:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
count += 1
|
||||||
|
|
||||||
# trigger auto-initialize
|
# trigger auto-initialize
|
||||||
fprint("Arm online. Waiting for calibration.")
|
fprint("Arm online. Waiting for calibration.")
|
||||||
# wait for auto-initialize
|
# wait for auto-initialize
|
||||||
@ -72,16 +74,19 @@ def connect(robot):
|
|||||||
ip = robot.ip
|
ip = robot.ip
|
||||||
fprint("Connecting to arm at " + ip)
|
fprint("Connecting to arm at " + ip)
|
||||||
trying = True
|
trying = True
|
||||||
while trying:
|
count = 0
|
||||||
|
while trying and count < 10:
|
||||||
|
count += 1
|
||||||
try:
|
try:
|
||||||
robot.robot = urx.Robot(ip)
|
robot.robot = urx.Robot(ip)
|
||||||
|
robot.robot.set_tcp((robot.offset_x, robot.offset_y, robot.offset_z, 0, 0, 0))
|
||||||
|
# Set weight
|
||||||
|
robot.robot.set_payload(2, (0, 0, 0.1))
|
||||||
trying = False
|
trying = False
|
||||||
except:
|
except:
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
# Sets robot arm endpoint offset (x,y,z,rx,ry,rz)
|
# Sets robot arm endpoint offset (x,y,z,rx,ry,rz)
|
||||||
robot.robot.set_tcp((robot.offset_x, robot.offset_y, robot.offset_z, 0, 0, 0))
|
|
||||||
# Set weight
|
|
||||||
robot.robot.set_payload(2, (0, 0, 0.1))
|
|
||||||
return robot
|
return robot
|
||||||
|
|
||||||
def init_arm(robot):
|
def init_arm(robot):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user