function
Tests.ManualGuidanceTests.rampStop
Release one reference axis from the commanded speed and follow it to rest
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | useSquareRootRamp | Boolean | | False selects the proportional law the ramp replaces |
| input | samplePeriod | Real | (unit = "s") | |
| input | steps | Integer | | |
| output | excursion | Real | | Most negative speed reached |
| output | residual | Real | | Speed left at the end of the run |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function rampStop
"Release one reference axis from the commanded speed and follow it to rest"
input Boolean useSquareRootRamp
"False selects the proportional law the ramp replaces";
input Real samplePeriod(unit = "s");
input Integer steps;
output Real excursion "Most negative speed reached";
output Real residual "Speed left at the end of the run";
protected
constant Real releaseSpeed = 5.0;
constant Real accelerationLimit = 3.0;
constant Real jerkLimit = 8.0;
Real speed;
Real acceleration;
Real target;
Real step;
algorithm
// One axis of the reference twist, released from the commanded speed with
// the same acceleration and jerk bounds the manual source uses.
speed := releaseSpeed;
acceleration := 0.0;
excursion := speed;
for index in 1:steps loop
target := if useSquareRootRamp then
MathUtilities.clip(
MathUtilities.squareRootRamp(
-speed, 1.0 / samplePeriod, jerkLimit),
-accelerationLimit, accelerationLimit)
else
MathUtilities.clip(
-speed / samplePeriod, -accelerationLimit, accelerationLimit);
step := MathUtilities.clip(
target - acceleration,
-jerkLimit * samplePeriod, jerkLimit * samplePeriod);
acceleration := acceleration + step;
speed := speed + acceleration * samplePeriod;
excursion := min(excursion, speed);
end for;
residual := abs(speed);
end rampStop;