Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
draisine
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
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
POWVER
draisine
Commits
e9921b7c
Commit
e9921b7c
authored
7 years ago
by
Felix Freiberger
Browse files
Options
Downloads
Plain Diff
Merge branch 'saved' of
ssh://liebe.cs.uni-saarland.de:2222/powver/draisine
into saved
parents
072a9157
03b45091
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Added SAVED integration.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
draiscontrol/control.py
+12
-4
12 additions, 4 deletions
draiscontrol/control.py
with
12 additions
and
4 deletions
draiscontrol/control.py
+
12
−
4
View file @
e9921b7c
...
...
@@ -124,13 +124,19 @@ class Control(object):
sys
.
stdout
.
flush
()
def
accelerationToByte
(
self
,
a
):
a
/=
self
.
accG
# convert back to g-force
a
*=
16384.0
# convert back to raw 16-bit word
a
/=
self
.
accG
# convert back to g-force
a
*=
16384.0
# convert back to raw 16-bit word
a
+=
(
2
**
15
)
# shift value to nonnegative range
a
=
int
(
a
/
(
2
**
8
))
# truncate to byte
a
=
min
(
max
(
a
,
0
),
2
**
8
-
1
)
# enforce range
return
a
def
speedToByte
(
self
,
s
):
s
*=
25
# stretch to reasonable range
s
=
int
(
s
)
# truncate to byte
s
=
min
(
max
(
s
,
0
),
2
**
8
-
1
)
# enforce range
return
s
def
savedloop
(
self
,
human
=
False
):
# old duty signal
# |
...
...
@@ -141,11 +147,13 @@ class Control(object):
while
True
:
self
.
refreshSensors
()
a
=
self
.
accY
.
read
(
t
)
s
=
self
.
hallSpeed
.
read
(
t
)
d
=
0.75
# TODO
b
=
max
(
0
,
min
(
254
,
int
(
254
*
d
)))
if
human
:
print
'
accY = {v}
'
.
format
(
v
=
self
.
accelerationToByte
(
a
))
print
'
duty = {d}
'
.
format
(
d
=
b
)
print
'
accY = {v}
'
.
format
(
v
=
self
.
accelerationToByte
(
a
))
print
'
speed = {s}
'
.
format
(
s
=
self
.
speedToByte
(
s
))
print
'
duty = {d}
'
.
format
(
d
=
b
)
else
:
dutycmd
=
array
.
array
(
'
B
'
,
[
b
])
self
.
logDuty
(
dutycmd
)
...
...
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