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.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| parameter | samplePeriod | Real | (unit="s") = 0.001 | |
| parameter | maxRollPitchRateRadS | Real | (unit="rad/s") = 6.0 | |
| parameter | maxYawRateRadS | Real | (unit="rad/s") = 3.5 | |
| parameter | maxAutoLevelTiltRad | Real | (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;