產品協同設計第二組

第十一周 << Previous Next >> 第十三周

第十二周

開會紀錄

----暫時放著----

改寫code=python to lua並簡化

優點:

python : 可執行運算值較大的編譯

lua : Vrep內部沿用 , 延遲現象較少

缺點:

python : 會有爆ping問題導致延遲

lua : 太多運算時直接停止

function sysCall_init() 
    KickBallV = 10
    R_KickBallVel = (math.pi/180)*KickBallV
    B_KickBallVel = -(math.pi/180)*KickBallV
    Sphere_handle=sim.getObjectHandle('Sphere')
    BRod_handle=sim.getObjectHandle('BRod')
    BRev_handle=sim.getObjectHandle('BRev')
    BMo_handle=sim.getObjectHandle('BMo')
    --
    RRod_handle=sim.getObjectHandle('RRod')
    RRev_handle=sim.getObjectHandle('RRev')
    RMo_handle=sim.getObjectHandle('RMo')
end
function sysCall_actuation()
    position_BR=sim.getObjectPosition(BRod_handle,-1)
    position_S=sim.getObjectPosition(Sphere_handle,-1)
    X =position_S[1] - position_BR[1]
    Y =position_S[2] - position_BR[2]
    if 1 then
        if X <= 0.02 and Y <= 0 then
            sim.setJointTargetVelocity(BRev_handle,B_KickBallVel)
            sim.setJointTargetVelocity(BRev_handle,-1)
        elseif X > 0.02 and Y <= 0 then
            sim.setJointTargetVelocity(BRev_handle,B_KickBallVel)
            sim.setJointTargetVelocity(BRev_handle,1)
        elseif X <= 0.02 and Y > 0 then            
            sim.setJointTargetVelocity(BRev_handle,R_KickBallVel)
            sim.setJointTargetVelocity(BRev_handle,-1)        
        elseif X > 0.02 and Y > 0 then            
            sim.setJointTargetVelocity(BRev_handle,R_KickBallVel)    
            sim.setJointTargetVelocity(BRev_handle,1)
        end
        YYYYY = Y*5
        sim.setJointTargetVelocity(BMo_handle,YYYYY)
    end
---
    position_RR=sim.getObjectPosition(RRod_handle,-1)
    X =position_S[1] - position_RR[1]
    Y =position_S[2] - position_RR[2]
    if 1 then
        if X <= 0.02 and Y <= 0 then
            sim.setJointTargetVelocity(RRev_handle,B_KickBallVel)
            sim.setJointTargetVelocity(RRev_handle,-1)
        elseif X > 0.02 and Y <= 0 then
            sim.setJointTargetVelocity(RRev_handle,B_KickBallVel)
            sim.setJointTargetVelocity(RRev_handle,1)
        elseif X <= 0.02 and Y > 0 then            
            sim.setJointTargetVelocity(RRev_handle,R_KickBallVel)
            sim.setJointTargetVelocity(RRev_handle,-1)        
        elseif X > 0.02 and Y > 0 then            
            sim.setJointTargetVelocity(RRev_handle,R_KickBallVel)    
            sim.setJointTargetVelocity(RRev_handle,1)
        end
        YYYYY = Y*5
        sim.setJointTargetVelocity(RMo_handle,YYYYY)
    end
end
--by 40623130--

ttt檔

原本要編寫切換鍵但於vrep中用io.clock等時間等待輸入雙命令時會出現運算值過大導致停止問題 , 所以先寫電腦打擊與跟蹤球

原python code出處(by 40623128):https://mdekmol.github.io/cd2019a-task1-2019cda_t1_g3_1/content/%E6%89%8B%E8%B6%B3%E7%90%83%E6%89%8B%E6%8E%A7%E8%88%87%E9%9B%BB%E8%85%A6%E5%B0%8D%E6%89%93.html


第十一周 << Previous Next >> 第十三周