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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Heyden
LabProcesses.jl
Commits
d5e320c6
Commit
d5e320c6
authored
7 years ago
by
Martin Karlsson
Browse files
Options
Downloads
Patches
Plain Diff
Implement ethheli
parent
0047c953
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interface_implementations/eth_helicopter.jl
+44
-0
44 additions, 0 deletions
src/interface_implementations/eth_helicopter.jl
with
44 additions
and
0 deletions
src/interface_implementations/eth_helicopter.jl
0 → 100644
+
44
−
0
View file @
d5e320c6
# Interface implementation Ball And Beam ====================================================
export
ETHHelicopter
,
ETHHelicopterSimulator
,
ETHHelicopterType
struct
ETHHelicopter
<:
PhysicalProcess
h
::
Float64
end
ETHHelicopter
()
=
ETHHelicopter
(
0.050
)
struct
ETHHelicopterSimulator
<:
SimulatedProcess
h
::
Float64
state
::
Vector
{
Float64
}
end
ETHHelicopterSimulator
()
=
ETHHelicopterSimulator
(
0.01
,
zeros
(
4
))
const
ETHHelicopterType
=
Union
{
ETHHelicopter
,
ETHHelicopterSimulator
}
num_outputs
(
p
::
ETHHelicopterType
)
=
2
num_inputs
(
p
::
ETHHelicopterType
)
=
2
outputrange
(
p
::
ETHHelicopterType
)
=
[(
-
10
,
10
),(
-
10
,
10
)]
# Beam angle, Ball position
inputrange
(
p
::
ETHHelicopterType
)
=
[(
-
10
,
10
)]
isstable
(
p
::
ETHHelicopterType
)
=
false
isasstable
(
p
::
ETHHelicopterType
)
=
false
sampletime
(
p
::
ETHHelicopterType
)
=
p
.
h
function
control
(
p
::
ETHHelicopter
,
u
)
ccall
((
:
comedi_write
,
comedipath
),
Int32
,(
Int32
,
Int32
,
Int32
,
Int32
),
0
,
1
,
0
,
num2io
(
u
[
1
]))
ccall
((
:
comedi_write
,
comedipath
),
Int32
,(
Int32
,
Int32
,
Int32
,
Int32
),
0
,
1
,
1
,
num2io
(
u
[
2
]))
end
measure
(
p
::
ETHHelicopter
)
=
[
io2num
(
ccall
((
:
comedi_read
,
comedipath
),
Int32
,(
Int32
,
Int32
,
Int32
),
0
,
0
,
i
))
for
i
=
0
:
1
]
#i=0 for pitch, i=1 for yaw
control
(
p
::
ETHHelicopterSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
ETHHelicopterSimulator
)
=
error
(
"Not yet implemented"
)
const
comedipath
=
Pkg
.
dir
(
"LabProcesses"
,
"c"
,
"comedi_bridge.so"
)
const
conversion
=
65535
/
20
io2num
(
x
)
=
x
/
conversion
-
10
# Converts from io to float
num2io
(
x
)
=
round
(
Int32
,(
x
+
10
)
*
conversion
)
# Converts from regular number to io
initialize
(
p
::
ETHHelicopter
)
=
ccall
((
:
comedi_start
,
comedipath
),
Int32
,(
Int32
,),
0
)
finalize
(
p
::
ETHHelicopter
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
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