Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Science Festival 2015
EV3WebController
Commits
6b93e7c0
Unverified
Commit
6b93e7c0
authored
Nov 09, 2015
by
Cédric Bonhomme
Browse files
fine tune
parent
9799c723
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/__init__.py
View file @
6b93e7c0
...
...
@@ -41,10 +41,11 @@ try:
ir_sensor
=
InfraredSensor
()
color_sensor
=
ColorSensor
()
except
Exception
as
e
:
print
e
pass
#raise Exception('You must run the application on the EV3.')
raise
e
right_wheel
.
position
=
0
left_wheel
.
position
=
0
right_wheel
.
stop
()
left_wheel
.
stop
()
from
web
import
views
web/views/views.py
View file @
6b93e7c0
...
...
@@ -41,7 +41,7 @@ def authentication_required(e):
@
app
.
route
(
'/move/<direction>'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/move/<direction>/<speed>'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/move/<direction>/<
int:
speed>'
,
methods
=
[
'GET'
])
@
to_response
def
move
(
direction
=
"forward"
,
speed
=
800
):
"""
...
...
@@ -62,8 +62,8 @@ def move(direction="forward", speed=800):
result
[
"message"
]
=
movements
.
run_position_limited
(
left_wheel
,
right_wheel
,
position
)
else
:
left_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
Fals
e
)
right_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
Fals
e
)
left_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
Tru
e
)
right_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
Tru
e
)
elif
direction
==
'backward'
:
nb_blocks
=
request
.
args
.
get
(
"blocks"
,
None
)
...
...
@@ -72,6 +72,7 @@ def move(direction="forward", speed=800):
result
[
"message"
]
=
movements
.
run_position_limited
(
left_wheel
,
right_wheel
,
position
)
else
:
print
(
speed
)
left_wheel
.
run_forever
(
speed
*
1
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
*
1
,
regulation_mode
=
False
)
...
...
@@ -79,7 +80,7 @@ def move(direction="forward", speed=800):
speed
=
600
forever
=
request
.
args
.
get
(
"forever"
,
None
)
if
None
is
forever
:
movements
.
rotate
(
left_wheel
,
right_wheel
,
-
3
0
0
,
3
0
0
,
90
,
0
)
movements
.
rotate
(
left_wheel
,
right_wheel
,
-
3
1
0
,
3
1
0
,
90
,
0
)
else
:
left_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
,
regulation_mode
=
False
)
...
...
@@ -88,7 +89,7 @@ def move(direction="forward", speed=800):
speed
=
600
forever
=
request
.
args
.
get
(
"forever"
,
None
)
if
None
is
forever
:
movements
.
rotate
(
left_wheel
,
right_wheel
,
3
0
0
,
-
3
0
0
,
0
,
90
)
movements
.
rotate
(
left_wheel
,
right_wheel
,
3
1
0
,
-
3
1
0
,
0
,
90
)
else
:
left_wheel
.
run_forever
(
speed
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
False
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment