|
7 | 7 | load('xX_1.mat')
|
8 | 8 | load('xX_2.mat')
|
9 | 9 |
|
10 |
| -figure(1) |
11 |
| -hold on |
12 |
| -grid |
13 |
| -axis([-10 10 0 5]) |
14 |
| -axis equal |
15 |
| -filename = 'trajectories.gif'; |
16 |
| -for i=1:size(tT_1,1)-1 |
17 |
| - |
18 |
| - plot(des_1(1), des_1(2), 'X', 'Color', 'b') |
19 |
| - plot(des_2(1), des_2(2), 'X', 'Color', 'r') |
20 |
| - |
21 |
| - viscircles([xX_1(i,1) + des_1(1), xX_1(i,2) + des_1(2)], r(1), 'EdgeColor', 'b') |
22 |
| - viscircles([xX_2(i,1) + des_2(1), xX_2(i,2) + des_2(2)], r(2), 'EdgeColor', 'r') |
23 |
| - viscircles([obs(1,1), obs(1,2)], obs(1,3), 'EdgeColor', 'k') |
24 |
| - |
25 |
| - pause() |
26 |
| - |
27 |
| - drawnow |
28 |
| - frame = getframe(1); |
29 |
| - im = frame2im(frame); |
30 |
| - [imind,cm] = rgb2ind(im,256); |
31 |
| - if i == 1; |
32 |
| - imwrite(imind,cm,filename,'gif', 'Loopcount',inf); |
33 |
| - else |
34 |
| - imwrite(imind,cm,filename,'gif','WriteMode','append'); |
35 |
| - end |
36 |
| - cla |
37 |
| -end |
| 10 | +% figure(1) |
| 11 | +% hold on |
| 12 | +% grid |
| 13 | +% axis([-10 10 0 5]) |
| 14 | +% axis equal |
| 15 | +% filename = 'trajectories.gif'; |
| 16 | +% for i=1:size(tT_1,1)-1 |
| 17 | +% |
| 18 | +% plot(des_1(1), des_1(2), 'X', 'Color', 'b') |
| 19 | +% plot(des_2(1), des_2(2), 'X', 'Color', 'r') |
| 20 | +% |
| 21 | +% viscircles([xX_1(i,1) + des_1(1), xX_1(i,2) + des_1(2)], r(1), 'EdgeColor', 'b') |
| 22 | +% viscircles([xX_2(i,1) + des_2(1), xX_2(i,2) + des_2(2)], r(2), 'EdgeColor', 'r') |
| 23 | +% viscircles([obs(1,1), obs(1,2)], obs(1,3), 'EdgeColor', 'k') |
| 24 | +% |
| 25 | +% pause() |
| 26 | +% |
| 27 | +% drawnow |
| 28 | +% frame = getframe(1); |
| 29 | +% im = frame2im(frame); |
| 30 | +% [imind,cm] = rgb2ind(im,256); |
| 31 | +% if i == 1; |
| 32 | +% imwrite(imind,cm,filename,'gif', 'Loopcount',inf); |
| 33 | +% else |
| 34 | +% imwrite(imind,cm,filename,'gif','WriteMode','append'); |
| 35 | +% end |
| 36 | +% cla |
| 37 | +% end |
38 | 38 |
|
39 | 39 |
|
40 | 40 | % Distances of agent 1 and agent 2 to the obstacle
|
41 | 41 | figure
|
42 |
| -plot(sqrt((xX_1(:,1)+(des_1(1)-obs(1,1))*ones(size(tT_1))).^2 + (xX_1(:,2)+(des_1(2)-obs(1,2))*ones(size(tT_1))).^2)); |
| 42 | +plot(sqrt((xX_1(:,1)+(des_1(1)-obs(1,1))*ones(size(tT_1))).^2 + (xX_1(:,2)+(des_1(2)-obs(1,2))*ones(size(tT_1))).^2), 'Color', [ 0 0.4470 0.7410]); |
43 | 43 | hold on
|
44 |
| -plot(sqrt((xX_2(:,1)+(des_2(1)-obs(1,1))*ones(size(tT_2))).^2 + (xX_2(:,2)+(des_2(2)-obs(1,2))*ones(size(tT_2))).^2)); |
| 44 | +plot(sqrt((xX_2(:,1)+(des_2(1)-obs(1,1))*ones(size(tT_2))).^2 + (xX_2(:,2)+(des_2(2)-obs(1,2))*ones(size(tT_2))).^2), 'Color', [ 0.8500 0.3250 0.0980]); |
| 45 | +constr_x = [0, 30]; |
| 46 | +constr_y = [1.6, 1.6]; |
| 47 | +plot(constr_x, constr_y, 'Color', 'c') |
45 | 48 | grid
|
| 49 | +axis([0 30 1.2 7]) |
46 | 50 |
|
47 | 51 | % Distance of agent 1 to agent 2
|
48 | 52 | figure
|
49 | 53 | hold on
|
| 54 | +constr_x = [0, 30]; |
| 55 | +constr_y = [1.1, 1.1]; |
| 56 | +plot(constr_x, constr_y, 'Color', 'c') |
| 57 | +constr_x = [0, 30]; |
| 58 | +constr_y = [2.1, 2.1]; |
| 59 | +plot(constr_x, constr_y, 'Color', 'c') |
| 60 | +axis([0 30 0.8 2.2]) |
| 61 | + |
50 | 62 | grid
|
51 | 63 | plot(...
|
52 | 64 | sqrt(...
|
53 | 65 | (xX_1(:,1) - xX_2(:,1)+ (des_1(1) - des_2(1))*ones(size(tT_1))).^2 + ...
|
54 | 66 | (xX_1(:,2) - xX_2(:,2)+ (des_1(2) - des_2(2))*ones(size(tT_2))).^2 ...
|
55 |
| - ) ... |
| 67 | + ), 'Color', 'b' ... |
56 | 68 | );
|
57 | 69 |
|
58 | 70 | % errors
|
|
73 | 85 | % inputs
|
74 | 86 | figure
|
75 | 87 | hold on
|
76 |
| -plot(uU_1_proper(1,:)) |
77 |
| -plot(uU_1_proper(2,:)) |
| 88 | +constr_x = [0, 30]; |
| 89 | +constr_y = [-10, -10]; |
| 90 | +plot(constr_x, constr_y, 'Color', 'c') |
| 91 | +constr_x = [0, 30]; |
| 92 | +constr_y = [10, 10]; |
| 93 | +plot(constr_x, constr_y, 'Color', 'c') |
| 94 | +plot(uU_1_proper(1,:), 'Color', [0 0.4470 0.7410]) |
| 95 | +plot(uU_1_proper(2,:), 'Color', [0.8500 0.3250 0.0980]) |
78 | 96 | grid
|
| 97 | +axis([0 30 -11 11]) |
79 | 98 |
|
80 | 99 | figure
|
81 | 100 | hold on
|
82 |
| -plot(uU_2_proper(1,:)) |
83 |
| -plot(uU_2_proper(2,:)) |
| 101 | +constr_x = [0, 30]; |
| 102 | +constr_y = [-10, -10]; |
| 103 | +plot(constr_x, constr_y, 'Color', 'c') |
| 104 | +constr_x = [0, 30]; |
| 105 | +constr_y = [10, 10]; |
| 106 | +plot(constr_x, constr_y, 'Color', 'c') |
| 107 | +plot(uU_2_proper(1,:), 'Color', [0 0.4470 0.7410]) |
| 108 | +plot(uU_2_proper(2,:), 'Color', [ 0.8500 0.3250 0.0980]) |
84 | 109 | grid
|
| 110 | +axis([0 30 -11 11]) |
0 commit comments