Q1.電腦回擊時,會發生延遲的狀況,需要測試求到哪個位置時,桿件能馬上做出擊球的動作
while (n == 1): if Bv <= 0 and BBv <= -0.02 and Rv<=0 and RRv <= -0.02: errorCode,position_BR=vrep.simxGetObjectPosition(clientID,B1_handle,-1,vrep.simx_opmode_oneshot) errorCode,position_RR=vrep.simxGetObjectPosition(clientID,B2_handle,-1,vrep.simx_opmode_oneshot) errorCode,position_S=vrep.simxGetObjectPosition(clientID,Sphere_handle,-1,vrep.simx_opmode_oneshot) Bv =position_S[1]- position_BR[1] BBv =position_S[0] - position_BR[0] Rv =position_S[1]- position_RR[1] RRv =position_RR[0]-position_S[0] vrep.simxSetJointTargetVelocity(clientID,R1_handle,B_KickBallVel,vrep.simx_opmode_oneshot_wait) vrep.simxSetJointTargetVelocity(clientID,R2_handle,R_KickBallVel,vrep.simx_opmode_oneshot_wait)
原來的程式碼是用球到0.02的位置,後來經過測試後,0.03為最佳
if BBB <-0.03: speed(R1_handle, B_KickBallVel) elif BBB >= -0.03: speed(R1_handle, R_KickBallVel) else: pass if RRR >0.03: speed(R2_handle, R_KickBallVel) elif RRR <= 0.03: speed(R2_handle, B_KickBallVel) else: pass
Q2.電腦做回擊時,發生延遲的狀況(尚未解決)