资源简介
matla运行APROBOT脚本即可实现人工势场法的仿真。使用vrep中的三轮小车,构建其运动的环境,包括转向角度,以及转向速度等。
本程序寻找的并不是最优路径,可适当改变转弯角度以及转弯速度进行优化。其中astart,m是经典的人工势场法程序,非常好理解,potential.pdf是介绍该算法非常直观的一篇论文。

代码片段和文件信息
function APRobot()
%UNtitleD2 此处显示有关此函数的摘要
% 此处显示详细说明
% 定义vrep与matlab连接的相关模块
disp(‘Program started‘);
% vrep=remApi(‘remoteApi‘‘extApi.h‘); % using the header (requires a compiler)
vrep=remApi(‘remoteApi‘); % using the prototype file (remoteApiProto.m)
vrep.simxFinish(-1); % just in case close all opened connections
clientID=vrep.simxStart(‘127.0.0.1‘19997truetrue50005);
[~MotorLeft] = vrep.simxGetobjectHandle(clientID‘leftmotor‘vrep.simx_opmode_blocking);
[~MotorRight] = vrep.simxGetobjectHandle(clientID‘rightmotor‘vrep.simx_opmode_blocking);
% 五个超声波传感器,探测机器人左、左前、前、右前、右方向上的障碍物
[~LeftSensingNoseHandle] = vrep.simxGetobjectHandle(clientID‘LeftSensing‘vrep.simx_opmode_blocking);
[~RightSensingNoseHandle] = vrep.simxGetobjectHandle(clientID‘RightSensing‘vrep.simx_opmode_blocking);
[~FrontSensingNoseHandle] = vrep.simxGetobjectHandle(clientID‘FrontSensing‘vrep.simx_opmode_blocking);
[~RightFrontSensingNoseHandle] = vrep.simxGetobjectHandle(clientID‘RightFrontSensing‘vrep.simx_opmode_blocking);
[~LeftfFrontSensingNoseHandle] = vrep.simxGetobjectHandle(clientID‘LeftFrontSensing‘vrep.simx_opmode_blocking);
% 机器人与目标句柄
[~BubbleRob] = vrep.simxGetobjectHandle(clientID‘BubbleRob‘vrep.simx_opmode_blocking);
[~goalhandle]=vrep.simxGetobjectHandle(clientID‘goal‘vrep.simx_opmode_blocking);%获得目标句柄
%minMaxSpeed = {50*pi/180300*pi/180}; %Min and max speeds for each motor
% 各部分模块定义结束
pathFound=false; % has goal been reached
% 人工势场法相关定义
robotSpeed=[-4 -4]; % arbitrary units
distanceThreshold = 1;%障碍物影响的距离
k=100; % degree of calculating potential
attractivePotentialScaling=100; % scaling factor for attractive potential
repulsivePotentialScaling=1000; % scaling factor for repulsive potential
minAttractivePotential=0.5; % minimum attractive potential at any point
% 全局变量用作计算势能用
distanceFront = 0;
distanceLeft = 0;
distanceRight = 0;
distanceFrontLeft = 0;
distanceFrontRight = 0;
distanceGoal = 0;
angleGoal = 0;
currentDirection=0;
speednew = 0;
if (clientID>-1)
tic;
disp(‘Connected to remote API server‘);
vrep.simxStartSimulation(clientIDvrep.simx_opmode_oneshot);
vrep.simxSetJointTargetVelocity(clientIDMotorLeftrobotSpeed(1)vrep.simx_opmode_oneshot);
vrep.simxSetJointTargetVelocity(clientIDMotorRightrobotSpeed(2)vrep.simx_opmode_oneshot);
% 获取目标的位置
[returnCodeGoalPositionXYZ]=vrep.simxGetobjectPosition(clientIDgoalhandle-1vrep.simx_opmode_blocking);%获得目标的位置
if(returnCode==vrep.simx_return_ok)
goal = GoalPositionXYZ(:1:2);%所有行的第一列和第二列
fprintf(“goal is:(%2.3f%2.3f)\n“goal);
else
fprintf(“Invalid Goal! the error code is: %d\n“returnCode);
end
%while toc<10
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 627121 2018-06-13 16:11 BubbleRob\20180607.ttt
文件 625953 2018-06-05 13:32 BubbleRob\BubbleRob.ttt
文件 12748 2018-06-13 11:06 BubbleRob\MATLAB_VREP_workspace\APRobot.m
文件 7351 2018-06-07 20:49 BubbleRob\MATLAB_VREP_workspace\astart.m
文件 557 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\distanceCost.m
文件 792 2018-05-30 14:56 BubbleRob\MATLAB_VREP_workspace\feasiblePoint.m
文件 251078 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\map1.bmp
文件 251078 2018-06-05 09:40 BubbleRob\MATLAB_VREP_workspace\map2.bmp
文件 251078 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\map3.bmp
文件 251078 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\map4.bmp
文件 251078 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\map5.bmp
文件 848 2018-05-15 16:33 BubbleRob\MATLAB_VREP_workspace\matlab.mat
文件 750054 2018-01-27 15:41 BubbleRob\MATLAB_VREP_workspace\my_map.bmp
文件 5580 2018-06-04 21:33 BubbleRob\MATLAB_VREP_workspace\obstacle.m
文件 1537 2018-05-31 11:00 BubbleRob\MATLAB_VREP_workspace\plotRobot.m
文件 192524 2014-06-06 15:35 BubbleRob\MATLAB_VREP_workspace\potential.pdf
文件 1089 2019-04-02 22:41 BubbleRob\MATLAB_VREP_workspace\readMe.txt
文件 100875 2018-01-25 17:03 BubbleRob\MATLAB_VREP_workspace\remApi.m
文件 70656 2018-01-25 17:03 BubbleRob\MATLAB_VREP_workspace\remoteApi.dll
文件 35378 2018-01-25 17:03 BubbleRob\MATLAB_VREP_workspace\remoteApiProto.m
文件 2716 2018-06-02 15:49 BubbleRob\MATLAB_VREP_workspace\simpleTest.m
文件 9885 2018-06-04 21:43 BubbleRob\MATLAB_VREP_workspace\turn.m
文件 1417 2018-06-12 16:05 BubbleRob\MATLAB_VREP_workspace\TurnSpeed.m
目录 0 2019-04-02 22:29 BubbleRob\MATLAB_VREP_workspace
目录 0 2019-04-02 22:29 BubbleRob
----------- --------- ---------- ----- ----
3702471 25
- 上一篇:vwap算法交易详解
- 下一篇:ZeroServer_01
相关资源
- 编程实现二维DCT变换
- 图像二值化
- 用FFT对信号进行频谱分析
- Tone-Reservation
- QGA 量子遗传算法
- 差分形式的阻滞增长模型
- 遗传算法的M文件
- 简单二阶互联系统的非线性动力学分
- 基于改进人工势场的矿井导航装置路
- 利用改进人工势场法的智能车避障路
- 基于改进人工势场法的救灾机器人路
- 手写数字识别-模板匹配法
- Stock_Watson_动态因子分析模型
- 果蝇优化算法优化支持向量回归程序
- 自己做的一个简单GUI扑克纸牌识别-
- multi output SVR
- AR过程的线性建模过程与各种功率谱估
- PCNN TOOLBOX
- plstoolbox.zip
- 中国国家基础地理信息系统GIS数据
- 粒子群微电网优化调度
- 矩阵分析-经典教材-中文版-Roger.A.Ho
- 压缩感知TwIST
- 基于最小错误率的贝叶斯手写数字分
- 最全系统辨识源代码,包括多种最小
- 导弹制导实验
- 画跟踪精确度图的程序.zip
- 重力场大地水准面及重力异常阶次误
- prtools5.2.3工具包
- 脉冲耦合神经网络工具箱PCNN-toolbox
评论
共有 条评论