Skip to content

This application provides a Web interface in order to control the EV3 robot.

License

Notifications You must be signed in to change notification settings

cedricbonhomme/EV3WebController

Repository files navigation

EV3WebController

Presentation

EV3WebController provides a Web interface in order to control the Lego Mindstorms EV3 robot.

Tested with Python 3.4 and Python 2.7.

Installation

Installation of the system

First, install ev3dev on your Lego Mindstorms EV3 brick.

During our tests we used ev3-ev3dev-jessie-2015-09-13 with python-ev3 0.0.3.0.

For the network I recommend the Wireless Nano Adapter Edimax EW-7811Un which is working perfectly out of the box.

Installation of EV3WebController and the requirements

$ ssh root@192.168.1.16
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ wget https://github.com/cedricbonhomme/EV3WebController/archive/master.tar.gz
$ tar -xzvf master.tar.gz
$ rm master.tar.gz
$ cd EV3WebController-master/
$ pip install -r requirements.txt
$ wget https://github.com/topikachu/python-ev3/archive/master.tar.gz
$ tar -xzvf master.tar.gz
$ rm master.tar.gz
$ cd python-ev3-master/
$ python setup.py install
$ cd ..
$ rm -Rf python-ev3-master/
$ cp conf/conf.cfg-sample conf/conf.cfg

Launch EV3WebController:

$ python runserver.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat

Launch EV3WebController at boot

In order to get EV3WebController start at boot, just create a new systemd service.

First create the file /etc/systemd/system/brickrc.service:

[Unit]
Description=EV3WebController
After=multi-user.target

[Install]
WantedBy=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/root/EV3WebController/run.sh

Then enable the new service:

$ systemctl daemon-reload
$ systemctl enable brickrc.service
$ systemctl restart brickrc.service

How to use the interface

Move the robot

$ GET http://192.168.1.16:5000/move/<direction>/<speed=800>

The value of speed is optional. Default is 800.

Acceptable values for direction:

  • forward;
  • backward;
  • left;
  • right;
  • stop.

Examples

Action successfully completed

$ GET http://192.168.1.16:5000/move/forward
{"action": "move", "direction": "forward", "message": "OK"}

In this case the HTTP status code returned is 200.

Unable to understand the request

$ GET http://192.168.1.16:5000/move/nowhere
{"message": "Unknown direction", "direction": "nowhere", "action": "move"}

In this case the HTTP status code returned is 400.

Hit a wall

$ GET http://192.168.1.16:5000/move/forward?blocks=25
{"action": "move", "direction": "forward", "message": "hit_wall"}

If a wall is detected the current action is stopped and the server will return the message "hit_wall".

End of the labyrinth

$ GET http://192.168.1.16:5000/move/forward?blocks=20
{"action": "move", "direction": "forward", "message": "in_target"}

If the red color is detected the current action is stopped and the server will return the message "in_target".

Retrieve values from sensors (not yet implemented)

$ GET http://192.168.1.16:5000/sensor/<sensor_name>

Acceptable values for sensor_name:

  • button;
  • ir_sensor.

Examples

$ GET http://192.168.1.16:5000/sensor/ir_sensor
{"distance": 12}
$ GET http://192.168.1.16:5000/sensor/color_sensor
{"rgb": [78, 31, 15], "mode": "RGB-RAW"}

License

EV3WebController is free software released under the "Modified BSD license"

Copyright (c) 2014-2015 Cédric Bonhomme - https://www.cedricbonhomme.org

Contact

Cédric Bonhomme.