python控制程序 .py 文件控制vrep常常包括以下步骤:
1.引入模块
import vrep
2.建立连接,先关闭上一次连接
print('Program started')
# Close potential connections
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
print("Connection success")
if clientID!=-1:
print ('Connected to remote API server')
3.开始仿真
# Start simulation
vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)
print("Simulation start")
根据需要,设置py文件和vrep环境时间一致:
# enable the synchronous mode on the client:
vrep.simxSynchronous(clientID,True)
相应的,在主程序部分,往往是循环里头:
# make step forward
vrep.simxSynchronousTrigger(clientID);
4.主程序部分
5.结束仿真
##### Stop simulation
vrep.simxStopSimulati