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
bae5bcf6
Unverified
Commit
bae5bcf6
authored
Nov 17, 2015
by
Cédric Bonhomme
Browse files
commit fine-tune from the last week
parent
9c98f618
Changes
3
Show whitespace changes
Inline
Side-by-side
web/__init__.py
View file @
bae5bcf6
...
...
@@ -28,6 +28,9 @@ app.debug = True
# Create a random secrey key so we can use sessions
app
.
config
[
'SECRET_KEY'
]
=
os
.
urandom
(
12
)
from
ev3.ev3dev
import
Tone
alarm
=
Tone
()
#head = None#Motor(port=Motor.PORT.A)
right_wheel
=
None
left_wheel
=
None
...
...
@@ -38,11 +41,15 @@ try:
right_wheel
=
Motor
(
port
=
Motor
.
PORT
.
B
)
left_wheel
=
Motor
(
port
=
Motor
.
PORT
.
C
)
button
=
TouchSensor
()
ir_sensor
=
InfraredSensor
()
#
ir_sensor = InfraredSensor()
color_sensor
=
ColorSensor
()
alarm
.
play
(
200
)
except
Exception
as
e
:
alarm
.
play
(
200
)
alarm
.
play
(
200
)
raise
e
right_wheel
.
position
=
0
left_wheel
.
position
=
0
right_wheel
.
reset
()
...
...
web/lib/movements.py
View file @
bae5bcf6
...
...
@@ -43,12 +43,12 @@ def check_stop_condition(motorA, motorB):
stop
(
motorA
,
motorB
)
# go a few centimers backward
motorA
.
position
=
0
motorA
.
run_position_limited
(
position_sp
=
18
0
,
speed_sp
=
5
0
0
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
100
0
,
motorA
.
run_position_limited
(
position_sp
=
22
0
,
speed_sp
=
3
50
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
2
0
,
ramp_down_sp
=
1000
)
motorB
.
position
=
0
motorB
.
run_position_limited
(
position_sp
=
18
0
,
speed_sp
=
5
0
0
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
100
0
,
motorB
.
run_position_limited
(
position_sp
=
22
0
,
speed_sp
=
3
50
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
2
0
,
amp_down_sp
=
1000
)
while
"running"
in
motorA
.
state
.
split
(
" "
)
and
\
"running"
in
motorB
.
state
.
split
(
" "
):
...
...
@@ -67,12 +67,12 @@ def run_position_limited(motorA, motorB, position):
Run for a limitied position.
"""
motorA
.
position
=
0
motorA
.
run_position_limited
(
position_sp
=
position
,
speed_sp
=
5
0
0
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
100
0
,
motorA
.
run_position_limited
(
position_sp
=
position
,
speed_sp
=
3
50
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
2
0
,
ramp_down_sp
=
1000
)
motorB
.
position
=
0
motorB
.
run_position_limited
(
position_sp
=
position
,
speed_sp
=
5
0
0
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
100
0
,
motorB
.
run_position_limited
(
position_sp
=
position
,
speed_sp
=
3
50
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
2
0
,
amp_down_sp
=
1000
)
return
check_stop_condition
(
motorA
,
motorB
)
...
...
web/views/views.py
View file @
bae5bcf6
...
...
@@ -77,7 +77,7 @@ def move(direction="forward", speed=60):
elif
direction
==
'left'
:
forever
=
request
.
args
.
get
(
"forever"
,
None
)
if
None
is
forever
:
movements
.
rotate
(
left_wheel
,
right_wheel
,
-
360
,
360
,
1
4
0
,
0
)
movements
.
rotate
(
left_wheel
,
right_wheel
,
-
360
,
360
,
1
8
0
,
0
)
else
:
left_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
,
regulation_mode
=
False
)
...
...
@@ -85,7 +85,7 @@ def move(direction="forward", speed=60):
elif
direction
==
'right'
:
forever
=
request
.
args
.
get
(
"forever"
,
None
)
if
None
is
forever
:
movements
.
rotate
(
left_wheel
,
right_wheel
,
360
,
-
360
,
0
,
1
4
0
)
movements
.
rotate
(
left_wheel
,
right_wheel
,
360
,
-
360
,
0
,
1
8
0
)
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