NAMA :WAHYU NUR CAHYO NIM :200491100015
4.5. Tugas Praktikum
Adapun tugas praktikum mengenai praktikum robotika modul empat seperti pada keterangan dibawah ini
1. Membuat map sesuai dengan gambar di bawah ini 2. Ukuran robot harus proporsional dengan ukuran map 3. Beri Nama dan NIM pada title Plot
4. Beri bentuk lingkaran warna biru pada titik awal robot dan beri bentuk kotak warna merah pada titik akhir robot
a. Siapkan MATLAB 2021 b. Instal exampleMaps
c. 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.1.
Gambar 4.1. Folder baru library exampleMaps
d. Gambar lintasan sesuai dengan asisten praktikum masing-masing dengan ketentuan yang sudah disepakati, seperti Gambar 4.2.
Gambar 4.2. Pembuatan map
e. buat program pada script
%filePath =
fullfile(fileparts(which('PathPlanningExample')),'data','exampleMaps.mat');
%load(filePath)
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);
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;
%grid on;
title({'wahyu nur cahyo';'200491100015'});
orientasiAwal = 0;
robotCurrentPose = [startLocation orientasiAwal];
%Menggunakan Class ExampleHelperDifferentialDriveRobot robot = ExampleHelperDifferentialDriveRobot(robotCurrentPose);
%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
Berikut ini adalah hasil running program robot planning dengan titik awal dan akhir yang telah ditentukan seperti pada Gambar 4.3.
Gambar 4.3. Running program