EV3WebController provides a Web interface in order to control the Lego Mindstorms EV3 robot.
Tested with Python 3.4 and Python 2.7.
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.
$ ssh [email protected]
$ 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 https://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
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
$ GET https://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.
$ GET https://192.168.1.16:5000/move/forward
{"action": "move", "direction": "forward", "message": "OK"}
In this case the HTTP status code returned is 200.
$ GET https://192.168.1.16:5000/move/nowhere
{"message": "Unknown direction", "direction": "nowhere", "action": "move"}
In this case the HTTP status code returned is 400.
$ GET https://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".
$ GET https://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".
$ GET https://192.168.1.16:5000/sensor/<sensor_name>
Acceptable values for sensor_name:
- button;
- ir_sensor.
$ GET https://192.168.1.16:5000/sensor/ir_sensor
{"distance": 12}
$ GET https://192.168.1.16:5000/sensor/color_sensor
{"rgb": [78, 31, 15], "mode": "RGB-RAW"}
EV3WebController is free software released under the "Modified BSD license"
Copyright (c) 2014-2015 Cédric Bonhomme - https://www.cedricbonhomme.org