Files
AIDASimulation/SimulationModels/OpenModelica 1.11/Requirements/StabilityRequirement.mo

103 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
within Requirements;
model StabilityRequirement
"SR-WIND-02: The UAS shall maintain lateral and yaw stability under wind disturbance and recover within limits"
// ---- System-level parameters (traceable to SR-WIND-02) ----
parameter Real hoverTolerance = 2.5
"Maximum allowed lateral deviation during hover [m]";
parameter Real yawTolerance = 5
"Maximum allowed yaw error [deg]";
parameter Real recoveryBand = 0.5
"Position error band for recovery after disturbance [m]";
parameter Real recoveryTime = 3
"Time to remain within recovery band [s]";
// ---- Inputs from the system ----
Modelica.Blocks.Interfaces.RealInput posX
"Measured X position [m]" annotation(
Placement(transformation(extent={{120,40},{80,80}})));
Modelica.Blocks.Interfaces.RealInput posY
"Measured Y position [m]" annotation(
Placement(transformation(extent={{120,-80},{80,-40}})));
Modelica.Blocks.Interfaces.RealInput yaw
"Measured yaw angle [deg]" annotation(
Placement(transformation(extent={{120,-10},{80,30}})));
Modelica.Blocks.Interfaces.RealInput DronePositionConsign[3]
"Commanded reference position [m]" annotation(
Placement(transformation(extent={{-20,120},{20,80}}, rotation=-90)));
Modelica.Blocks.Interfaces.RealInput yawConsign
"Commanded yaw angle [deg]" annotation(
Placement(transformation(extent={{-60,120},{-20,80}}, rotation=-90)));
// ---- Outputs for monitoring ----
Modelica.Blocks.Interfaces.RealOutput lateralError
"2D lateral position error magnitude [m]" annotation(
Placement(transformation(extent={{-90,50},{-110,70}})));
Modelica.Blocks.Interfaces.RealOutput yawError
"Yaw error magnitude [deg]" annotation(
Placement(transformation(extent={{-90,20},{-110,40}})));
Modelica.Blocks.Interfaces.BooleanOutput withinHoverLimit
"true if lateralError < hoverTolerance" annotation(
Placement(visible = true, transformation(extent = {{-110, -10}, {-90, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.BooleanOutput withinYawLimit
"true if yawError < yawTolerance" annotation(
Placement(visible = true, transformation(extent = {{-110, -40}, {-90, -20}}, rotation = 0), iconTransformation(origin = {-100, -30}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.BooleanOutput recovered
"true if position remains within recoveryBand for recoveryTime" annotation(
Placement(visible = true, transformation(extent = {{-110, -70}, {-90, -50}}, rotation = 0), iconTransformation(origin = {-100, -60}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.BooleanOutput pass
"true if all criteria are satisfied" annotation(
Placement(visible = true, transformation(extent = {{-110, -100}, {-90, -80}}, rotation = 0), iconTransformation(origin = {-100, -90}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
protected
Real t_within(start=0) "Timer for recovery criterion";
equation
// --- Lateral and yaw errors ---
lateralError = sqrt((posX - DronePositionConsign[1])^2 +
(posY - DronePositionConsign[2])^2);
yawError = abs(yaw - yawConsign);
withinHoverLimit = lateralError < hoverTolerance;
withinYawLimit = yawError < yawTolerance;
// --- Recovery logic (after gust disturbance) ---
der(t_within) = if lateralError < recoveryBand then 1 else 0;
// Reset timer whenever the drone leaves the recovery band
when lateralError > recoveryBand then
reinit(t_within, 0);
end when;
recovered = t_within >= recoveryTime;
// --- Overall requirement pass flag ---
//pass = withinHoverLimit and withinYawLimit and recovered;
pass = withinHoverLimit and withinYawLimit;
annotation(
Documentation(info="
<html>
<h4>SR-WIND-02 Performance in Wind</h4>
<p>
Source: EASA Means of Compliance Light-UAS.2512,
ISO 21384-3 (Clause 10 Operational limitations).
</p>
<p>
<b>Requirement:</b><br>
Under a steady 8 m/s wind with 12 m/s gusts, the UAS shall:
<ul>
<li>Maintain lateral position error ≤ 1.5 m (95th percentile) during hover.</li>
<li>Maintain yaw pointing error ≤ 5° (95th percentile).</li>
<li>Recover to within 0.5 m position error within 3 s after gust disturbance.</li>
</ul>
</p>
<p>
<b>Simulation Inputs:</b> Connect to AIDA_System position, yaw, and
reference signals.
</p>
</html>"),
uses(Modelica(version="3.2.2")),
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "SR-WIND-02"), Rectangle(extent = {{-104, -2}, {-104, -2}}), Rectangle(origin = {0, -1}, extent = {{-100, 101}, {100, -99}})}, coordinateSystem(initialScale = 0.1)));
end StabilityRequirement;