资源简介
利用python远程控制v-rep循迹小车完成仿真,包含源码,场景文件和仿真视频
代码片段和文件信息
#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爬取淘宝粽子销售数据并分析
相关资源
- python爬取淘宝粽子销售数据并分析
- Python神经网络编程.zip
- python满分实验报告:红心大战源代码
- python核心编程第三版
- [全套55讲]-鱼C论坛小甲鱼Python课后题
- Introducing Python;Modern Computing in Simple
- 《 流畅的python 》源代码 .zip
- python pycharm爬虫实战之百度贴吧爬取
- Python基础教程第3版电子版 文字版 中
- python教材
- pandas包python3.5版本 win64
- 用Python写网络爬虫.pdf 高清版
- Python Cookbook 第三版 中文+英文 高清带
- python写的一个小型计算器
- matplotlibwin32
- python菜鸟教程
- 精通Python设计模式 超清pdf 非扫描 带
- 人工智能-python机器学习实战高清完整
- 基于物品的协同过滤算法源码及数据
- 流畅的python_PDF 中文 高清 无密码
- Python编程从入门到实践.rar
- FlaskWeb开发:基于Python的Web应用开发实
- 《Python金融序列量化应用编程指南》
- Python web接口开发与测试电子版.pdf
- Thoughtful Machine Learning with Python
- Python for Data Analysis 2nd Edition最终版
- 《Python基础教程第3版》带书签超清
- 《Selenium自动化测试:基于Python语言》
- Django Web开发指南(Python)
- Python for Data Analysis 2nd Edition.pdf
评论
共有 条评论