Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getGraphics(solo_rbt_path, solo_rbt1, solo_rbt2, solo_rbt3,
- coop_rbt_path, coop_rbt1, coop_rbt2, coop_rbt3)
- csv_reader = csv.reader(csv_file, delimiter=',')
- % read files from solo experiment
- data_solo_path = dlmread(solo_rbt_path, ',', 0, 0); % robot path
- data_solo_rbt1 = dlmread(solo_rbt1, ',', 0, 0);
- data_solo_rbt2 = dlmread(solo_rbt2, ',', 0, 0);
- data_solo_rbt3 = dlmread(solo_rbt3, ',', 0, 0);
- % read files from coop experiment
- data_coop_path = dlmread(coop_rbt_path, ',', 0, 0);
- data_coop_rbt1 = dlmread(coop_rbt1, ',', 0, 0);
- data_coop_rbt2 = dlmread(coop_rbt2, ',', 0, 0);
- data_coop_rbt3 = dlmread(coop_rbt3, ',', 0, 0);
- timer = 1; % starts in second one
- step = 1; % 1 second step
- % solo
- t_solo = [];
- % counter for solo
- counter_solo_path = 1;
- counter_solo_rbt1 = 1;
- counter_solo_rbt2 = 1;
- counter_solo_rbt3 = 1;
- % error of estimation
- erro_solo_rbt1 = [];
- erro_solo_rbt2 = [];
- erro_solo_rbt3 = [];
- not_finished = true;
- while (not_finished)
- while (data_solo_path(counter_solo_path, 1) < timer)
- if (counter_solo_path + 1 <= rows(data_solo_path))
- counter_solo_path = counter_solo_path + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_solo_rbt1(counter_solo_rbt1, 1) < timer)
- if (counter_solo_rbt1 + 1 <= rows(data_solo_rbt1))
- counter_solo_rbt1 = counter_solo_rbt1 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_solo_rbt2(counter_solo_rbt2, 1) < timer)
- if (counter_solo_rbt2 + 1 <= rows(data_solo_rbt2))
- counter_solo_rbt2 = counter_solo_rbt2 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_solo_rbt3(counter_solo_rbt3, 1) < timer)
- if (counter_solo_rbt3 + 1 <= rows(data_solo_rbt3))
- counter_solo_rbt3 = counter_solo_rbt3 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- % compute error estimation of robot 1
- if (data_solo_rbt1(counter_solo_rbt1, 8) == 1)
- e = sqrt(power(data_solo_rbt1(counter_solo_rbt1, 2) - data_solo_path(counter_solo_path, 2), 2) + power(data_solo_rbt1(counter_solo_rbt1, 3) - data_solo_path(counter_solo_path, 3), 2) + power(data_solo_rbt1(counter_solo_rbt1, 4) - data_solo_path(counter_solo_path, 4), 2));
- else
- e = NaN;
- endif
- erro_solo_rbt1 = [erro_solo_rbt1, e];
- % compute error estimation of robot 2
- if (data_solo_rbt2(counter_solo_rbt2, 8) == 1)
- e = sqrt(power(data_solo_rbt2(counter_solo_rbt2, 2) - data_solo_path(counter_solo_path, 2), 2) + power(data_solo_rbt2(counter_solo_rbt2, 3) - data_solo_path(counter_solo_path, 3), 2) + power(data_solo_rbt2(counter_solo_rbt2, 4) - data_solo_path(counter_solo_path, 4), 2));
- else
- e = NaN;
- endif
- erro_solo_rbt2 = [erro_solo_rbt2, e];
- % compute error estimation of robot 3
- if (data_solo_rbt3(counter_solo_rbt3, 8) == 1)
- e = sqrt(power(data_solo_rbt3(counter_solo_rbt3, 2) - data_solo_path(counter_solo_path, 2), 2) + power(data_solo_rbt3(counter_solo_rbt3, 3) - data_solo_path(counter_solo_path, 3), 2) + power(data_solo_rbt3(counter_solo_rbt3, 4) - data_solo_path(counter_solo_path, 4), 2));
- else
- e = NaN;
- endif
- erro_solo_rbt3 = [erro_solo_rbt3, e];
- t_solo = [t_solo; timer];
- % show time between each estimation
- %printf("Timer: %d - Path timer: %f - Robot 1: %f - Erro: %f\n", timer, data_solo_path(counter_solo_path - 1, 1), data_solo_rbt1(counter_solo_rbt1 - 1, 1), e);
- timer = timer + step;
- endwhile
- % coop
- t_coop = [];
- timer = 1;
- % counter for coop
- counter_coop_path = 1;
- counter_coop_rbt1 = 1;
- counter_coop_rbt2 = 1;
- counter_coop_rbt3 = 1;
- % error of estimation
- erro_coop_rbt1 = [];
- erro_coop_rbt2 = [];
- erro_coop_rbt3 = [];
- not_finished = true;
- while (not_finished)
- while (data_coop_path(counter_coop_path, 1) < timer)
- if (counter_coop_path + 1 <= rows(data_coop_path))
- counter_coop_path = counter_coop_path + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_coop_rbt1(counter_coop_rbt1, 1) < timer)
- if (counter_coop_rbt1 + 1 <= rows(data_coop_rbt1))
- counter_coop_rbt1 = counter_coop_rbt1 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_coop_rbt2(counter_coop_rbt2, 1) < timer)
- if (counter_coop_rbt2 + 1 <= rows(data_coop_rbt2))
- counter_coop_rbt2 = counter_coop_rbt2 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- while (data_coop_rbt3(counter_coop_rbt3, 1) < timer)
- if (counter_coop_rbt3 + 1 <= rows(data_coop_rbt3))
- counter_coop_rbt3 = counter_coop_rbt3 + 1;
- else
- not_finished = false;
- break;
- endif
- endwhile
- % compute error estimation of robot 1
- if (data_coop_rbt1(counter_coop_rbt1, 8) == 1)
- e = sqrt(power(data_coop_rbt1(counter_coop_rbt1, 2) - data_coop_path(counter_coop_path, 2), 2) + power(data_coop_rbt1(counter_coop_rbt1, 3) - data_coop_path(counter_coop_path, 3), 2) + power(data_coop_rbt1(counter_coop_rbt1, 4) - data_coop_path(counter_coop_path, 4), 2));
- else
- e = NaN;
- endif
- erro_coop_rbt1 = [erro_coop_rbt1, e];
- % compute error estimation of robot 2
- if (data_coop_rbt2(counter_coop_rbt2, 8) == 1)
- e = sqrt(power(data_coop_rbt2(counter_coop_rbt2, 2) - data_coop_path(counter_coop_path, 2), 2) + power(data_coop_rbt2(counter_coop_rbt2, 3) - data_coop_path(counter_coop_path, 3), 2) + power(data_coop_rbt2(counter_coop_rbt2, 4) - data_coop_path(counter_coop_path, 4), 2));
- else
- e = NaN;
- endif
- erro_coop_rbt2 = [erro_coop_rbt2, e];
- % compute error estimation of robot 3
- if (data_coop_rbt3(counter_coop_rbt3, 8) == 1)
- e = sqrt(power(data_coop_rbt3(counter_coop_rbt3, 2) - data_coop_path(counter_coop_path, 2), 2) + power(data_coop_rbt3(counter_coop_rbt3, 3) - data_coop_path(counter_coop_path, 3), 2) + power(data_coop_rbt3(counter_coop_rbt3, 4) - data_coop_path(counter_coop_path, 4), 2));
- else
- e = NaN;
- endif
- erro_coop_rbt3 = [erro_coop_rbt3, e];
- t_coop = [t_coop; timer];
- % show time between each estimation
- %printf("Timer: %d - Path timer: %f - Robot 1: %f - Erro: %f\n", timer, data_coop_path(counter_coop_path - 1, 1), data_coop_rbt1(counter_coop_rbt1 - 1, 1), e);
- timer = timer + step;
- endwhile
- max_erro_value = max([erro_solo_rbt1, erro_solo_rbt2, erro_solo_rbt3, erro_coop_rbt1, erro_coop_rbt2, erro_coop_rbt3]);
- max_time_solo = rows(t_solo);
- max_time_coop = rows(t_coop);
- hf = figure ();
- % solo
- subplot(3, 2, 1);
- plot(t_solo, erro_solo_rbt1);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_solo + 5]);
- title("Estimation error of object position - Turtlebot 1\n Non-cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- subplot(3, 2, 3);
- plot(t_solo, erro_solo_rbt2);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_solo + 5]);
- title("Estimation error of object position - Turtlebot 2\n Non-cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- subplot(3, 2, 5);
- plot(t_solo, erro_solo_rbt3);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_solo + 5]);
- title("Estimation error of object position - Turtlebot 3\n Non-cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- %% coop
- subplot(3, 2, 2);
- plot(t_coop, erro_coop_rbt1);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_coop + 5]);
- title("Estimation error of object position - Turtlebot 1\n Cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- subplot(3, 2, 4);
- plot(t_coop, erro_coop_rbt2);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_coop + 5]);
- title("Estimation error of object position - Turtlebot 2\n Cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- subplot(3, 2, 6);
- plot(t_coop, erro_coop_rbt3);
- ylim ([0.0, max_erro_value + 0.5]);
- xlim([0.0, max_time_coop + 5]);
- title("Estimation error of object position - Turtlebot 3\n Cooperative approach");
- xlabel("Time-step");
- ylabel("Error in world reference frame");
- set(gca, "fontsize", 12);
- print (hf, "plot15_7.pdf", "-deps");
- endfunction
Add Comment
Please, Sign In to add comment