Gleiter
(EN google-translate)
(PL google-translate)
|

clear(); clf(); XMAX=500; YMAX=500; figur=gcf(); // Handler der Grafik holen figur.figure_size= [500,500]; achsen = gca(); achsen.data_bounds = [0,0;YMAX,XMAX];//Achsen-Definitionsbereich SENSORBREITE=7; SENSORRADIUS = round( (SENSORBREITE-1)/2 ); plot([0,500],[0,0]); plot([0,500],[500,500]); plot([0,0.01],[0,0]); plot([100,400],[100,100]); plot([100,400],[400,400]); plot([100,100.01],[100,400]); plot([400,400.01],[100,400]); plot([150,350],[150,150]); plot([150,350],[350,350]); plot([150,150.01],[150,350]); plot([350,350.01],[150,350]); bodenmatrix = zeros(YMAX,XMAX); sensormatrix = zeros(SENSORBREITE,SENSORBREITE); for xx=100:400 for yy=100:400 bodenmatrix(yy,xx)=4; end end for xx=150:350 for yy=150:350 bodenmatrix(yy,xx)=0; end end Matplot1(sensormatrix,[0,0,SENSORBREITE,SENSORBREITE]); //Matrix füllt ganzen Bereich aus, Default-Colormap. grafik = gce(); grafik.rect = [0,0,SENSORBREITE*8,SENSORBREITE*8]; x=120; y=100; t=0; dt=0.03; m=1.0; D=0.1; vx=0.0; vy=0.0; Fx=0.0; Fy=0.0; ZX=0; ZY=0; for i=1:1000 xalt = x; yalt = y; ax = (Fx - D*vx)/m; ay = (Fy - D*vy)/m; vx = vx + dt*ax; vy = vy + dt*ay; x = x + dt*vx; y = y + dt*vy; //Sensormatrix aktualisieren: ix=round(x); iy=YMAX - round(y); //Umgekehrt, da Koord. von bodenmatrix umgekehrt gegenüber plot. for xx=1:SENSORBREITE for yy=1:SENSORBREITE xb = xx+ix-SENSORRADIUS; yb = yy+iy-SENSORRADIUS; if (xb>0 & xb<=XMAX & yb>0 & yb<=YMAX) then sensormatrix(yy,xx) = bodenmatrix(yy+iy-SENSORRADIUS,xx+ix-SENSORRADIUS); else sensormatrix(yy,xx) = 0; end end end //Konzept für die Regelung ------------------------- gewichte = [30,20,10,0,-10,-20,-30]; wx = gewichte*sensormatrix(4,1:7)'; wy = -gewichte*sensormatrix(1:7,4); Fx = -30*wx + ZX; Fy = -30*wy + ZY; if (wy>0 & wx==0) then ZX=20; elseif (wy<0 & wx==0) then ZX=-20; end if (wy==0 & wx>0) then ZY=20; elseif (wy==0 & wx<0) then ZY=-20; end //ENDE Konzept für die Regelung ------------------------- sleep(10); plot([xalt,x],[yalt,y],'re'); grafik.data = sensormatrix; t=t+dt; end
Code 0-1: gleiter.sce (vergl. oben).

Bild 0-1: Gleiterfahrt, Momentaufnahme.
Übung
Entwickeln und implementieren Sie ein rubustes, transparentes Konzept, mit dessen Hilfe das Fahrzeug gegen Uhrzeigersinn seine Bahn entlangfährt.
Machen Sie dabei gebrauch von den "Mustern für fehlertoleranten Softwareentwurf".