model
Vehicles.Cubs2.Test.Scenarios.PatternMission
Base classes
Vehicles.Cubs2.ClosedLoopVehicle
Follow base classes for inherited declarations; this page lists explicit declarations only.
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| parameter | patternRoute | Components.RouteParameters | = Components.RouteParameters(
cruiseSpeed = 4.0,
waypointSwitchingDistance = 3.0,
waypoints = [
0.0, 0.0, 3.0;
12.0, 0.0, 3.0;
30.0, 0.0, 3.0;
30.0, 20.0, 3.0;
0.0, 20.0, 3.0;
0.0, 0.0, 3.0;
12.0, 0.0, 3.0]) | |
| output | lapCount | Integer | (start = 0, fixed = true) | |
| output | landing | Boolean | (start = false, fixed = true) | |
| output | missionPhase | Integer | |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
model PatternMission
parameter Components.RouteParameters patternRoute = Components.RouteParameters(
cruiseSpeed = 4.0,
waypointSwitchingDistance = 3.0,
waypoints = [
0.0, 0.0, 3.0;
12.0, 0.0, 3.0;
30.0, 0.0, 3.0;
30.0, 20.0, 3.0;
0.0, 20.0, 3.0;
0.0, 0.0, 3.0;
12.0, 0.0, 3.0]);
extends Vehicles.Cubs2.ClosedLoopVehicle(
route = patternRoute,
initialPosition_m = {0.0, 0.0, 3.0},
initialVelocityBody_m_s = {4.0, 0.0, 0.0},
engaged = true,
armed = not (landing and position_m[3] < 0.4),
stickOverrideActive = landing,
stickOverride = {0.0, -0.25, 0.0, 0.12});
discrete output Integer lapCount(start = 0, fixed = true);
discrete output Boolean landing(start = false, fixed = true);
output Integer missionPhase;
protected
discrete Integer previousWaypoint(start = 1, fixed = true);
algorithm
when sample(0.0, 0.02) then
if not pre(landing) and position_m[3] > 2.0
and pre(previousWaypoint) == 6 and currentWaypoint == 1 then
lapCount := pre(lapCount) + 1;
else
lapCount := pre(lapCount);
end if;
previousWaypoint := currentWaypoint;
landing := pre(landing) or lapCount >= 2;
end when;
equation
if landing then
missionPhase = 3;
elseif position_m[3] > 0.4 then
missionPhase = 2;
else
missionPhase = 1;
end if;
end PatternMission;