Commit 7c0af5d0 authored by Claudio Gomes's avatar Claudio Gomes
Browse files

Add modelica models.

parent 4600fc21
model BikeModel
// Taken from
// Parameters are taken from there as well.
parameter Real lf=1.105 "distance from the the center of mass to the front (m)";
parameter Real lr=1.738 "distance from the the center of mass to the rear (m)";
parameter Real x0=0 "initial position in x";
parameter Real y0=0 "initial position in y";
parameter Real psi0=0 "initial orientation";
parameter Real v0=0 "initial velocity along psi0";
output Real x "x coordinate (m)";
output Real y "y coordinate (m)";
output Real psi "Inertial orientation of the model (rad)";
output Real v "speed along psi (m/s)";
output Real beta "is the angle of the current velocity vector of the center of mass with respect to the longitudinal axis of the car (rad)";
input Real deltaf "steering angle at the front wheel (rad)";
initial equation
x = x0;
y = y0;
psi= psi0;
der(x) = v * cos(psi + beta);
der(y) = v * sin(psi + beta);
der(psi) = (v/lr) * sin(beta);
v = v0;
beta = atan( (lr/(lf + lr)) * tan(deltaf) );
end BikeModel;
model BikeModelScenarioDriver
parameter Real speed = 1 "m/s";
BikeModel bike(v0=speed);
Driver driver;
bike.deltaf = driver.steering;
experiment(StartTime = 0, StopTime = 200, Tolerance = 1e-06, Interval = 0.002));
end BikeModelScenarioDriver;
model Driver
parameter Real width = 2.0;
parameter Real amplitude = 0.8;
parameter Real risingtime = 5.0;
parameter Real starttime = 5.0;
parameter Integer nperiod = 1;
parameter Real period = 300;
output Real steering;
Modelica.Blocks.Sources.Trapezoid trap(nperiod=nperiod, startTime=starttime, rising=risingtime, falling=risingtime, period=period, width=width, amplitude=amplitude);
steering = trap.y;
end Driver;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment