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
Martin Heyden
LabProcesses.jl
Commits
aadb545e
Commit
aadb545e
authored
7 years ago
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Implement beam
parent
41e269d1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/controllers.jl
+2
-2
2 additions, 2 deletions
src/controllers.jl
src/interface_implementations/ballandbeam.jl
+33
-11
33 additions, 11 deletions
src/interface_implementations/ballandbeam.jl
with
35 additions
and
13 deletions
src/controllers.jl
+
2
−
2
View file @
aadb545e
...
...
@@ -36,9 +36,9 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
y
[
:
,
i
]
=
measure
(
P
)
r
[
:
,
i
]
=
reference
(
t
)
u
[
:
,
i
]
=
calc_control
(
i
)
# y,r must be updated before u
control
(
P
,
[
clamp
.
(
u
[
j
,
i
],
input
_
range
(
P
)[
j
]
...
)
for
j
=
1
:
nu
])
control
(
P
,
[
clamp
.
(
u
[
j
,
i
],
inputrange
(
P
)[
j
]
...
)
for
j
=
1
:
nu
])
end
end
finalize
(
P
)
y
,
u
,
r
y
'
,
u
'
,
r
'
end
This diff is collapsed.
Click to expand it.
src/interface_implementations/ballandbeam.jl
+
33
−
11
View file @
aadb545e
# Interface implementation Ball And Beam ====================================================
export
BallAndBeam
,
BallAndBeamSimulator
,
BallAndBeamType
export
Beam
,
BeamSimulator
,
BeamType
,
BallAndBeam
,
BallAndBeamSimulator
,
BeamOrBallAndBeam
struct
Beam
<:
PhysicalProcess
h
::
Float64
bias
::
Float64
end
Beam
()
=
Beam
(
0.01
,
0.0
)
struct
BeamSimulator
<:
SimulatedProcess
h
::
Float64
state
::
Vector
{
Float64
}
# angle,ω
end
BeamSimulator
()
=
BeamSimulator
(
0.01
,
zeros
(
2
))
struct
BallAndBeam
<:
PhysicalProcess
h
::
Float64
...
...
@@ -14,22 +26,32 @@ struct BallAndBeamSimulator <: SimulatedProcess
end
BallAndBeamSimulator
()
=
BallAndBeamSimulator
(
0.01
,
zeros
(
4
))
const
BeamType
=
Union
{
Beam
,
BeamSimulator
}
const
BallAndBeamType
=
Union
{
BallAndBeam
,
BallAndBeamSimulator
}
const
BeamOrBallAndBeam
=
Union
{
BeamType
,
BallAndBeamType
}
num_outputs
(
p
::
BeamType
)
=
1
num_outputs
(
p
::
BallAndBeamType
)
=
2
num_inputs
(
p
::
BallAndBeamType
)
=
1
num_inputs
(
p
::
BeamOrBallAndBeam
)
=
1
outputrange
(
p
::
Beam
)
=
[(
-
10
,
10
)]
outputrange
(
p
::
BallAndBeamType
)
=
[(
-
10
,
10
),(
-
1
,
1
)]
# Beam angle, Ball position
inputrange
(
p
::
BallAndBeamType
)
=
[(
-
10
,
10
)]
inputrange
(
p
::
BeamOrBallAndBeam
)
=
[(
-
10
,
10
)]
isstable
(
p
::
Beam
)
=
true
isstable
(
p
::
BallAndBeamType
)
=
false
isasstable
(
p
::
BallAndBeam
Type
)
=
false
sampletime
(
p
::
BallAndBeam
Type
)
=
p
.
h
bias
(
p
::
BallAndBeam
)
=
p
.
bias
isasstable
(
p
::
BeamOr
BallAndBeam
)
=
false
sampletime
(
p
::
BeamOr
BallAndBeam
)
=
p
.
h
bias
(
p
::
BeamOr
BallAndBeam
)
=
p
.
bias
bias
(
p
::
BallAndBeamSimulator
)
=
0
control
(
p
::
BallAndBeam
,
u
)
=
ccall
((
:
comedi_write
,
comedipath
),
Int32
,
control
(
p
::
BeamOr
BallAndBeam
,
u
)
=
ccall
((
:
comedi_write
,
comedipath
),
Int32
,
(
Int32
,
Int32
,
Int32
,
Int32
),
0
,
1
,
1
,
num2io
(
u
[
1
]
+
p
.
bias
))
measure
(
p
::
B
allAndBeam
)
=
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
measure
(
p
::
B
eam
)
=
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
(
Int32
,
Int32
,
Int32
),
0
,
0
,
0
))
measure
(
p
::
BallAndBeam
)
=
[
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,
(
Int32
,
Int32
,
Int32
),
0
,
0
,
i
))
for
i
=
0
:
1
]
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
BallAndBeamSimulator
)
=
[
p
.
state
[
1
],
p
.
state
[
3
]]
...
...
@@ -39,7 +61,7 @@ const conversion = 65535/20
io2num
(
x
)
=
x
/
conversion
-
10
# Converts from io to float
num2io
(
x
)
=
round
(
Int32
,
x
*
100
+
2048
)
# Converts from regular number to io
initialize
(
p
::
BallAndBeam
)
=
ccall
((
:
comedi_start
,
comedipath
),
Int32
,(
Int32
,),
0
)
finalize
(
p
::
BallAndBeam
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
initialize
(
p
::
BeamOr
BallAndBeam
)
=
ccall
((
:
comedi_start
,
comedipath
),
Int32
,(
Int32
,),
0
)
finalize
(
p
::
BeamOr
BallAndBeam
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
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