亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wander.m

?? robot_simulator of system
?? M
字號:
% wander.m - navigation behavior for robot simulation
%  written by: Shawn Lankton
%  for: ECE8843 (sort-of) fun (mostly)
%
%  This function collects 'rangefinder' data and uses it to determine
%  velocities for the left and right 'wheels'.  It then calls the drive
%  function to predict where those commands will put the robot and
%  continues.  This is the real 'heart' of the simulation.
%
%  Inputs:
%    posn - [yposn, xposn, theta]
%    rad - radius of the robot body
%    wdia - diameter of the robot's wheelbase
%    course - obstacle matrix (0 = obstacle ~0 = clear)
%    dt - timestep to take between driving and collecting sensor data
%
%  Outputs:
%    none
%

function wander(posn, rad, wdia, course, dt)

vL_target = 5;
vR_target = 5;

% Drive Around
for i = 1:dt:1000
    rangeL = rangefinder([posn(1), posn(2), posn(3)+pi/8], rad, course); %left
    rangeR = rangefinder([posn(1), posn(2), posn(3)-pi/8], rad, course); %right
    rangeC = rangefinder(posn, rad,course); %center
    
    
    if(rangeL <= 10 || rangeR <= 10)
        %if both are blocked
        if(rangeL <= 10 && rangeR <=10)
            %turn towards larger if possible
            if(rangeL >= rangeR+2)
                vL = -1;
                vR = 1;
            else if(rangeR >= rangeL+2)
                vL = 1;
                vR = -1;
                else
                    %otherwise turn randomly
                    vL = sign(.5-rand);
                    vR = -vL;
                end
            end

            while(rangeL <= 10 || rangeR <= 10 || rangeC <= 5)
                %keep turning until both are free, and then a little more
                rangeL = rangefinder([posn(1), posn(2), ...
                                      posn(3)+pi/8], rad, course); %left
                rangeR = rangefinder([posn(1), posn(2), ...
                                      posn(3)-pi/8], rad, course); %right
                rangeC = rangefinder(posn, rad,course); %center
                
                posn = drive(posn, wdia, vL, vR, dt);
                
                drawbot(posn,rad,course);
                
                if(detectcollision(posn,rad,course))
                    disp(['Collision Detected at (' num2str(posn(1))...
                          ',' num2str(posn(2)) ')']);
                end
                drawnow;
            end
            %continue with slightly random arc
            vL = vL_target;
            vR = vR_target;
        else
            %if only one is blocked, turn away from it
            if(rangeL >= rangeR)
                vL = 5-11+rangeR;
                vR = 5;
            else
                vL = 5;
                vR = 5-11+rangeL;
            end
        end
    else
        %if nobody is blocked, contintue on the random arc.
        vL = vL_target;
        vR = vR_target;
    end
    
    % every 15 iterations, determine a new random-ish arc
    if(mod(i,5) == 0)
        vL_target = 5;
        vR_target = 5 + 2*(.5-rand);
    end
    
    %determine new position
    posn = drive(posn, wdia, vL, vR, dt);
    if(detectcollision(posn,rad,course))
        disp(['Collision Detected at (' num2str(posn(1)) ...
              ',' num2str(posn(2)) ')']);
    end

    %draw the robot
    drawbot(posn,rad,course);
    drawnow;

end




%rangefinder.m - finds distance to nearest obstacle
%  written by: Shawn Lankton
%  for: ECE8843 (sort-of) fun (mostly)
%
%  The 'sensor' of this robotic simuator.  It starts at the border of the
%  robot and then marches outward, testing each pixel.  If it finds a 0
%  pixel (obstacle) it returns the number of steps taken to get there.
%  Thus it acts like a rangefinder.  It has a max range of 100, and a min
%  range of 0, although if you get a 0 reading it means you crashed.
%
%  Also, this takes in posn in the same way all these other functions do,
%  but it may be beneficial to change the value of posn(3) (theta) so that
%  the rangefinder doesn't point straight forward.  In this way you can
%  simulate multiple ranefinders at different angles.
%
%  Another note... this isn't totally realistic because it doesn't have any
%  field of view.  Its just a line real IR or sonar rangefinders have a x
%  degree field of view and objects anywhere within are seen.  This
%  doesn't.
%
%  Inputs:
%    posn - [yposn, xposn, theta]
%    rad - radius of the robot's body
%    course - obstacle matrix (0 = obstacle ~0 = clear)
%
%  Outputs:
%    dist - distance to obstacle.
%

function dist = rangefinder(posn, rad, course)

% get size of course
[dimy, dimx] = size(course);

%for 100 steps.
for i = rad:(100+rad)
    %get x&y coords of point to test
    y = posn(1)+ i*sin(posn(3));
    x = posn(2)+ i*cos(posn(3));
    
    %make sure x & y are inside the course
    x(x < 1) = 1;
    x(x > dimx) = dimx;
    y(y < 1) = 1;
    y(y > dimy) = dimy;
    
    %see if the course at x & y is an obstacle or not
    if(course(round(x),round(y)) == 0)
        %if yes, return the distance to the obstacle
        dist = i-rad;
        return;
    end
end

%if no obstacles found within 100 pixels, return 100
dist = 100;
return;

%drive.m - does the dead rekoning kinematics based on wheel speeds
%  written by: Shawn Lankton
%  for: ECE8843 (sort-of) fun (mostly)
%
%  This predicts how the robot's position will change based on velocities
%  for the left and right wheel along with a 'time driving.'  This is based
%  on the simplest formulation for 2-wheeled kinematics that I could find.
%  http://rossum.sourceforge.net/papers/DiffSteer/DiffSteer.html
%
%  Inputs:
%    posn - [yposn, xposn, theta]
%    wdia - diameter of the robot's wheelbase
%    vL - left wheel velocity
%    vR - right wheel velocity
%    t - time driving at these velocities
%
%  Outputs:
%    newposn - [yposn, xposn, theta]
%

function [newposn] = drive(posn, wdia, vL, vR, t)

%get speed differences & sums
vdiff = vR-vL;
vsum = vR+vL;

%calculate new angle (pretty simple)
newposn(3) = posn(3) + vdiff*t/wdia;

if(vdiff == 0)
    %calculate new [y x] if wheels moving together.
    newposn(1) = vL*t*sin(posn(3))+posn(1);
    newposn(2) = vR*t*cos(posn(3))+posn(2);  
else
    %calculate new [y x] if wheels moving at unequal speeds.
    newposn(1) = posn(1) - wdia*vsum/(2*vdiff)*(cos(vdiff*t/wdia+posn(3))-cos(posn(3)));
    newposn(2) = posn(2) + wdia*vsum/(2*vdiff)*(sin(vdiff*t/wdia+posn(3))-sin(posn(3)));
end

%detectcollisions.m - sees if the robot hit something
%  written by: Shawn Lankton
%  for: ECE8843 (sort-of) fun (mostly)
%
%  This just checks the border of the robot to see if any of the pixels are
%  on black (an obstacle).  The function is a little 'iffy' because it has
%  significant rounding error (espicially on my 128x128 course).  Also, if
%  an obstacle somehow gets inside the robot, detectcollisions won't see
%  it.  It only detects collisions on the edge.  it returns 1 for 'yes I
%  hit something' and 0 for 'nah, I'm fine.'
%
%  Inputs:
%    posn - [yposn, xposn, theta]
%    rad - radius of the robot's body
%    course - obstacle matrix (0 = obstacle ~0 = clear)
%
%  Outputs:
%    bool - 1 (yes, I hit something), 0 (nah, I'm fine)
%

function bool = detectcollision(posn, rad, course)

%get a circle representing the robot's body
angs = 0:pi/10:2*pi;
y = posn(1) + rad*sin(angs);
x = posn(2) + rad*cos(angs);

%for each of these 20 pixels, check if one is on black
for i = 1:length(y)
    if(course(round(x(i)),round(y(i))) == 0)
        %if so, return 1
        bool = 1;
        return;
    end
end

%if not, return 0
bool = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一级二级三级在线免费观看| 97精品电影院| 欧美美女黄视频| 国产婷婷色一区二区三区| 一区二区三区日韩精品视频| 久久97超碰国产精品超碰| 欧美性生活久久| 欧美激情一区二区三区四区| 三级一区在线视频先锋| 欧美最猛黑人xxxxx猛交| 精品国产不卡一区二区三区| 亚洲成人7777| 色屁屁一区二区| 中文字幕一区二区在线播放| 国产呦萝稀缺另类资源| 日韩精品一区二区在线观看| 五月综合激情婷婷六月色窝| 色综合久久天天| 亚洲视频一二区| 99久久精品国产一区| 国产精品久久久久久户外露出| 国产最新精品精品你懂的| 精品久久国产字幕高潮| 免费av网站大全久久| 欧美日韩国产综合草草| 天天色综合成人网| 欧美卡1卡2卡| 日韩电影在线一区二区三区| 欧美日本韩国一区| 亚洲高清免费在线| 91麻豆精品国产91久久久使用方法 | 亚洲男人的天堂在线观看| 粉嫩aⅴ一区二区三区四区| 欧美国产在线观看| 成人网在线播放| 亚洲日本青草视频在线怡红院| 成人影视亚洲图片在线| 18成人在线观看| 色8久久人人97超碰香蕉987| 亚洲午夜精品在线| 日韩欧美中文一区| 韩国欧美一区二区| 久久久久久久久岛国免费| 国产成人av福利| 国产精品视频麻豆| 91电影在线观看| 日韩激情中文字幕| 久久久久久久久免费| 99久久久无码国产精品| 亚洲大片精品永久免费| 精品国产免费一区二区三区四区| 久久成人精品无人区| 国产午夜三级一区二区三| 波多野洁衣一区| 亚洲高清不卡在线观看| 久久综合色天天久久综合图片| 成人午夜激情视频| 亚洲午夜av在线| 精品久久久久久久人人人人传媒| 不卡免费追剧大全电视剧网站| 亚洲成av人片在线观看| 欧美不卡在线视频| 91小视频在线| 久久国产日韩欧美精品| 亚洲欧美日本在线| 日韩三级电影网址| eeuss鲁片一区二区三区| 午夜婷婷国产麻豆精品| 国产亚洲综合色| 欧美日韩在线播| 国产福利一区在线观看| 亚洲成a人片在线观看中文| 欧美精品一区二区三| 色哟哟一区二区在线观看| 国内精品久久久久影院薰衣草| 国产精品色哟哟网站| 欧美成人艳星乳罩| 欧美午夜不卡视频| 国产麻豆精品theporn| 日本在线不卡视频| 亚洲男人天堂一区| 国产日韩av一区二区| 91精品免费在线观看| 91免费版在线看| 国产成人精品免费| 狠狠久久亚洲欧美| 亚洲第一激情av| 亚洲欧洲制服丝袜| 国产精品第五页| 久久综合久久综合久久综合| 制服视频三区第一页精品| 色香蕉久久蜜桃| 成人福利视频在线| 国产盗摄女厕一区二区三区| 奇米色一区二区| 丝袜诱惑亚洲看片| 亚洲成人综合视频| 亚洲综合一区在线| 亚洲精品大片www| 最新中文字幕一区二区三区| 国产日韩精品一区二区三区 | 99久久99久久精品免费观看| 蜜臀精品一区二区三区在线观看| 亚洲人成亚洲人成在线观看图片| 337p日本欧洲亚洲大胆精品| 91精品国产综合久久福利| 91官网在线观看| 一本到高清视频免费精品| 成人黄色免费短视频| 国产99久久久久久免费看农村| 韩国成人在线视频| 国产精品69久久久久水密桃| 激情久久五月天| 国产精品一区一区| 国产精品一卡二| 成人午夜碰碰视频| 91日韩在线专区| 91免费看片在线观看| 91久久精品网| 欧美高清视频一二三区| 在线不卡中文字幕| 欧美大胆人体bbbb| 久久色在线观看| 国产精品丝袜在线| 亚洲人午夜精品天堂一二香蕉| 一区二区三区精品视频在线| 亚洲伊人色欲综合网| 日韩专区欧美专区| 久久99精品视频| 成人av电影观看| 欧美日韩大陆在线| 精品少妇一区二区三区在线播放| 久久久久久一级片| 中文字幕在线免费不卡| 亚洲一区二区三区小说| 奇米四色…亚洲| 成人的网站免费观看| 欧美午夜免费电影| 精品国产髙清在线看国产毛片| 2017欧美狠狠色| 亚洲男人的天堂网| 日本美女一区二区三区视频| 成人一道本在线| 69av一区二区三区| 久久久www成人免费毛片麻豆| ●精品国产综合乱码久久久久| 亚洲高清免费视频| 国产91高潮流白浆在线麻豆| 91福利在线播放| 久久网站最新地址| 亚洲一级在线观看| 懂色一区二区三区免费观看| 欧美午夜理伦三级在线观看| 欧美精品一区二区三区蜜桃视频 | 99久久国产综合精品色伊| 欧美日韩大陆在线| 136国产福利精品导航| 乱一区二区av| 色综合色狠狠综合色| 久久亚洲捆绑美女| 亚洲一级二级三级在线免费观看| 国产精品综合av一区二区国产馆| 欧美亚洲一区二区在线观看| 久久看人人爽人人| 日本成人在线看| 色美美综合视频| 国产日韩欧美高清| 久久99蜜桃精品| 欧美三级蜜桃2在线观看| 国产精品蜜臀在线观看| 黄页网站大全一区二区| 精品视频一区 二区 三区| 国产片一区二区| 国产一区在线精品| 欧美性大战久久| 一区二区三区美女视频| 成人免费不卡视频| 精品1区2区在线观看| 日韩va欧美va亚洲va久久| 色综合久久88色综合天天| 国产精品日产欧美久久久久| 国产精品自产自拍| 精品久久久久久久人人人人传媒| 视频一区免费在线观看| 欧美日本视频在线| 五月天一区二区| 欧美日韩一区二区三区高清| 一区二区三区在线影院| 91麻豆精品秘密| 亚洲精品国产精华液| 91一区二区在线| 亚洲免费av观看| 91精品福利视频| 一区二区久久久久久| 91香蕉视频黄| 亚洲激情男女视频| 色播五月激情综合网| 69av一区二区三区| 国产欧美一区二区三区在线看蜜臀 | 欧美日韩欧美一区二区|