MODUL IV ROBOTIKA
4.5. Tugas Praktikum
tercepat lainnya menuju titik tujuan. Hasil pergerakan yang dilakukan robot untuk mencapai led f dengan rintangan pada led b. Robot akan berubah arah menghadap led d lalu lurus lagi ke led d, lalu lurus lagi ke led e, lalu lurus lagi ke led f. seperti Gambar 4.3.
Gambar 4.4. Skema pengujian
Pengujian Pengujian pada tahap ini dilakukan percobaan yang dilakukan robot yang bergerak menuju posisi destinasi tujuan berbeda. Bentuk skema 3x2 yang artinya terdapat 6 rute lintasan yang dapat di lewati robot ditambahkan berupa satu rute yang tidak dapat dilewati sebagai rintangan. Setelah memilih set point rute start, sebagai posisi awal robot pada lintasan kemudian menentukan led posisi destinasi yang menjadi tujuan robot
n. Siapkan MATLAB 2021 o. Instal exampleMaps
p. Tambahkan exampleMaps pada folder yang sudah kita siapkan dan file program MATLAB dan juga gambar maps lintasan
Berikut adalah pembuatan folder baru yang didalamnya terdapat file MATLAB, gambar lintasan, dan juga library exampleMaps seperti Gambar 4.4.
Gambar 4.4. Folder baru library exampleMaps
d. Gambar lintasan sesuai dengan asisten praktikum masing-masing dengan ketentuan yang sudah disepakati, seperti Gambar 4.5.
lxiv
Gambar 4.5. Pembuatan map
e. Buat program setelah itu screenshoot hasil running program dan input seperti Tabel 4.1. Berikut
Tabel 4.1. Program dan Running Program
Program Running program
%file Path = fullfile (file
parts(which('PathPlanningExample')),'data','exampleMa ps.mat');
load exampleMaps.mat
image=imread('revisike2.png');
abu=rgb2gray(image);
bwimage = abu< 0.5;
mapbaru = robotics.BinaryOccupancyGrid(bwimage);
show(mapbaru);
robotRadius = 0.5;
mapInflated = copy(mapbaru);
%% Construct PRM and Set Parameters prm = robotics.PRM;
prm.Map = mapInflated;
prm.NumNodes = 50;
prm.ConnectionDistance = 5;
% Define start and end locations on the map for the path planner to use.
startLocation = [25 20];
endLocation = [111 114];
path = findpath(prm, startLocation, endLocation);
while isempty(path)
prm.NumNodes = prm.NumNodes + 10;
% Use the |update| function to re-create the PRM roadmap with the changed
% attribute
lxv
Program Running program update(prm);
% Search for a feasible path with the updated PRM path = findpath(prm, startLocation, endLocation);
end
% Display path path;
total = prm.NumNodes;
show(prm, 'Map', 'on', 'Roadmap', 'on', 'Path','on');
rectangle('position',[25 20 5 5],'FaceColor','r')
rectangle('position',[111 114 5 5],'Curvature',[1 1],'FaceColor','b')
hold on;
%grid on;
title({'wahyu nur cahyo';'200491100015'});
orientasiAwal = 0;
robotCurrentPose = [startLocation orientasiAwal];
%Menggunakan
Class ExampleHelperDifferentialDriveRobot
robot=ExampleHelperDifferentialDriveRobot(robotCurr entPose);
controller = robotics.PurePursuit;
controller.Waypoints = path;
controller.DesiredLinearVelocity = 1;
controller.MaxAngularVelocity = 5;
controller.LookaheadDistance = 0.3;
radiusTarget = 0.1;
jarakKeTarget = norm(startLocation - endLocation);
while( jarakKeTarget > radiusTarget )
[v, omega] = step(controller, robot.CurrentPose);
drive(robot, v, omega)
lxvi
Program Running program titikSekarang = robot.CurrentPose(1:2);
jarakKeTarget = norm(titikSekarang - endLocation);
end
%file Path = fullfile (file
parts(which('PathPlanningExample')),'data','exampleMa ps.mat');
%load(file Path) load exampleMaps.mat
image=imread('revisike2.png');
abu=rgb2gray(image);
bwimage = abu< 0.5;
mapbaru = robotics.BinaryOccupancyGrid(bwimage);
show(mapbaru);
robotRadius = 0.5;
mapInflated = copy(mapbaru);
%inflate(mapInflated,robotRadius)
%% Construct PRM and Set Parameters prm = robotics.PRM;
prm.Map = mapInflated;
prm.NumNodes = 50;
prm.ConnectionDistance = 5;
% Define start and end locations on the map for the path planner to use.
startLocation = [25 20];
endLocation = [115 115];
path = findpath(prm, startLocation, endLocation);
while isempty(path)
% No feasible path found yet, increase the number of nodes
prm.NumNodes = prm.NumNodes + 10;
lxvii
Program Running program % Use the |update| function to re-create the PRM
roadmap with the changed % attribute
update(prm);
% Search for a feasible path with the updated PRM path = findpath(prm, startLocation, endLocation);
end
% Display path path;
total = prm.NumNodes;
show(prm, 'Map', 'on', 'Roadmap', 'on', 'Path','on');
rectangle('position',[25 20 5 5],'FaceColor','r') rectangle('position',[115 115 5 5],'Curvature',[1 1],'FaceColor','b')
hold on;
%grid on;
title({'SARIFATUL LAILA';'200491100025'});
orientasiAwal = 0;
robotCurrentPose = [startLocation orientasiAwal];
%Menggunakan Class
ExampleHelperDifferentialDriveRobot robot =
ExampleHelperDifferentialDriveRobot(robotCurrentPos e);
%Menggunakan kontrol dari pure pursuit controller = robotics.PurePursuit;
controller.Waypoints = path;
controller.DesiredLinearVelocity = 1;
controller.MaxAngularVelocity = 5;
controller.LookaheadDistance = 0.3;
lxviii
Program Running program radiusTarget = 0.1;
jarakKeTarget = norm(startLocation - endLocation);
while( jarakKeTarget > radiusTarget )
[v, omega] = step(controller, robot.CurrentPose);
titikSekarang = robot.CurrentPose(1:2);
jarakKeTarget = norm(titikSekarang - endLocation);
end
%file Path = fullfile (file
parts(which('PathPlanningExample')),'data','exampleMa ps.mat');
%load(file Path) load exampleMaps.mat
image=imread('revisike2.png');
abu=rgb2gray(image);
bwimage = abu< 0.5;
mapbaru = robotics.BinaryOccupancyGrid(bwimage);
show(mapbaru);
robotRadius = 0.5;
mapInflated = copy(mapbaru);
%inflate(mapInflated,robotRadius)
%% Construct PRM and Set Parameters prm = robotics.PRM;
prm.Map = mapInflated;
prm.NumNodes = 50;
prm.ConnectionDistance = 5;
% Define start and end locations on the map for the path planner to use.
startLocation = [25 20];
endLocation = [111 114];
path = findpath(prm, startLocation, endLocation);
lxix
Program Running program while isempty(path)
% No feasible path found yet, increase the number of nodes
prm.NumNodes = prm.NumNodes + 10;
% Use the |update| function to re-create the PRM roadmap with the changed
% attribute update(prm);
% Search for a feasible path with the updated PRM path = findpath(prm, startLocation, endLocation);
end
% Display path path;
total = prm.NumNodes;
show(prm, 'Map', 'on', 'Roadmap', 'on', 'Path','on');
rectangle('position',[25 20 5 5],'FaceColor','r') rectangle('position',[111 114 5 5],'Curvature',[1 1],'FaceColor','b')
hold on;
title({'Moh Misbahul Munir';'200491100043'});
orientasiAwal = 0;
robotCurrentPose = [startLocation orientasiAwal];
%Menggunakan Class
ExampleHelperDifferentialDriveRobot Robot=
ExampleHelperDifferentualDriveRobot(robotCurrent)
%Menggunakan kontrol dari pure pursuit controller = robotics.PurePursuit;
controller.Waypoints = path;
controller.DesiredLinearVelocity = 1;
lxx
Program Running program controller.MaxAngularVelocity = 5;
controller.LookaheadDistance = 0.3;
radiusTarget = 0.1;
jarakKeTarget = norm(startLocation - endLocation);
while( jarakKeTarget > radiusTarget )
[v, omega] = step(controller, robot.CurrentPose);
%%[v, omega] = controller(robot.getRobotPose);
drive(robot, v, omega)
titikSekarang = robot.CurrentPose(1:2);
jarakKeTarget = norm(titikSekarang - endLocation);
end
%file Path = fullfile (file
parts(which('PathPlanningExample')),'data','exampleMa ps.mat');
%load(file Path) load exampleMaps.mat
image=imread('revisike2.png');
abu=rgb2gray(image);
bwimage = abu< 0.5;
mapbaru = robotics.BinaryOccupancyGrid(bwimage);
show(mapbaru);
robotRadius = 0.5;
mapInflated = copy(mapbaru);
%inflate(mapInflated,robotRadius)
%% Construct PRM and Set Parameters prm = robotics.PRM;
prm.Map = mapInflated;
prm.NumNodes = 50;
prm.ConnectionDistance = 5;
% Define start and end locations on the map for the path
lxxi
Program Running program planner to use.
startLocation = [25 20];
endLocation = [111 114];
path = findpath(prm, startLocation, endLocation);
while isempty(path)
% No feasible path found yet, increase the number of nodes
prm.NumNodes = prm.NumNodes + 10;
% Use the |update| function to re-create the PRM roadmap with the changed
% attribute update(prm);
% Search for a feasible path with the updated PRM path = findpath(prm, startLocation, endLocation);
end
% Display path path;
total = prm.NumNodes;
show(prm, 'Map', 'on', 'Roadmap', 'on', 'Path','on');
rectangle('position',[25 20 5 5],'FaceColor','r') rectangle('position',[111 114 5 5],'Curvature',[1 1],'FaceColor','b')
hold on;
title({‘Alvio nita karina lukman';'200491100058'});
orientasiAwal = 0;
robotCurrentPose = [startLocation orientasiAwal];
ExampleHelperDifferentialDriveRobot robot =
ExampleHelperDifferentialDriveRobot(robotCurrentPos e);
lxxii
Program Running program
%Menggunakan kontrol dari pure pursuit controller = robotics.PurePursuit;
controller.Waypoints = path;
controller.DesiredLinearVelocity = 1;
controller.MaxAngularVelocity = 5;
controller.LookaheadDistance = 0.3;
radiusTarget = 0.1;
jarakKeTarget = norm(startLocation - endLocation);
while( jarakKeTarget > radiusTarget )
[v, omega] = step(controller, robot.CurrentPose);
%%[v, omega] = controller(robot.getRobotPose);
drive(robot, v, omega)
titikSekarang = robot.CurrentPose(1:2);
jarakKeTarget = norm(titikSekarang - endLocation);
end
lxxiii