Commit c9d81b89 authored by Cédric Bonhomme's avatar Cédric Bonhomme

Closes #9.

parent 91a3ec94
...@@ -33,12 +33,15 @@ def check_stop_condition(motorA, motorB): ...@@ -33,12 +33,15 @@ def check_stop_condition(motorA, motorB):
""" """
Wait for the completion of the command before sending the result. Wait for the completion of the command before sending the result.
""" """
result_message = []
while "running" in motorA.state.split(" ") and \ while "running" in motorA.state.split(" ") and \
"running" in motorB.state.split(" "): "running" in motorB.state.split(" "):
time.sleep(0.1) time.sleep(0.1)
if button.is_pushed: if button.is_pushed:
# stop the motor
stop(motorA, motorB) stop(motorA, motorB)
time.sleep(0.5) time.sleep(0.5)
# go a few centimers backward
motorA.position = 0 motorA.position = 0
motorA.run_position_limited(position_sp=180, speed_sp=800, motorA.run_position_limited(position_sp=180, speed_sp=800,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000, stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000,
...@@ -50,11 +53,11 @@ def check_stop_condition(motorA, motorB): ...@@ -50,11 +53,11 @@ def check_stop_condition(motorA, motorB):
while "running" in motorA.state.split(" ") and \ while "running" in motorA.state.split(" ") and \
"running" in motorB.state.split(" "): "running" in motorB.state.split(" "):
time.sleep(0.1) time.sleep(0.1)
return "hit_wall" result_message.append("hit_wall")
if color_sensor.colors[color_sensor.color] == "red": if color_sensor.colors[color_sensor.color] == "red":
stop(motorA, motorB) stop(motorA, motorB)
return "in_target" result_message.append("in_target")
return "OK" return ";".join(result_message) if len(result_message) != 0 else "OK"
def run_position_limited(motorA, motorB, position): def run_position_limited(motorA, motorB, position):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment