Project

General

Profile

Statistics
| Revision:

root / branches / 16299_s10 / matlab / visualizeRobots.m @ 1821

History | View | Annotate | Download (1.04 KB)

1 1812 cbrownel
function [mov] = visualizeRobots(f,n,Xs,Ys,Thetas,Speeds,idx,color,mov,winsize)
2 1746 bneuman
3 1812 cbrownel
% Scales arrows to length
4
arrowScale = 1.5;
5
6 1747 bneuman
clf;
7 1797 bneuman
ax = [min(min(Xs))-1, max(max(Xs))+1, min(min(Ys))-1, max(max(Ys))+1];
8
9
if ax(1) > -10
10
    ax(1) = -10;
11
end
12
if ax(2) < 10
13
    ax(2) = 10;
14
end
15
if ax(3) > -10
16
    ax(3) = -10;
17
end
18
if ax(4) < 10
19
    ax(4) = 10;
20
end
21
22
axis(ax);
23
24
%axis([-10 10 -10 10])
25
26 1746 bneuman
axis manual
27
set( gca,'nextplot','add' );
28
for j = 1:n
29 1821 cbrownel
    h = plot_arrow( Xs(j,idx),Ys(j,idx),Xs(j,idx) + Speeds(j, idx-1) * arrowScale * cos(Thetas(j,idx)),Ys(j,idx) + Speeds(j, idx-1) * arrowScale * sin(Thetas(j,idx)),'color',color(j,:),'facecolor',color(j,:),'edgecolor',color(j,:) );
30
   	%h = plot_arrow( Xs(j,idx),Ys(j,idx),Xs(j,idx) + cos(Thetas(j,idx)),Ys(j,idx) + sin(Thetas(j,idx)),'color',color(j,:),'facecolor',color(j,:),'edgecolor',color(j,:) );
31
32 1812 cbrownel
    set( h,'linewidth',3 );
33
	d = plot( Xs(j,idx),Ys(j,idx), '.k');
34
	set( d,'MarkerSize',5 );
35 1746 bneuman
end
36
hold off;
37
38 1812 cbrownel
if idx < 3 %s o we don't see giant arrows
39
    clf
40 1747 bneuman
end
41 1816 bbland
%mov(:,idx) = getframe(f,winsize);
42
pause(.001);
43 1747 bneuman
44 1746 bneuman
end