SeanBotTwo years ago I did the SeanBot robot which was the EV3D4 build but with ev3dev running under the covers and a basic web interface for driving. The implementation was a bit clunky though as it used an apache web server to serve the web pages, images, etc but used a second web server for the REST API. Despite being a bit clunky to get going I've seen several projects use the seanbot code to provide a web interface for their robot. pandaeatsbamboo was the most recent project to do so, they have a nice blog post on their build.
Since there were several projects using the seanbot code and since many of the basic lego mindstorms builds are tank style robots (EV3D4, TRACK3R, GRIPP3R, EV3RSTORM, ete are all tank robots) I decided to revamp the seanbot code to make it a little easier to use. Here it is in action, details after the video.
- Only run one web server
- Implement the web server in python
- Take advantage of the Tank class in ev3dev-lang-python's helper.py
- Provide a desktop interface and a touch based smartphone interface
- Make it easy for someone to modify the existing code for their own robot
The web server listens on port 8000 so go to http://x.x.x.x:8000/ where x.x.x.x is the IP address of your EV3. The main interface will present you with a choice between a desktop interface or a mobile interface.
The desktop interface looks very similar to the original seanbot interface. There are two sliders, one to control the speed of the medium motor and one to control the speed of the tank's movements. This page supports touch events so you can use the desktop interface from your smartphone if you like.
The mobile interface uses a virtual joystick, if you drag the black dot towards the top of the gray circle the robot will move forward. Drag it to the right to turn clockwise, drag it to the left to turn counter clockwise, etc.
The closer the black dot is to the edge of the gray circle the faster the robot moves.
The code is available at ev3dev-lang-python in the demo/EV3D4 directory, just run EV3D4WebControl and off you go (I am assuming that you are running python-ev3dev 0.7.0 or later). WebControlledTank lives in ev3dev/helper.py so take a look at that if you want to see the details on what is going on behind the scenes.
If you want your own tank class robot with a web interface you could do something similar to this:
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D
from ev3dev.helper import WebControlledTank, MediumMotor
log = logging.getLogger(__name__)
WebControlledTank.__init__(self, left_motor, right_motor)
self.medium_motor = MediumMotor(medium_motor)
# code specific to your robot (sensors, etc) goes here
if __name__ == '__main__':
mybot = MyTankRobot()