commit fine-tune from the last week

parent 9c98f618
...@@ -28,6 +28,9 @@ app.debug = True ...@@ -28,6 +28,9 @@ app.debug = True
# Create a random secrey key so we can use sessions # Create a random secrey key so we can use sessions
app.config['SECRET_KEY'] = os.urandom(12) app.config['SECRET_KEY'] = os.urandom(12)
from ev3.ev3dev import Tone
alarm = Tone()
#head = None#Motor(port=Motor.PORT.A) #head = None#Motor(port=Motor.PORT.A)
right_wheel = None right_wheel = None
left_wheel = None left_wheel = None
...@@ -38,11 +41,15 @@ try: ...@@ -38,11 +41,15 @@ try:
right_wheel = Motor(port=Motor.PORT.B) right_wheel = Motor(port=Motor.PORT.B)
left_wheel = Motor(port=Motor.PORT.C) left_wheel = Motor(port=Motor.PORT.C)
button = TouchSensor() button = TouchSensor()
ir_sensor = InfraredSensor() #ir_sensor = InfraredSensor()
color_sensor = ColorSensor() color_sensor = ColorSensor()
alarm.play(200)
except Exception as e: except Exception as e:
alarm.play(200)
alarm.play(200)
raise e raise e
right_wheel.position = 0 right_wheel.position = 0
left_wheel.position = 0 left_wheel.position = 0
right_wheel.reset() right_wheel.reset()
......
...@@ -43,12 +43,12 @@ def check_stop_condition(motorA, motorB): ...@@ -43,12 +43,12 @@ def check_stop_condition(motorA, motorB):
stop(motorA, motorB) stop(motorA, motorB)
# go a few centimers backward # go a few centimers backward
motorA.position = 0 motorA.position = 0
motorA.run_position_limited(position_sp=180, speed_sp=500, motorA.run_position_limited(position_sp=220, speed_sp=350,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000, stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=20,
ramp_down_sp=1000) ramp_down_sp=1000)
motorB.position = 0 motorB.position = 0
motorB.run_position_limited(position_sp=180, speed_sp=500, motorB.run_position_limited(position_sp=220, speed_sp=350,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000, stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=20,
amp_down_sp=1000) amp_down_sp=1000)
while "running" in motorA.state.split(" ") and \ while "running" in motorA.state.split(" ") and \
"running" in motorB.state.split(" "): "running" in motorB.state.split(" "):
...@@ -67,12 +67,12 @@ def run_position_limited(motorA, motorB, position): ...@@ -67,12 +67,12 @@ def run_position_limited(motorA, motorB, position):
Run for a limitied position. Run for a limitied position.
""" """
motorA.position = 0 motorA.position = 0
motorA.run_position_limited(position_sp=position, speed_sp=500, motorA.run_position_limited(position_sp=position, speed_sp=350,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000, stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=20,
ramp_down_sp=1000) ramp_down_sp=1000)
motorB.position = 0 motorB.position = 0
motorB.run_position_limited(position_sp=position, speed_sp=500, motorB.run_position_limited(position_sp=position, speed_sp=350,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000, stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=20,
amp_down_sp=1000) amp_down_sp=1000)
return check_stop_condition(motorA, motorB) return check_stop_condition(motorA, motorB)
......
...@@ -77,7 +77,7 @@ def move(direction="forward", speed=60): ...@@ -77,7 +77,7 @@ def move(direction="forward", speed=60):
elif direction == 'left': elif direction == 'left':
forever = request.args.get("forever", None) forever = request.args.get("forever", None)
if None is forever: if None is forever:
movements.rotate(left_wheel, right_wheel, -360, 360, 140, 0) movements.rotate(left_wheel, right_wheel, -360, 360, 180, 0)
else: else:
left_wheel.run_forever(speed * -1, regulation_mode=False) left_wheel.run_forever(speed * -1, regulation_mode=False)
right_wheel.run_forever(speed, regulation_mode=False) right_wheel.run_forever(speed, regulation_mode=False)
...@@ -85,7 +85,7 @@ def move(direction="forward", speed=60): ...@@ -85,7 +85,7 @@ def move(direction="forward", speed=60):
elif direction == 'right': elif direction == 'right':
forever = request.args.get("forever", None) forever = request.args.get("forever", None)
if None is forever: if None is forever:
movements.rotate(left_wheel, right_wheel, 360, -360, 0, 140) movements.rotate(left_wheel, right_wheel, 360, -360, 0, 180)
else: else:
left_wheel.run_forever(speed, regulation_mode=False) left_wheel.run_forever(speed, regulation_mode=False)
right_wheel.run_forever(speed * -1, regulation_mode=False) right_wheel.run_forever(speed * -1, regulation_mode=False)
......
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