CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

model

SLAM.Examples.Vehicles.QuadrotorSIL.Motor

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
parameterCtReal= 8.54858e-6Thrust coefficient [N/(rad/s)^2]
parametertau_upReal= 0.0125Motor spin-up time constant [s]
parametertau_downReal= 0.025Motor spin-down time constant [s]
parametertau_inv_midReal= 0.5 * (1.0 / tau_up + 1.0 / tau_down)Mean inverse motor lag [1/s]
parametertau_inv_deltaReal= 0.5 * (1.0 / tau_up - 1.0 / tau_down)Signed inverse motor lag half-range [1/s]
parametertau_epsReal= 1.0Smooth transition width for asymmetric lag [rad/s]
parameteromega_cmd_maxReal= 1600Maximum commanded motor speed [rad/s]
parameteromega_cmd_epsReal= 20Smooth command saturation width [rad/s]
inputomega_cmdReal(start = 0)Commanded speed [rad/s]
outputomegaReal(start = 0, fixed = true)Actual speed [rad/s]
outputthrustRealMotor 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;