Providing a programmable interface for controlling the robot movement
This part is relatively easier. We will be using the building blocks that were created in chapter 1. It mostly involves more HTML and Python coding than any hardware interfacing logic. We need to decide on a command list that we are going to support. I decided on the following:
f=forward, b=backward, l=left and r=right
Each command is allowed a range of 1 to 9 units of movement.
For example: l:3,f:7,b:4, r:2, which means turn left 3 units, go forward 7 units, backwards 4 units and finally turn right 2 units.
The complex part of the coding is in the HTML form submit for the command list. I also created a small iframe to dump back the translated commands to provide a verification feedback mechanism.
Once this command list is passed on to the python cgi-bin script, it is parsed for individual commands and executed.
The below video gives a demo of this behaviour. The code is available in the GITHUB repo.
All the code is available in Bitbucket. Use the following command to download the repo:
git clone https://email@example.com/boseontherocks/projects_1.git
The code used in this post is available in the folder robot_2