TASK2 <<
Previous Next >> 夾爪
分球機
測試人員:40823208
import sim as vrep
import math
import random
import time
import keyboard
print ('Start')
# Close eventual old connections
vrep.simxFinish(-1)
# Connect to V-REP remote server
clientID = vrep.simxStart('192.168.1.83', 19997, True, True, 5000, 5)
if clientID !=-1:
print ('Connected to remote API server')
res = vrep.simxAddStatusbarMessage(
clientID, "40823208",
vrep.simx_opmode_oneshot)
if res not in (vrep.simx_return_ok, vrep.simx_return_novalue_flag):
print("Could not add a message to the status bar.")
opmode = vrep.simx_opmode_oneshot_wait
vrep.simxStartSimulation(clientID, opmode)
ret, wristHandle = vrep.simxGetObjectHandle(clientID, "joint",opmode)
while True:
if keyboard.is_pressed("Q"):
print("Velocity=5")
vrep.simxSetJointTargetVelocity(clientID,wristHandle,5,opmode)
#Q可以讓轉速=5
if keyboard.is_pressed("W"):
print("Velocity=10")
vrep.simxSetJointTargetVelocity(clientID,wristHandle,10,opmode)
#W可以讓轉速=10
if keyboard.is_pressed("E"):
print("Velocity=0")
vrep.simxSetJointTargetVelocity(clientID,wristHandle,0,opmode)
#E可以讓轉速=0
else:
print ('Failed connecting to remote API server')
print ('End')
TASK2 <<
Previous Next >> 夾爪