资源简介
利用python远程控制v-rep循迹小车完成仿真,包含源码,场景文件和仿真视频
![](http://www.nz998.com/pic/71888.jpg)
代码片段和文件信息
#Imporditakse teeigd:
import vrep #V-rep‘s library
import sys
import time
vrep.simxFinish(-1) #It is closing all open connections with VREP
clientID=vrep.simxStart(‘127.0.0.1‘19997TrueTrue50005)
if clientID!=-1: #It is checking if connection is successful
print ‘Connected to remote API server‘
else:
print ‘Connection not successful‘
sys.exit(‘Could not connect‘)
#Getting motor handles
errorCodeleft_motor_handle=vrep.simxGetobjectHandle(clientID“left_joint“vrep.simx_opmode_oneshot_wait)
errorCoderight_motor_handle=vrep.simxGetobjectHandle(clientID“right_joint“vrep.simx_opmode_oneshot_wait)
sensor_h=[] #handles list
sensor_val=[] #Sensor value list
#Getting sensor handles list
for x in range(06):
errorCodesensor_handle=vrep.simxGetobjectHandle(clientID‘line_sensor‘+str(x)vrep.simx_opmode_oneshot_wait)
sensor_h.append(sensor_handle) #It is adding sensor handle values
errorCodedetectionstate sensorreadingvalue=vrep.simxReadVisionSensor(clientIDsensor_h[x]vrep.simx_opmode_streaming)
sensor_val.append(1.0) #It is adding 1.0 to fill the sensor values on the list. In the while loop it is going to overwrite the values
time.sleep(1)
t = time.time() #It is saving the time which is now
while (1): #Cycle which doesn‘t end
#It is writing down sensor handles and reading values
summa = 0 #It is zeroing the sum
andur = 0 #and the sensor values
for x in range(06):
errorCodedetectionstate sensorreadingvalue=vrep.simxReadVisionSensor(clientIDsensor_h[x]vrep.simx_opmode_buffer)
#Reading sensor values
sensor_val[x]=sensorreadingvalue[1][0] #It is overwriting the sensor values
print “Positsiooni väärtus kokku45 :“sensor_val[x] x
if sensor_val[2]<=0.2 or sensor_val[3]<=0.2:
errorCode=vrep.simxSetJointTargetVelocity(clientIDleft_motor_handle10 vrep.simx_opmode_streaming)
errorCode=vrep.simxSetJointTargetVelocity(clientIDright_motor_handle10 vrep.simx_opmode_streaming)
if sensor_val[1]<=0.2:
errorCode=vrep.simxSetJointTargetVelocity(clientIDleft_motor_handle13 vrep.simx_opmode_streaming)
errorCode=vrep.simxSetJointTargetVelocity(clientIDright_motor_handle10 vrep.simx_opmode_streaming)
if sensor_val[0]<=0.2:
errorCode=vrep.simxSetJointTargetVelocity(clientIDleft_motor_handle16 vrep.simx_opmode_streaming)
errorCode=vrep.simxSetJointTargetVelocity(clientIDright_motor_handle10 vrep.simx_opmode_streaming)
if sensor_val[4]<=0.2:
errorCode=vrep.simxSetJointTargetVelocity(clientIDleft_motor_handle10 vrep.simx_opmode_streaming)
errorCode=vrep.simxSetJointTargetVelocity(clientIDright_motor_handle13 vrep.simx_opmode_streaming)
if sensor_val[5]<=0.2:
errorCode=vrep.simxSetJointTargetVelocity(clientIDleft_motor_handle10 vrep.simx_opmode_streaming)
erro
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-19 20:51 linefollower\
文件 9959709 2018-09-19 19:52 linefollower\line follow car.mp4
文件 3295 2018-09-19 19:50 linefollower\line follow car.py
文件 67072 2016-11-16 11:34 linefollower\remoteApi.dll
文件 321735 2018-09-19 20:50 linefollower\scene.ttt
文件 70365 2017-04-05 21:36 linefollower\vrep.py
文件 57480 2018-09-06 09:45 linefollower\vrep.pyc
文件 45014 2017-04-05 21:36 linefollower\vrepConst.py
文件 27588 2018-09-19 15:33 linefollower\vrepConst.pyc
- 上一篇:Python神经网络编程.zip
- 下一篇:python爬取淘宝粽子销售数据并分析
相关资源
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
评论
共有 条评论