Java / Reengineering
(EN google-translate)
(PL google-translate)
Als Zwischenschritt soll auf möglichst effiziente Weise das SUMO-Simulationsmodell von Scilab nach Java/Processing übertragen werden.
Verwenden Sie als Integrator die nachfolgende Implementierung eines Runge-Kutta-Integrators:
public class Integrator { int anzahl; double[] k1,k2,k3,k4; double[] yhilf; Modell modell; public Integrator(Modell modell) { this.modell = modell; anzahl = modell.getGleichungsanzahl(); k1 = new double[anzahl]; k2 = new double[anzahl]; k3 = new double[anzahl]; k4 = new double[anzahl]; yhilf = new double[anzahl]; } public void zeitschritt(double[] y,double[] y_alt, double t, double dt) { modell.steigung(k1,y_alt,t); for(int i=0;i<anzahl;i++) yhilf[i] = y_alt[i] + 0.5*dt*k1[i]; modell.steigung(k2,yhilf,t+0.5*dt); for(int i=0;i<anzahl;i++) yhilf[i] = y_alt[i] + 0.5*dt*k2[i]; modell.steigung(k3,yhilf,t+0.5*dt); for(int i=0;i<anzahl;i++) yhilf[i] = y_alt[i] + dt*k3[i]; modell.steigung(k4,yhilf,t+dt); for(int i=0;i<anzahl;i++) y[i] = y_alt[i] + (dt/6.0)*(k1[i]+2.0*k2[i]+2.0*k3[i]+k4[i]); } }
Code 0-1: Integrator.pde / Integrator.java
Hinweise
|
Erläuterungen:
y_neu neuer Systemzustand nach einem Integrationsschritt: x y phi vx vy omega y_alt alter Systemzustand pwm_li PWM-Wert linke Kette pwm_re PWM-Wert rechte Kette Fext externe Kraft (2D-Vektor / 2D-Array) resultierend aus Zusammenstoß mit anderem Fahrzeug Mext externes Moment (1D / double) resultierend aus Zusammenstoß mit anderem Fahrzeug sensor Entfernungssensorwert resultierend aus aktueller Situation dt Zeitschrittweite für Integration
Code 0-2: Erläuterungen
Beispiel-Projekte mit Processing


Musterlösung








