Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
BallAndBeam.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
processes
BallAndBeam.jl
Commits
b2ed01c6
There was a problem fetching the pipeline summary.
Commit
b2ed01c6
authored
7 years ago
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Verified to work on BeamSimulator
parent
8bf75d40
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BallAndBeam.jl
+4
-6
4 additions, 6 deletions
src/BallAndBeam.jl
src/FRTN35_lab1.jl
+8
-8
8 additions, 8 deletions
src/FRTN35_lab1.jl
with
12 additions
and
14 deletions
src/BallAndBeam.jl
+
4
−
6
View file @
b2ed01c6
...
...
@@ -26,21 +26,21 @@ using LabProcesses, Plots, Polynomials, ControlSystems, ProgressMeter
run_experiment(P::AbstractBeam, ω, duration, settling_time, amplitude, bias)
Perform fra-experiemnt For a single frequency `ω`. Called from inside `fra`
"""
function
run_experiment
(
P
::
AbstractBeam
,
ω
,
duration
,
settling_time
,
amplitude
,
bias
)
function
run_experiment
(
P
::
AbstractBeam
,
ω
,
duration
,
settling_time
,
amplitude
)
h
=
sampletime
(
P
)
data
=
zeros
(
0
:
h
:
duration
)
LabProcesses
.
initialize
(
P
)
for
t
=
0
:
h
:
settling_time
@periodically
h
begin
u
=
amplitude
*
sin
(
ω
*
t
)
control
(
P
,
u
+
bias
)
control
(
P
,
u
+
bias
(
P
)
)
end
end
for
(
i
,
t
)
=
enumerate
(
0
:
h
:
duration
)
@periodically
h
begin
data
[
i
]
=
measure
(
P
)
u
=
amplitude
*
sin
(
ω
*
t
)
control
(
P
,
u
)
control
(
P
,
u
+
bias
(
P
)
)
end
end
LabProcesses
.
finalize
(
P
)
...
...
@@ -58,13 +58,11 @@ integrate(fun,data,ω,h) = h*sum(fun(ω*(i-1)*h).*data[i] for i = 1:length(data)
fra(Ω::AbstractVector; kwargs...)
# Arguments
- `bias = 0`: Change the bias if the beam angle is drifting over time
- `settling_time = 2`: In seconds, rounded up to closest integer periods
- `nbr_of_periods = 10`:
- `amplitude = 1`: Very low freqs might require smaller amplitude
"""
function
fra
(
P
::
AbstractBeam
,
Ω
::
AbstractVector
;
bias
=
0
,
settling_time
=
2
,
nbr_of_periods
=
10
,
amplitude
=
1
)
...
...
@@ -75,7 +73,7 @@ function fra(P::AbstractBeam, Ω::AbstractVector;
T
=
2
π
/
ω
# Period time
settling_time_i
=
ceil
(
settling_time
/
T
)
*
T
# Settling time even number of periods
duration
=
nbr_of_periods
*
T
data
=
run_experiment
(
P
,
ω
,
duration
,
settling_time_i
,
amplitude
,
bias
)
data
=
run_experiment
(
P
,
ω
,
duration
,
settling_time_i
,
amplitude
)
sin_channel
=
integrate
(
sin
,
data
,
ω
,
h
)
cos_channel
=
integrate
(
cos
,
data
,
ω
,
h
)
G
[
i
]
=
2
/
(
amplitude
*
duration
)
*
Complex
(
sin_channel
,
cos_channel
)
...
...
This diff is collapsed.
Click to expand it.
src/FRTN35_lab1.jl
+
8
−
8
View file @
b2ed01c6
using
BallAndBeam
,
LabProcesses
,
ControlSystems
,
JLD
using
BallAndBeam
,
ControlSystems
,
JLD
,
LabProcesses
# @load "workspace.jld" # Run this command to restore a saved workspace
bias
=
0.01
# Change this if your process drifts over time
P
=
LabProcesses
.
Beam
(
0.01
,
bias
)
P
=
LabProcesses
.
Beam
(
0.01
)
# Replace for BeamSimulator to run simulations
h
=
sampletime
(
P
)
settling_time
=
1
nbr_of_periods
=
5
nbr_of_periods
=
3
# Below we define some frequency vectors (using logarithmic spacing)
# and run three experiments. You may modify the freqency vectors
# any way you want and add/remove experiments as needed.
w1_100
=
logspace
(
log10
(
1
),
log10
(
300
),
8
)
G1
=
fra
(
P
,
w1_100
,
amplitude
=
1
,
bias
=
bias
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
G1
=
fra
(
P
,
w1_100
,
amplitude
=
1
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
@save
"workspace.jld"
w1_200
=
logspace
(
log10
(
5
),
log10
(
50
),
20
)
G2
=
fra
(
P
,
w1_200
,
amplitude
=
2
,
bias
=
bias
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
G2
=
fra
(
P
,
w1_200
,
amplitude
=
2
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
@save
"workspace.jld"
w1_300
=
logspace
(
log10
(
10
),
log10
(
30
),
20
)
G3
=
fra
(
P
,
w1_300
,
amplitude
=
2
,
bias
=
bias
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
G3
=
fra
(
P
,
w1_300
,
amplitude
=
2
,
nbr_of_periods
=
nbr_of_periods
,
settling_time
=
settling_time
)
@save
"workspace.jld"
# Concatenate (overlapping) estimates to be used and sort based on freq
G123
=
sortfqs
([
G1
;
G2
;
G3
])
bopl
(
G123
,
m
=:
star
)
nypl
(
G123
)
nypl
(
G123
,
m
=:
star
)
## Control ==================================================================================
polevect
=
[
-
10
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment