40823246 cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 每周進度
    • stage1-bg8
    • stage2-bg1
      • 檔案下載
      • 參考資料
    • stage3-bg1
      • task2
  • 筆記
    • coppeliasim 新增球體,旋轉軸應用
    • 組員fork git pull 注意事項
    • reveal 功能
    • remote api
  • W5
  • w15
  • w16
參考資料 << Previous Next >> task2

stage3-bg1

w9

討論做什麼

w10

20210504

remote api(python) 連動成功

20210505

新增控制插鏟功能

20210506

新增控制推高機前後左右功能

 20210512

巡路小車

20210513

凸輪stage2,爬不上去,待改善

20210514

來回走直線

20210520

堆高機搬運測試A to B

20210524

將機械手臂改成改成一鍵往前 > 抓取 >往後 >放開,增加抓取成功機率。

downloads

主要程式碼:

#angle = math.pi/180
if keyboard.is_pressed("t"):
            print("You pressed t")
           
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.5,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*90,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.1,opmode)
            time.sleep(5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*0,opmode)

20210604

加入rgb偵測啟動夾爪。

downloads

主要程式碼:

 #rgb辨識-----
        returnCode,resolution,image=vrep.simxGetVisionSensorImage(clientID,vision_handle,0,opmode)#取得圖片
        color = np.asarray(image)#將圖片數據轉成矩陣形式
        color.shape = (resolution[1], resolution[0], 3)
        color = color.astype(np.float)#-1~1
        color[color < 0] += 255
        color = np.fliplr(color)#因為得到得圖片數據是上下左右顛倒的,所以要將數據在顛倒一次才能轉正
        color = color.astype(np.uint8)#0~255
        rgb=color[1]
        rgb2=rgb[1]
        print(rgb2)
        rgb3=[139,139,163]#掃地機器人的顏色
        rgb4=[0,0,147]
        #rgb辨識-----
        
        #夾爪程式(rgb作動)-----
        if all(rgb2==rgb3):
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.5,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*90,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.1,opmode)
            time.sleep(5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*0,opmode)
        #夾爪程式(rgb作動)-----

20210618

更新RGB辨識程式,因為每個產品顏色多少有一點點的差異,所以把條件設置在一定範圍內。

#rgb辨識-----
        returnCode,resolution,image=vrep.simxGetVisionSensorImage(clientID,vision_handle,0,opmode)#取得圖片
        color = np.asarray(image)#將圖片數據轉成矩陣形式
        color.shape = (resolution[1], resolution[0], 3)
        color = color.astype(np.float)#-1~1
        color[color < 0] += 255
        color = np.fliplr(color)#因為得到得圖片數據是上下左右顛倒的,所以要將數據在顛倒一次才能轉正
        color = color.astype(np.uint8)#0~255
        rgb=color[1]
        rgb2=rgb[1]
        r=rgb2[0]
        g=rgb2[1]
        b=rgb2[2]
        print(rgb2)
        rgb3=[139,139,163]#掃地機器人的顏色
        rgb4=[0,0,147]
        #rgb辨識-----
        
        #夾爪程式(rgb作動)-----
        if 167>b>161 and 142>r>136 and 142>g>136:#設置一定範圍
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.5,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*90,opmode)
            time.sleep(0.5)
            vrep.simxSetJointTargetPosition(clientID,vertical_handle,0.1,opmode)
            time.sleep(5)
            vrep.simxSetJointTargetPosition(clientID,cam_handle,angle*0,opmode)
        #夾爪程式(rgb作動)-----

檔案下載


參考資料 << Previous Next >> task2

Copyright © All rights reserved | This template is made with by Colorlib