import sim as vrep
import math
import random
import time
import keyboard
print ('Start')
vrep.simxFinish(-1)
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)
if keyboard.is_pressed("W"):
print("Velocity=10")
vrep.simxSetJointTargetVelocity(clientID,wristHandle,10,opmode)
if keyboard.is_pressed("E"):
print("Velocity=0")
vrep.simxSetJointTargetVelocity(clientID,wristHandle,0,opmode)
else:
print ('Failed connecting to remote API server')
print ('End')