2 The Damped Mass problem
2.1 Modeling
To better understand the problem let’s take a peek at how the simulated model works.
BlockOnSlope.js
Models.BlockOnSlope.prototype.vars =
1{
g: 9.81,
x: 0, // distance from objective s
dx: 0, // velocity v
slope: 1, // slope coefficient alpha = dy/dx in the cartesian plane
F: 0, // Requested u
F_cmd: 0, // Saturated u
friction: 0, // Coulomb friction coefficient mu
T: 0, // Simulation Time
};
Models.BlockOnSlope.prototype.simulate = function (dt, controlFunc)
{
this.F_cmd = controlFunc({x:this.x,dx:this.dx,T:this.T});
if(typeof this.F_cmd != 'number' || isNaN(this.F_cmd)) throw "Error: The controlFunction must return a number.";
2 this.F_cmd = Math.max(-20,Math.min(20,this.F_cmd));
integrationStep(this, ['x', 'dx', 'F'], dt);
}
Models.BlockOnSlope.prototype.ode = function (x)
{
return [
3 x[1],
(x[2]) - (Math.sin(this.slope) * this.g) - (this.friction * x[1]),
20.0 * (this.F_cmd - x[2])
];
}- 1
- The model has obviously some default values for the parameters that can be modified for the different scenarios.
- 2
-
The control command \(u\) is generated by the
controlFunction(block)function provided by us. There are some checks to see if it’s a number. If it’s acceptable then it passes through a saturation between \(\pm20\). - 3
- The model is a simple ODE with equations:
\[ \begin{cases} \dot s = v \\ \dot v = F - sin(\alpha) \cdot g - \mu \cdot v \\ \dot F = -20 \cdot F + 20 \cdot u_{sat} \\ \end{cases} \]
Converting it in state-space representation:
\[ \begin{bmatrix} \dot s \\ \dot v \\ \dot F \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 \\ 0& -\mu & 1\\ 0 & 0 & -20 \end{bmatrix} \begin{bmatrix} s \\ v \\ F \end{bmatrix} + \begin{bmatrix} 0 \\ 0 \\ u_{sat} \end{bmatrix} + \begin{bmatrix} 0 \\ - sin(\alpha) \cdot g \\ 0 \end{bmatrix} \]
\[ \begin{bmatrix} s \\ v \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \end{bmatrix} \begin{bmatrix} s \\ v \\ F \end{bmatrix} \]
Obviously the gravitational term acts as a disturbance.
Converting it in transfer function form is not necessary.
\[ \alpha + \]