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
c9d81b89
Unverified
Commit
c9d81b89
authored
Nov 10, 2015
by
Cédric Bonhomme
Browse files
Closes
#9
.
parent
91a3ec94
Changes
1
Hide whitespace changes
Inline
Side-by-side
web/lib/movements.py
View file @
c9d81b89
...
...
@@ -33,12 +33,15 @@ def check_stop_condition(motorA, motorB):
"""
Wait for the completion of the command before sending the result.
"""
result_message
=
[]
while
"running"
in
motorA
.
state
.
split
(
" "
)
and
\
"running"
in
motorB
.
state
.
split
(
" "
):
time
.
sleep
(
0.1
)
if
button
.
is_pushed
:
# stop the motor
stop
(
motorA
,
motorB
)
time
.
sleep
(
0.5
)
# go a few centimers backward
motorA
.
position
=
0
motorA
.
run_position_limited
(
position_sp
=
180
,
speed_sp
=
800
,
stop_mode
=
Motor
.
STOP_MODE
.
BRAKE
,
ramp_up_sp
=
1000
,
...
...
@@ -50,11 +53,11 @@ def check_stop_condition(motorA, motorB):
while
"running"
in
motorA
.
state
.
split
(
" "
)
and
\
"running"
in
motorB
.
state
.
split
(
" "
):
time
.
sleep
(
0.1
)
re
turn
"hit_wall"
re
sult_message
.
append
(
"hit_wall"
)
if
color_sensor
.
colors
[
color_sensor
.
color
]
==
"red"
:
stop
(
motorA
,
motorB
)
re
turn
"in_target"
return
"OK"
re
sult_message
.
append
(
"in_target"
)
return
";"
.
join
(
result_message
)
if
len
(
result_message
)
!=
0
else
"OK"
def
run_position_limited
(
motorA
,
motorB
,
position
):
...
...
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