task1 <<
Previous Next >> w13
task2
bubble
import sim as vrep
import sys
# child threaded script:
#simExtRemoteApiStart(19999)
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
if clientID!= -1:
print("Connected to remote server")
else:
print('Connection not successful')
sys.exit('Could not connect')
errorCode,left_motor_handle=vrep.simxGetObjectHandle(clientID,'bubbleRob_leftMotor',vrep.simx_opmode_oneshot_wait)
errorCode,right_motor_handle=vrep.simxGetObjectHandle(clientID,'bubbleRob_rightMotor',vrep.simx_opmode_oneshot_wait)
if errorCode == -1:
print('Can not find left or right motor')
sys.exit()
errorCode=vrep.simxSetJointTargetVelocity(clientID,left_motor_handle,10, vrep.simx_opmode_oneshot_wait)
errorCode=vrep.simxSetJointTargetVelocity(clientID,right_motor_handle,30, vrep.simx_opmode_oneshot_wait)
下列兩行為左右輪的轉數

STAGE1 API
import sim as vrep
import sys
# child threaded script:
#simExtRemoteApiStart(19999)
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
if clientID!= -1:
print("Connected to remote server")
else:
print('Connection not successful')
sys.exit('Could not connect')
errorCode,main_handle=vrep.simxGetObjectHandle(clientID,'main',vrep.simx_opmode_oneshot_wait)
if errorCode == -1:
print('Can not find main')
sys.exit()
errorCode=vrep.simxSetJointTargetVelocity(clientID,main_handle,10, vrep.simx_opmode_oneshot_wait)
模擬情況
STAGE2 API
import sim as vrep
import sys
# child threaded script:
#simExtRemoteApiStart(19999)
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19999, True, True, 5000, 5)
if clientID!= -1:
print("Connected to remote server")
else:
print('Connection not successful')
sys.exit('Could not connect')
errorCode,main01_handle=vrep.simxGetObjectHandle(clientID,'main01',vrep.simx_opmode_oneshot_wait)
if errorCode == -1:
print('Can not find main01')
sys.exit()
errorCode=vrep.simxSetJointTargetVelocity(clientID,main01_handle,10, vrep.simx_opmode_oneshot_wait)
模擬情況
task1 <<
Previous Next >> w13