Commit 4852459a authored by Cédric Bonhomme's avatar Cédric Bonhomme

run_position_limited with position_sp set to 360by default (seems to be about 11cm).

parent b1176e8a
......@@ -34,7 +34,7 @@ button = None
ir_sensor = None
try:
right_wheel = Motor(port=Motor.PORT.B)
left_wheel = Motor(port=Motor.PORT.C)
left_wheel = Motor(port=Motor.PORT.C)
button = TouchSensor()
ir_sensor = InfraredSensor()
except Exception as e:
......
......@@ -5,7 +5,7 @@ $(document).ready(function() {
console.log('ArrowUp down')
var ip = document.domain
var power = 60
var ajax_url = "http://" + ip + ":5000/move/forward/" + power
var ajax_url = "http://" + ip + ":5000/move/forward"
$.ajax({
type: "GET",
......@@ -22,7 +22,7 @@ $(document).ready(function() {
console.log('ArrowDown down')
var ip = document.domain
var power = 60
var ajax_url = "http://" + ip + ":5000/move/backward/" + power
var ajax_url = "http://" + ip + ":5000/move/backward"
$.ajax({
type: "GET",
......@@ -39,7 +39,7 @@ $(document).ready(function() {
console.log('ArrowLeft down')
var ip = document.domain
var power = 60
var ajax_url = "http://" + ip + ":5000/move/left/" + power
var ajax_url = "http://" + ip + ":5000/move/left"
$.ajax({
type: "GET",
......@@ -56,7 +56,7 @@ $(document).ready(function() {
console.log('ArrowRight down')
var ip = document.domain
var power = 60
var ajax_url = "http://" + ip + ":5000/move/right/" + power
var ajax_url = "http://" + ip + ":5000/move/right"
$.ajax({
type: "GET",
......
......@@ -22,6 +22,8 @@ from flask import render_template, current_app, request, session, \
from flask.ext.login import LoginManager, login_user, logout_user, \
login_required, current_user, AnonymousUserMixin
from ev3.ev3dev import Motor
import conf
from web.decorators import to_response
from web import app
......@@ -52,7 +54,7 @@ def load_user(id):
@app.route('/move/<direction>', methods=['GET'])
@app.route('/move/<direction>/<speed>', methods=['GET'])
@to_response
def move(direction="forward", speed=60):
def move(direction="forward", speed=800):
"""
"""
result = {
......@@ -63,8 +65,20 @@ def move(direction="forward", speed=60):
return_code = 200
if direction == 'forward':
left_wheel.run_forever(speed * 1, regulation_mode=False)
right_wheel.run_forever(speed * 1, regulation_mode=False)
nb_blocks = request.args.get("blocks", None)
if None is not nb_blocks:
position = int(nb_blocks) * 360
left_wheel.position = 0
left_wheel.run_position_limited(position_sp=position, speed_sp=800,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000,
ramp_down_sp=1000)
right_wheel.position = 0
right_wheel.run_position_limited(position_sp=position, speed_sp=800,
stop_mode=Motor.STOP_MODE.BRAKE, ramp_up_sp=1000,
amp_down_sp=1000)
else:
left_wheel.run_forever(speed * 1, regulation_mode=False)
right_wheel.run_forever(speed * 1, regulation_mode=False)
elif direction == 'backward':
try:
......
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