Skip to content

Commit 9303312

Browse files
committed
Move get_startup into the package
1 parent b039efa commit 9303312

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

docs/src/functions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ CurrentModule = WinchControllers
77
@limit
88
saturate
99
merge_angles
10+
get_startup
1011
```

src/WinchControllers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ abstract type AbstractForceController end
1818
const AFC = AbstractForceController
1919

2020
# Write your package code here.
21+
include("wc_settings.jl")
2122
include("utils.jl")
2223
include("components.jl")
23-
include("wc_settings.jl")
2424
include("wc_components.jl")
2525
include("winchcontroller.jl")
2626

src/utils.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Functions:
77
- limit
88
- merge_angles
99
- moving_average
10+
- get_startup
1011
1112
Implemented as described in the PhD thesis of Uwe Fechner.
1213
"""
@@ -88,4 +89,35 @@ function moving_average(data, window)
8889
result = mean(data[length(data)-window:end])
8990
end
9091
result
92+
end
93+
94+
95+
"""
96+
get_startup(wcs::WCSettings, samples)
97+
98+
Create a signal, that is rising with wcs.t_startup from zero to one and then stays constant.
99+
100+
## Parameters:
101+
- wcs: the winch controller settings
102+
- samples: the number of samples to create
103+
104+
## Returns:
105+
- a vector of length `samples` with the startup signal
106+
"""
107+
function get_startup(wcs::WCSettings, samples)
108+
result = zeros(samples)
109+
startup = 0.0
110+
rising = true
111+
delta = wcs.dt/wcs.t_startup
112+
for i in 1:samples
113+
result[i] = startup
114+
if rising
115+
startup += delta
116+
end
117+
if startup >= 1.0
118+
startup = 1.0
119+
rising = false
120+
end
121+
end
122+
result
91123
end

test/test_utilities.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
# Create a signal, that is rising with wcs.t_startup from zero to one and then stays constant.
2-
function get_startup(wcs::WCSettings, samples)
3-
result = zeros(samples)
4-
startup = 0.0
5-
rising = true
6-
delta = wcs.dt/wcs.t_startup
7-
for i in 1:samples
8-
result[i] = startup
9-
if rising
10-
startup += delta
11-
end
12-
if startup >= 1.0
13-
startup = 1.0
14-
rising = false
15-
end
16-
end
17-
result
18-
end
19-
201
# Create a wind signal in triangle form, using the constants V_WIND_MIN and V_WIND_MAX with
212
# the frequency FREQ_WIND.
223
function get_triangle_wind(wcs::WCSettings)

0 commit comments

Comments
 (0)