傻子機械人主程式

2021-09-26 14:42:10 字數 4311 閱讀 5758

color_dist = ,

'blue': ,

'green': ,

'yellow':,

#'black':,

#'white':,

}color_dist2= ,

'blue': ,

'green': ,

'yellow':,

#'black':,

#'white':,

}

th1 = threading.thread(target=get_image)

th1.setdaemon(true) # 設定為後台執行緒,這裡預設是false,設定為true之後則主線程不用等待子執行緒

th1.start()

cv_color_count = 0

ball_list=

ball_list_color = ['red','blue','green','yellow','black','white']

num_random = 0

circle=

black_first=false

for_red=false

#firstflood()

no_cnts=0

black_radius=0

xiao=0

pwmservo.setservo(1, 1900, 500)

pwmservo.setservo(2, 1500, 500)

while true:

if orgframe is not none and get_image_ok:

get_image_ok=false

print('get image')

cv2.imshow('orgframe', orgframe) #顯示影象

cv2.waitkey(1)

for i in color_dist:

print('enter for')

mask1 = cv2.inrange(picture, color_dist[i]['lower'], color_dist[i]['upper'])

mask2 = cv2.inrange(picture, color_dist2[i]['lower'], color_dist2[i]['upper'])

mask=mask1+mask2

mask = cv2.erode(mask, none, iterations=3)

mask = cv2.dilate(mask, none, iterations=3)

radius=legendary(mask)

if radius >=5: # 半徑大於140才算

xiao=0

black_first=false

print('find contours')

cv_color_count += 1

cv2.imshow('mask',mask)

print('breaklist')

break

else:

xiao+=1

if len(ball_list)==0 or xiao>=3:

xiao=0

print('no_conts')

no_cnts+=1

if no_cnts>3:

no_cnts=0

_,mask=cv2.threshold(picture2,100,255,cv2.thresh_binary_inv)

mask = cv2.erode(mask, none, iterations=4)

mask = cv2.dilate(mask, none, iterations=4)

cv2.imshow('blackmask',mask)

black_radius=legendary(mask)

print('blackradius:')

print(black_radius)

if black_radius>=5:

if black_first:

coor = get_coormain(mask,20,65536)

if coor is none:

num=0

print('num game over')

else:

num=len(coor)

print('num:')

print(num)

print('123')

print(radius)

print(black_radius)

if black_radius<51:

print('地雷區')

keep_parallel()

landmine()

keep_parallel()

elif num==2 and black_radius>50:

print('跨溝壑')

gouhe()

#keep_parallel()

else:

print('there is black,but game over')

black_first=false

else:

print('傻子機械人向前走幾步(準備第二次檢測黑色)')

ssr.running_action_group('walk',1)

black_first=true

else:

print('循線程式')

ssr.running_action_group('walk',1)

#xunxian()

if cv_color_count >= 4:

print('識別3次')

print(ball_list)

cv_color_count = 0

if ball_list[0]==ball_list[1] and ball_list[0]==ball_list[2] and\

ball_list[0]==ball_list[3] :

print('相等')

ball_list_color[num_random]=ball_list[0]

if ball_list_color[num_random]== 'red':

print('向前一步走')

ssr.running_action_group('walk',1)

print('789')

print(radius)

if radius<80 and for_red:

for_red=false

print('踢球進洞')

golf()

ssr.running_action_group('turnleft',5)

ssr.running_action_group('firstwalk', 1)

pwmservo.setservo(1, 1900, 500)

pwmservo.setservo(2, 1500, 500)

time.sleep(1)

elif for_red:

for_red=false

print('過紅色板橋')

#keep_parallel()

ssr.running_action_group('firstwalk', 1)

red_bridge()

for_red=true

elif ball_list_color[num_random] == 'blue':

print('過藍色板橋')

keep_parallel()

ssr.running_action_group('firstwalk', 1)

blue()

elif ball_list_color[num_random] == 'green':

print('過獨木橋')

keep_parallel()

ssr.running_action_group('firstwalk', 1)

greenbridge()

elif ball_list_color[num_random]== 'yellow':

print('過黃色回形坑')

keep_parallel()

ssr.running_action_group('firstwalk', 1)

huixingqiao()

num_random = 0

ball_list =

else:

print('made')

time.sleep(0.2)

cv2.destroyallwindows()

六軸機械人光機 六軸機械人主要用到哪些感測器?

康道智慧型解說六軸機械人主要用到哪些感測器?一 六軸機械人主要用到哪些感測器?1.視覺感測器 常用的計算機視覺方案也有很多種,比如雙目視覺,基於tof的深度相機,基於結構光的深度相機等。基於結構光的深度相機發射出的光會生成相對隨機但又固定的斑點圖樣,光斑打在物體上,因為與攝像頭距離不同,被攝像頭捕捉...

安川機械人程式還原 安川機械人 程式示例

收集整理 頁尾內容 1 nop 程式起始命令 空指令 2 cycle 注釋 迴圈執行 3 movj c00000 vj 100.00 point 距對中颱大概 150mm 的位置4 pulse ot 68 t 0.50 時間測量 point 取出待機位置 5 loop1 abel loop1 6 j...

安川機械人程式還原 安川機械人 程式示例

精品文件 1 nop 程式起始命令 空指令 2 cycle 注釋 迴圈執行 3 movj c00000 vj 100.00 point 距對中颱大概 150mm 的位置4 pulse ot 68 t 0.50 時間測量 point 取出待機位置 5 loop1 abel loop1 6 jump c...