CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

block

Vehicles.Rdd2.CommandMapping

Map pilot input into rate, attitude, and thrust demands

Public declarations

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

RoleNameTypeDimensions / attributes / defaultDescription
parametersamplePeriodReal(unit="s") = 0.001
parametermaxRollPitchRateRadSReal(unit="rad/s") = 6.0
parametermaxYawRateRadSReal(unit="rad/s") = 3.5
parametermaxAutoLevelTiltRadReal(unit="rad") = 0.61086524

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

block CommandMapping "Map pilot input into rate, attitude, and thrust demands"
  import Interfaces = Vehicles.Rdd2.ControllerInterfaces;

  parameter Real samplePeriod(unit="s") = 0.001;
  parameter Real maxRollPitchRateRadS(unit="rad/s") = 6.0;
  parameter Real maxYawRateRadS(unit="rad/s") = 3.5;
  parameter Real maxAutoLevelTiltRad(unit="rad") = 0.61086524;

  Interfaces.PilotInput pilot;
  Interfaces.PilotCommands commands;

protected
  discrete Real normalizedStick[3](each start = 0.0)
    "Normalized {roll, pitch, yaw} stick position";

algorithm
  when sample(0.0, samplePeriod) then
    normalizedStick := MathUtilities.clipVector(pilot.stick, -1.0, 1.0);
    commands.throttleInput := MathUtilities.clip(pilot.throttle, 0.0, 1.0);

    commands.acroRateDesired_rad_s :=
      {maxRollPitchRateRadS, maxRollPitchRateRadS, maxYawRateRadS}
      .* normalizedStick;
    commands.attitudeTiltDesired_rad :=
      maxAutoLevelTiltRad * normalizedStick[1:2];
  end when;
end CommandMapping;