2021-協同產品設計實習-stage3-bg6

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 機械手臂
    • 繪圖成果
    • 計算角度
  • 程式模擬
    • W10
    • W11
  • CoppliaSim程式模擬
    • CoppeliaSim 教學
      • 軸的旋轉教學
      • 直線運動教學
      • 1-單軸直線運動
      • 2-可變速之旋轉運動
      • 3-遙控攝影小汽車
      • CODE 指令解說
      • remoteApi python 指令對照
      • 機械手臂設定範例
      • 按鍵控制代碼
    • 架設場景
      • 對軸進行旋轉控制
      • 對方快進行XYZ軸控制
      • 物件螺旋運動
      • 3D列印機_控制噴嘴
      • 3D列印機_自動繪製
      • 3D列印機_控制高度
      • 衝擊試驗機
      • 架設機械手臂場景
      • 機械手臂場景微調
      • 機械手臂場景路徑控制
    • W13 Pick and Place
      • remoteApi
      • 0526更新
      • 舊版本
    • 尋找控制代碼
    • 控制解說
    • 0513 機械手臂新增夾爪控制
    • 0511 Programming in C++
    • 參考資料
    • 舊資料
      • 0511 Programming in Lua on multiple program
      • 0511 Programming in Lua in One program
  • task2-remoteAPI
    • 機械手臂多人對戰
    • 自動吹笛子機
    • 3D列印機
    • W13 Pick and Place remoteApi
      • 0601
      • 0524
    • remoteAPI in C++
      • 0511
      • 0512
      • 0512-2
    • remoteAPI in python
      • 0513-1
      • 0517
    • remoteApi in Lua
      • 0513-2
  • stage3
    • task
      • task1
    • 每週進度影片
      • 第九週
      • 第十週
      • 第十一週
      • 第十二週
      • 第十三週
    • 討論
      • discord
      • 第一次討論
      • 第二次討論
      • 第三次討論
      • 第四次討論
      • 第五次討論
    • 遇到的問題
      • 更新出錯
      • 倉儲帳號被鎖
    • 小組直播影片
      • 第11週
      • 第12週
      • 第13週
  • W15
    • 影片字幕整理
remoteApi << Previous Next >> 舊版本

0526更新

預計更新-remoteApi

檔案下載

W13_pick and place

影片:

影片模擬時間為30分鐘,總共進行4次將球放到空盤再回復,理論上可以無限反覆模擬

之前在舊版本中,會發現吸盤一直朝同一方向旋轉角度會誤差越來越大,所以在此場景中,將吸取設為正轉,放下設成反轉,即可以避免朝同一方向選轉造成的角度偏移問題

程式構想:

透過計算現在為拿取第幾個球,可以推算出該球在第幾層(unit),也可以定為該層的起始座標(角落)

知道在第幾層後可以反推出他是該層的第幾個(finding_XY),進一步知道他的XY座標(X_Pos/Y_Pos)

例: 第九顆球,可以得知在第三層,反推可以得知她是第4個,然後就可以得知她是第二排第一個,以此類推

而在第30顆球過後,需要重新設定基準座標還有重設數量,才有最下面if問句

程式參考

function signal_switch(singal,enable)
    if singal==1 or singal==12 then
        sim.setIntegerSignal(modelName1 .."call_1",enable)
    end
    if singal==2 or singal==11 then
        sim.setIntegerSignal(modelName2 .."call_2",enable)
    end
    if singal==3 or singal==10 then
        sim.setIntegerSignal(modelName3 .."call_3",enable)
    end
    if singal==4 or singal==9 then
        sim.setIntegerSignal(modelName4 .."call_4",enable)
    end
    if singal==5 or singal==8 then
        sim.setIntegerSignal(modelName5 .."call_5",enable)
    end
    if singal==6 or singal==7 then
        sim.setIntegerSignal(modelName6 .."call_6",enable)
    end
end

function sysCall_threadmain()
    joint01=sim.getObjectHandle('X')
    joint02=sim.getObjectHandle('Y')
    joint03=sim.getObjectHandle('Z')
    jointr=sim.getObjectHandle('Rotate')
    tt=1
    long_t=1.5
    long_long_t=3 --time set
    rotate_deg=0 --pad rotate
    atz=0  --altitude set
    setx=0.5
    setpx=-0.5 --center pick set
    sety=-0.16
    setpy=-0.16 --center fall set
    local pick_high={"0.0645","0.134","0.2025","0.2768"} --pick up high set
    local fall_high={"0.05","0.12","0.18","0.26"} --fall high set
    local high_up={"0","0","0.05","0.12"}
    cube=1              -- set cube
    ball_pick_time=0    --total ball we pick
    ball_put_time=31     --total ball we put
    while (ball_pick_time<60) do
        for ball=1,6,1 do    --pick the ball
            ball_pick_time=ball_pick_time+1 --total time we pick
            i=1
            unit=0
            level=0
            while level < ball_pick_time do  --find which level and place should be of the xy coordinates
                unit=unit+1
                level=level+unit^2
            end
            finding_XY=ball_pick_time   --this is the XY on that floor
            while(i<=unit-1) do            
                finding_XY=finding_XY-(i^2) 
                i=i+1
            end
            X_Pos=finding_XY%unit       -- the X and Y coordinates(by balls)
             if X_Pos==0 then
                X_Pos=unit
            end
            Y_Pos=(math.ceil(finding_XY/unit)) 
            BaseX=setx-((unit-1)*0.05)--now we need to find the 0 of the xy
            BaseY=sety-((unit-1)*0.05)
            sim.setJointTargetPosition(joint01,BaseX+(0.1*(X_Pos-1))) --move to Position
            sim.wait(tt)
            sim.setJointTargetPosition(joint02,BaseY+(0.1*(Y_Pos-1)))
            sim.wait(tt)
            signal_switch(ball,1) --switch pad on
            sim.setJointTargetPosition(joint03,-pick_high[unit])--pick the pall
            sim.wait(tt)
            sim.setJointTargetPosition(joint03,atz-high_up[unit]) --after pick up we dont need to go that high
            sim.wait(tt)
            rotate_deg=rotate_deg+60  --rotate the pad
            sim.setJointTargetPosition(jointr,rotate_deg*math.pi/180)
            sim.wait(tt)
            sim.wait(tt)
        end
        sim.wait(long_t)
        sim.setJointTargetPosition(joint01,0)
        sim.setJointTargetPosition(joint02,0)
        sim.setJointTargetPosition(joint03,0)
        sim.wait(long_t)
        for ball=1,6,1 do --put the ball
            ball_put_time=ball_put_time-1
            i=1
            unit=0
            level=0
            while level < ball_put_time do  --find which level and place should be of the xy coordinates
                unit=unit+1
                level=level+unit^2
            end
            finding_XY=ball_put_time   --this is the XY on that floor
            while(i<=unit-1) do            
                finding_XY=finding_XY-(i^2) 
                i=i+1
            end
            X_Pos=finding_XY%unit       -- the X and Y coordinates(by balls)
             if X_Pos==0 then
                X_Pos=unit
            end
            Y_Pos=(math.ceil(finding_XY/unit)) 
            BaseX=setpx-((unit-1)*0.05)--now we need to find the 0 of the xy
            BaseY=setpy-((unit-1)*0.05)
            rotate_deg=rotate_deg-60  --rotate the pad
            sim.setJointTargetPosition(jointr,rotate_deg*math.pi/180)
            sim.wait(tt)
            sim.setJointTargetPosition(joint01,BaseX+(0.1*(X_Pos-1))) --move to Position
            sim.wait(tt)
            sim.setJointTargetPosition(joint02,BaseY+(0.1*(Y_Pos-1)))
            sim.wait(tt)
            sim.setJointTargetPosition(joint03,-fall_high[unit])--pick the pall
            sim.wait(tt)
            signal_switch(ball+6,0) --switch pad off
            sim.wait(tt)
            sim.setJointTargetPosition(joint03,atz-high_up[unit]) --after pick up we dont need to go that high
            sim.wait(tt)
            sim.wait(tt)
        end
        sim.wait(long_t)
        sim.setJointTargetPosition(joint01,0)
        sim.setJointTargetPosition(joint02,0)
        sim.setJointTargetPosition(joint03,0)
        sim.wait(long_t)
        if ball_pick_time==30 then
            pick_high={"0.07","0.138","0.2085","0.28"}
            setx=-setx
            setpx=-setpx
            ball_pick_time=0
            ball_put_time=31
        end
    end
end


remoteApi << Previous Next >> 舊版本

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