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

reset motors

parent 6b93e7c0
......@@ -45,7 +45,7 @@ except Exception as e:
right_wheel.position = 0
left_wheel.position = 0
right_wheel.stop()
left_wheel.stop()
right_wheel.reset()
left_wheel.reset()
from web import views
......@@ -38,12 +38,22 @@ def check_stop_condition(motorA, motorB):
time.sleep(0.1)
if button.is_pushed:
stop(motorA, motorB)
time.sleep(0.5)
motorA.position = 0
motorA.run_position_limited(position_sp=180, speed_sp=800,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000,
ramp_down_sp=1000)
motorB.position = 0
motorB.run_position_limited(position_sp=180, speed_sp=800,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000,
amp_down_sp=1000)
return "hit_wall"
if color_sensor.colors[color_sensor.color] == "red":
stop(motorA, motorB)
return "in_target"
return "OK"
def run_position_limited(motorA, motorB, position):
"""
Run for a limitied position.
......
......@@ -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=True)
right_wheel.run_forever(speed * -1, regulation_mode=True)
left_wheel.run_forever(speed * -1, regulation_mode=False)
right_wheel.run_forever(speed * -1, regulation_mode=False)
elif direction == 'backward':
nb_blocks = request.args.get("blocks", None)
......
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