Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabProcesses.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
LabProcesses.jl
Commits
5dbfdbe8
Commit
5dbfdbe8
authored
7 years ago
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Update initialize, finalize and constructors
parent
2bde548e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/interface_implementations/ballandbeam.jl
+37
-17
37 additions, 17 deletions
src/interface_implementations/ballandbeam.jl
src/interface_implementations/eth_helicopter.jl
+22
-13
22 additions, 13 deletions
src/interface_implementations/eth_helicopter.jl
with
59 additions
and
30 deletions
src/interface_implementations/ballandbeam.jl
+
37
−
17
View file @
5dbfdbe8
...
...
@@ -24,12 +24,22 @@ Physical beam process
- `measure::AnalogInput10V = AnalogInput10V(0)`
- `control::AnalogOutput10V = AnalogOutput10V(1)`
"""
@with_kw
struct
Beam
<:
PhysicalProcess
h
::
Float64
=
0.01
bias
::
Float64
=
0.0
stream
::
LabStream
=
ComediStream
()
measure
::
AnalogInput10V
=
AnalogInput10V
(
0
)
control
::
AnalogOutput10V
=
AnalogOutput10V
(
1
)
struct
Beam
<:
PhysicalProcess
h
::
Float64
bias
::
Float64
stream
::
LabStream
measure
::
AnalogInput10V
control
::
AnalogOutput10V
end
function
Beam
(;
h
::
Float64
=
0.01
,
bias
::
Float64
=
0.
,
stream
::
LabStream
=
ComediStream
(),
measure
::
AnalogInput10V
=
AnalogInput10V
(
0
),
control
::
AnalogOutput10V
=
AnalogOutput10V
(
1
))
p
=
new
(
Float64
(
h
),
Float64
(
bias
),
stream
,
measure
,
control
)
init_devices!
(
p
.
stream
,
p
.
measure
,
p
.
control
)
p
end
include
(
"define_beam_system.jl"
)
...
...
@@ -41,13 +51,24 @@ struct BeamSimulator <: SimulatedProcess
BeamSimulator
(;
h
::
Real
=
0.01
)
=
new
(
Float64
(
h
),
SysFilter
(
beam_system
,
h
))
end
@with_kw
struct
BallAndBeam
<:
PhysicalProcess
h
::
Float64
=
0.01
bias
::
Float64
=
0.0
stream
::
LabStream
=
ComediStream
()
measure1
::
AnalogInput10V
=
AnalogInput10V
(
0
)
measure2
::
AnalogInput10V
=
AnalogInput10V
(
1
)
control
::
AnalogOutput10V
=
AnalogOutput10V
(
0
)
struct
BallAndBeam
<:
PhysicalProcess
h
::
Float64
bias
::
Float64
stream
::
LabStream
measure1
::
AnalogInput10V
measure2
::
AnalogInput10V
control
::
AnalogOutput10V
end
function
BallAndBeam
(;
h
=
0.01
,
bias
=
0.
,
stream
=
ComediStream
(),
measure1
::
AnalogInput10V
=
AnalogInput10V
(
0
),
measure2
::
AnalogInput10V
=
AnalogInput10V
(
1
),
control
::
AnalogOutput10V
=
AnalogOutput10V
(
1
))
p
=
new
(
h
,
bias
,
stream
,
measure1
,
measure2
,
control
)
init_devices!
(
p
.
stream
,
p
.
measure1
,
p
.
measure2
,
p
.
control
)
p
end
struct
BallAndBeamSimulator
<:
SimulatedProcess
...
...
@@ -84,10 +105,9 @@ measure(p::BeamSimulator) = vecdot(p.s.sys.C,p.s.state)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
initialize
(
p
::
Beam
)
=
init_devices!
(
p
.
stream
,
p
.
measure
,
p
.
control
)
initialize
(
p
::
BallAndBeam
)
=
init_devices!
(
p
.
stream
,
p
.
measure1
,
p
.
measure2
,
p
.
control
)
finalize
(
p
::
AbstractBeamOrBallAndBeam
)
=
close
(
p
.
stream
)
initialize
(
p
::
Beam
)
=
nothing
initialize
(
p
::
BallAndBeam
)
=
nothing
finalize
(
p
::
AbstractBeamOrBallAndBeam
)
=
foreach
(
close
,
p
.
stream
.
devices
)
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
nothing
initialize
(
p
::
BeamSimulator
)
=
p
.
s
.
state
.*=
0
...
...
This diff is collapsed.
Click to expand it.
src/interface_implementations/eth_helicopter.jl
+
22
−
13
View file @
5dbfdbe8
...
...
@@ -22,13 +22,25 @@ export ETHHelicopter, ETHHelicopterSimulator, AbstractETHHelicopter
- `control2::AnalogOutput10V = AnalogOutput10V(1)`
"""
@with_kw
struct
ETHHelicopter
<:
PhysicalProcess
h
::
Float64
=
0.05
bias
::
Float64
=
0.0
stream
::
LabStream
=
ComediStream
()
measure1
::
AnalogInput10V
=
AnalogInput10V
(
0
)
measure2
::
AnalogInput10V
=
AnalogInput10V
(
1
)
control1
::
AnalogOutput10V
=
AnalogOutput10V
(
0
)
control2
::
AnalogOutput10V
=
AnalogOutput10V
(
1
)
h
::
Float64
bias
::
Float64
stream
::
LabStream
measure1
::
AnalogInput10V
measure2
::
AnalogInput10V
control1
::
AnalogOutput10V
control2
::
AnalogOutput10V
end
function
ETHHelicopter
(;
h
=
0.05
,
bias
=
0.
,
stream
=
ComediStream
(),
measure1
::
AnalogInput10V
=
AnalogInput10V
(
0
),
measure2
::
AnalogInput10V
=
AnalogInput10V
(
1
),
control1
::
AnalogOutput10V
=
AnalogOutput10V
(
0
),
control2
::
AnalogOutput10V
=
AnalogOutput10V
(
1
))
p
=
new
(
h
,
bias
,
stream
,
measure1
,
measure2
,
control1
,
control2
)
init_devices!
(
p
.
stream
,
p
.
measure1
,
p
.
measure2
,
p
.
control1
,
p
.
control2
)
p
end
...
...
@@ -55,15 +67,12 @@ function control(p::ETHHelicopter, u)
send
(
p
.
control2
,
u
[
2
])
end
measure
(
p
::
ETHHelicopter
)
=
[
read
(
p
.
measure1
),
read
(
p
.
measure2
)]
#i=0 for pitch, i=1 for yaw
measure
(
p
::
ETHHelicopter
)
=
[
read
(
p
.
measure1
),
read
(
p
.
measure2
)]
control
(
p
::
ETHHelicopterSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
ETHHelicopterSimulator
)
=
error
(
"Not yet implemented"
)
initialize
(
p
::
ETHHelicopter
)
=
init_devices!
(
p
.
stream
,
p
.
measure1
,
p
.
measure2
,
p
.
control1
,
p
.
control2
)
finalize
(
p
::
ETHHelicopter
)
=
close
(
p
.
stream
)
initialize
(
p
::
ETHHelicopter
)
=
nothing
finalize
(
p
::
ETHHelicopter
)
=
foreach
(
close
,
p
.
stream
.
devices
)
initialize
(
p
::
ETHHelicopterSimulator
)
=
nothing
finalize
(
p
::
ETHHelicopterSimulator
)
=
nothing
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