40623141 協同產品設計實習

程式除錯 << Previous Next >> Vrep

程式優化

問題:

操作按鍵過多,導致控制困難

解決方法 :

取消暫停鍵

改成按下按鍵作動 放開則停止

修改前 :

1
2
3
4
5
6
if keyboard.is_pressed('y'): #桿子向左移
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,0.1,vrep.simx_opmode_oneshot_wait)
elif keyboard.is_pressed('u'): #桿子停止作動
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,0,vrep.simx_opmode_oneshot_wait)
elif keyboard.is_pressed('i'): #桿子向右移
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,-0.1,vrep.simx_opmode_oneshot_wait)



修改後 :

1
2
3
4
5
6
if keyboard.is_pressed('u'): #桿子向左移
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,0.1,vrep.simx_opmode_oneshot_wait)
elif keyboard.is_pressed('i'): #桿子向右移
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,-0.1,vrep.simx_opmode_oneshot_wait)
else:
vrep.simxSetJointTargetVelocity(clientID,RMo_handle,0,vrep.simx_opmode_oneshot_wait)


程式除錯 << Previous Next >> Vrep