model
SLAM.Examples.Vehicles.QuadrotorSIL.Motor
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| parameter | Ct | Real | = 8.54858e-6 | Thrust coefficient [N/(rad/s)^2] |
| parameter | tau_up | Real | = 0.0125 | Motor spin-up time constant [s] |
| parameter | tau_down | Real | = 0.025 | Motor spin-down time constant [s] |
| parameter | tau_inv_mid | Real | = 0.5 * (1.0 / tau_up + 1.0 / tau_down) | Mean inverse motor lag [1/s] |
| parameter | tau_inv_delta | Real | = 0.5 * (1.0 / tau_up - 1.0 / tau_down) | Signed inverse motor lag half-range [1/s] |
| parameter | tau_eps | Real | = 1.0 | Smooth transition width for asymmetric lag [rad/s] |
| parameter | omega_cmd_max | Real | = 1600 | Maximum commanded motor speed [rad/s] |
| parameter | omega_cmd_eps | Real | = 20 | Smooth command saturation width [rad/s] |
| input | omega_cmd | Real | (start = 0) | Commanded speed [rad/s] |
| output | omega | Real | (start = 0, fixed = true) | Actual speed [rad/s] |
| output | thrust | Real | | Motor thrust [N] |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
model Motor
parameter Real Ct = 8.54858e-6 "Thrust coefficient [N/(rad/s)^2]";
parameter Real tau_up = 0.0125 "Motor spin-up time constant [s]";
parameter Real tau_down = 0.025 "Motor spin-down time constant [s]";
parameter Real tau_inv_mid = 0.5 * (1.0 / tau_up + 1.0 / tau_down) "Mean inverse motor lag [1/s]";
parameter Real tau_inv_delta = 0.5 * (1.0 / tau_up - 1.0 / tau_down) "Signed inverse motor lag half-range [1/s]";
parameter Real tau_eps = 1.0 "Smooth transition width for asymmetric lag [rad/s]";
parameter Real omega_cmd_max = 1600 "Maximum commanded motor speed [rad/s]";
parameter Real omega_cmd_eps = 20 "Smooth command saturation width [rad/s]";
input Real omega_cmd(start = 0) "Commanded speed [rad/s]";
output Real omega(start = 0, fixed = true) "Actual speed [rad/s]";
output Real thrust "Motor thrust [N]";
protected
Real omega_error "Motor speed tracking error [rad/s]";
Real omega_cmd_nonnegative "Command after smooth lower limit [rad/s]";
Real omega_cmd_upper_margin "Distance from the smooth lower-limited command to the upper command limit [rad/s]";
Real omega_cmd_limited "Command after smooth lower and upper limits [rad/s]";
Real lag_blend "Smooth lag blend";
Real tau_inv "Smooth inverse lag [1/s]";
equation
omega_cmd_nonnegative = 0.5 * (omega_cmd + sqrt(omega_cmd * omega_cmd + omega_cmd_eps * omega_cmd_eps));
omega_cmd_upper_margin = omega_cmd_max - omega_cmd_nonnegative;
omega_cmd_limited = omega_cmd_max - 0.5 * (omega_cmd_upper_margin + sqrt(omega_cmd_upper_margin * omega_cmd_upper_margin + omega_cmd_eps * omega_cmd_eps));
omega_error = omega_cmd_limited - omega;
lag_blend = omega_error / sqrt(omega_error * omega_error + tau_eps * tau_eps);
tau_inv = tau_inv_mid + tau_inv_delta * lag_blend;
der(omega) = tau_inv * omega_error;
thrust = Ct * omega * omega;
end Motor;