I'm missing the 6 to complete the 4 objects. my obstacle on tbe robot_sim_server.m is: obstacle = [1,5,6,11];
A robot simulation server referred as robot_sim_server ("command") is provided to simulate the autonomous robot as it interacts with the environment. Below are the commands to the robot_sim_sever. [left front right] = robot_sim_server("sensor_read") read sensor data [pos dir] = robot_sim_server ("move 0")- turn left [pos dir] = robot_sim_server ("move 1")- move straight one grid [pos dir] robot_sim_server ("move 2")- turn right [pos dir num_move]= robot_sim_server ("status") - returns the position and direction of the robot, and the number of moves since the start of the simulation
clear robot_sim_server - Default values of position, direction, and number of movements are 0. Overall Task: In addition, a robot_plot(pos,dir,obj_loc) function is provided to plot the environment, robot, and objects. reset position, direction, and the number of movements to 0. 1. Develop a navigation algorithm that explores the 4x4 grid and locate the four objects. do 2. The implement the algorithm in Matlab. The program should interact with robot_sim_server () to know the locations of the objects. navigate() while (num of objects < 4) 3. Based on the object locations, determine the sum of the object's distance with respect to the other objects. For example, object 1 sum of distance is Obj1_SOD distance (Obj1,Obj2) + distance(Obj1,Obj3) + distance(Obj1,Obj4) 4. Push the object with the largest sum of distance outside the grid.
12 8 4 0 13 9 5 10 6 14 2 11 7 3
4- 5 6- 7- 18 19 20 21 22 clear figure obj_pos = []; P = 0; clear robot_sim_server; % reset simulation 1 23 24- 25 26 27 28 while length (obj_pos)<4 % sense 1 - 1 result = robot_sim_server ("status"); pos result (1) dir result (2) = num_moves = result (3) Р obj_pos robot plot (pos, dir, obj_pos); pause sense sensor_data = robot_sim_server ("sensor_read"); plan and act if sensor_data (2)==0 && p = 4 result = robot_sim_server ("move 1"); p = p + 1; if p == 1 result = robot sim server ("move ?").
ers\j-den\Downloads\Mini Project 1\Mini Project 1\Demo 1.m x move.mx navigate.mx robot plot.mx robot_sim_server.mx sensor_read.mx + end elseif sensor_data (1)==0 || p == 4 p = 0; end if p == 1 result = robot_sim_server ("move 2"); result = robot_sim_server ("move 0"); elseif sensor_data (3) ***** object detection result = robot_sim_server ("move 2"); if (dir==0) and Window = 0 == if sensor data (2) ==1 if ismember (pos+4, obj_pos)==0% check if the object is already in the lis obj_pos [obj_pos pos+4]; end end end if sensor data (1) ==1 if ismember (pos-1, obj_pos)==0&check if the object is already in the list obj_pos= [obj_pos pos-1]; end if sensor_data (3)=1 if ismember (pos+1, obj_pos)==0 check if the object is already in the list obj_pos [obj pos pos+1];
\Users\j-den\Downloads\Mini Project 1\Mini Project 1\Demo1.m .m x move.m X navigate.mx robot plot.mx robot_sim_server.mx sensor_read.mx + end end elseif (dir ==1) if sensor data (2)==0 if ismember (pos+1, obj_pos)==0% check if the object is already in the list obj_pos = [obj_pos pos+1]; end elseif sensor_data(1) ==1 if ismember (pos+4, obj_pos)==0% check if the object is already in the list obj_pos = [obj_pos pos+4]; end elseif sensor data (1)=-1 if ismember (pos-1, obj_pos)=0 check if the object is already in the list obj_pos = [obj_pos pos-1]; end end ***** end ******
78 79 80 81 82 83- 84 85 88 86 end robot plot (pos, dir,obj_pos); Command Window fx ###
I'm missing the 6 to complete the 4 objects. my obstacle on tbe robot_sim_server.m is: obstacle = [1,5,6,11];
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am