Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EV3WebController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Science Festival 2015
EV3WebController
Commits
04c35974
Unverified
Commit
04c35974
authored
Oct 29, 2015
by
Cédric Bonhomme
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor bug fixes and improvements
parent
306f47f6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
96 deletions
+43
-96
CHANGELOG.md
CHANGELOG.md
+5
-1
README.md
README.md
+1
-1
bootstrap.py
bootstrap.py
+1
-1
conf.py
conf.py
+7
-27
runserver.py
runserver.py
+1
-1
web/__init__.py
web/__init__.py
+15
-13
web/decorators.py
web/decorators.py
+1
-1
web/lib/utils.py
web/lib/utils.py
+1
-1
web/views/views.py
web/views/views.py
+11
-50
No files found.
CHANGELOG.md
View file @
04c35974
EV3WebController project news
0.
1 (2014-12-15)
0.
2 (2015-10-29)
*
Beta release. It is possible to control the robot in four directions;
*
minor improvements and bug fixed.
0.
1 (2013-04-15)
*
First working prototype.
README.md
View file @
04c35974
...
...
@@ -57,7 +57,7 @@ Acceptable values for *sensor_name*:
cve-search is free software released under the "Modified BSD license"
Copyright (c) 201
3
-2015 Cédric Bonhomme - https://www.cedricbonhomme.org
Copyright (c) 201
4
-2015 Cédric Bonhomme - https://www.cedricbonhomme.org
# Contact
...
...
bootstrap.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
conf.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
@@ -20,7 +20,6 @@ import os, sys
BASE_DIR
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
PATH
=
os
.
path
.
abspath
(
"."
)
ON_HEROKU
=
int
(
os
.
environ
.
get
(
'HEROKU'
,
0
))
==
1
DEFAULTS
=
{
"platform_url"
:
"http://0.0.0.0:5000"
,
"host"
:
"0.0.0.0"
,
"port"
:
"5000"
,
...
...
@@ -28,32 +27,13 @@ DEFAULTS = {"platform_url": "http://0.0.0.0:5000",
"debug"
:
"true"
}
if
not
ON_HEROKU
:
try
:
import
configparser
as
confparser
except
:
import
ConfigParser
as
confparser
# load the configuration
config
=
confparser
.
SafeConfigParser
(
defaults
=
DEFAULTS
)
config
.
read
(
os
.
path
.
join
(
BASE_DIR
,
"conf/conf.cfg"
))
else
:
class
Config
(
object
):
def
get
(
self
,
_
,
name
):
return
os
.
environ
.
get
(
name
.
upper
(),
DEFAULTS
.
get
(
name
))
def
getint
(
self
,
_
,
name
):
return
int
(
self
.
get
(
_
,
name
))
def
getboolean
(
self
,
_
,
name
):
value
=
self
.
get
(
_
,
name
)
if
value
==
'true'
:
return
True
elif
value
==
'false'
:
return
False
return
None
config
=
Config
()
try
:
import
configparser
as
confparser
except
:
import
ConfigParser
as
confparser
PATH
=
os
.
path
.
abspath
(
"."
)
config
=
confparser
.
SafeConfigParser
(
defaults
=
DEFAULTS
)
config
.
read
(
os
.
path
.
join
(
BASE_DIR
,
"conf/conf.cfg"
))
PLATFORM_URL
=
config
.
get
(
'misc'
,
'platform_url'
)
...
...
runserver.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
web/__init__.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
@@ -14,10 +14,10 @@ import os
from
flask
import
Flask
#from ev3.ev3dev import Ev3Dev
#
from ev3.ev3dev import Key, Motor
"""
from ev3.lego import LargeMotor
from
ev3.ev3dev
import
Key
,
Motor
from
ev3.lego
import
LargeMotor
from
ev3.lego
import
TouchSensor
from ev3.lego import InfraredSensor
"""
from
ev3.lego
import
InfraredSensor
import
conf
...
...
@@ -30,14 +30,16 @@ app.config['SECRET_KEY'] = os.urandom(12)
#Ev3Dev.__init__()
#head = None#Motor(port=Motor.PORT.A)
right_wheel
=
None
#Motor(port=Motor.PORT.B)
left_wheel
=
None
#Motor(port=Motor.PORT.C)
button
=
None
#TouchSensor()
ir_sensor
=
None
#InfraredSensor()
# Views
#from flask.ext.restful import Api
#api = Api(app, prefix='/api/v1.0')
right_wheel
=
None
left_wheel
=
None
button
=
None
ir_sensor
=
None
try
:
right_wheel
=
Motor
(
port
=
Motor
.
PORT
.
B
)
left_wheel
=
Motor
(
port
=
Motor
.
PORT
.
C
)
button
=
TouchSensor
()
ir_sensor
=
InfraredSensor
()
except
Exception
:
print
(
"You must run the application as root on the EV3."
)
from
web
import
views
web/decorators.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
web/lib/utils.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@ import logging
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
web/views/views.py
View file @
04c35974
...
...
@@ -3,7 +3,7 @@
# ***** BEGIN LICENSE BLOCK *****
# This file is part of EV3WebController.
# Copyright (c) 2014 Cédric Bonhomme.
# Copyright (c) 2014
-2015
Cédric Bonhomme.
# All rights reserved.
#
#
...
...
@@ -11,14 +11,13 @@
# ***** END LICENSE BLOCK *****
__author__
=
"Cedric Bonhomme"
__version__
=
"$Revision: 0.
1
$"
__version__
=
"$Revision: 0.
2
$"
__date__
=
"$Date: 2014/12/15$"
__revision__
=
"$Date: 201
4/12/15
$"
__copyright__
=
"Copyright (c) 2014 Cédric BOnhomme"
__revision__
=
"$Date: 201
5/10/29
$"
__copyright__
=
"Copyright (c) 2014
-2015
Cédric BOnhomme"
__license__
=
""
from
flask
import
render_template
,
current_app
,
request
,
flash
,
session
,
\
from
flask
import
render_template
,
current_app
,
request
,
session
,
\
url_for
,
redirect
,
g
,
send_from_directory
,
make_response
,
abort
,
Markup
from
flask.ext.login
import
LoginManager
,
login_user
,
logout_user
,
\
login_required
,
current_user
,
AnonymousUserMixin
...
...
@@ -28,68 +27,30 @@ from web.decorators import to_response
from
web
import
app
from
web
import
right_wheel
,
left_wheel
,
button
,
ir_sensor
#
# Default errors
#
@
app
.
errorhandler
(
404
)
def
page_not_found
(
e
):
return
render_template
(
'errors/404.html'
),
404
@
app
.
errorhandler
(
405
)
def
method_not_allowed
(
e
):
return
render_template
(
'errors/405.html'
),
405
@
app
.
errorhandler
(
500
)
def
page_not_found
(
e
):
return
render_template
(
'errors/500.html'
),
500
def
redirect_url
(
default
=
'profile'
):
return
request
.
args
.
get
(
'next'
)
or
\
request
.
referrer
or
\
url_for
(
default
)
login_manager
=
LoginManager
(
app
)
login_manager
.
login_view
=
'login'
login_manager
.
login_message
=
'Please log in to access this page.'
login_manager
.
login_message_category
=
'danger'
@
app
.
errorhandler
(
403
)
def
authentication_failed
(
e
):
flash
(
'You do not have enough rights.'
,
'danger'
)
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'about'
))
@
app
.
errorhandler
(
401
)
def
authentication_required
(
e
):
flash
(
'Authenticated required.'
,
'info'
)
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'about'
))
@
login_manager
.
user_loader
def
load_user
(
id
):
# Return an instance of the User model
return
models
.
User
.
objects
(
id
=
id
).
first
()
@
app
.
before_request
def
before_request
():
g
.
user
=
current_user
def
log_user
(
user
):
"""
Effectively log the user and update the identity with Flask-Principal.
"""
login_user
(
user
)
g
.
user
=
user
session
[
'id'
]
=
str
(
user
.
id
)
# Tell Flask-Principal the identity changed
identity_changed
.
send
(
current_app
.
_get_current_object
(),
identity
=
Identity
(
str
(
user
.
id
)))
@
app
.
route
(
'/move/<direction>'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/move/<direction>/<speed>'
,
methods
=
[
'GET'
])
...
...
@@ -105,13 +66,13 @@ def move(direction="forward", speed=60):
return_code
=
200
if
direction
==
'forward'
:
pass
#left_wheel.run_forever(speed * -
1, regulation_mode=False)
#right_wheel.run_forever(speed * -
1, regulation_mode=False)
left_wheel
.
run_forever
(
speed
*
1
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
*
1
,
regulation_mode
=
False
)
elif
direction
==
'backward'
:
try
:
left_wheel
.
run_forever
(
speed
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
,
regulation_mode
=
False
)
left_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
False
)
right_wheel
.
run_forever
(
speed
*
-
1
,
regulation_mode
=
False
)
except
Exception
as
e
:
result
[
"message"
],
return_code
=
"error"
,
400
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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