I'm developing a drone simulation in OpenModelica. In an equation block I am calculating velocity and position vectors, but I want to cap the velocity to a certain value. This is a simplified example of my drone block.
block drone
parameter Real mass = 0.985;
constant Real g = 9.8;
constant Real maxSpeed = 15.0;
Input Real Fx,Fy,Fz;
Real x,y,z;
Real vX,vY,vZ;
equation
der(vX) = Fx / mass;
der(vY) = Fy / mass;
der(vZ) = Fz / (mass*g);
der(x) = vX;
der(y) = vY;
der(z) = vZ;
end drone;
EDIT: The velocity vector in the example have to be capped only if the speed of the drone exceed the maxSpeed value