BotTwo has a few modes of operation.
- In one of his Autonomous Modes, he can wander about aimlessly, simply avoiding objects, all the while building or refining a map of his surroundings for future use.
- A second function in his Autonomous Modes allows you to select a location from his floorplan map, and he will find the shortest path to it, using A* algorithm.
- In Manual Mode, you can drive him like an RC Car from a webpage.
This is the mode that I will describe here, with code examples for each programming platform. As part of my learning process, I chose a very simple DIY approach, as opposed to a framework like node.js
The php script opens a simple Web Socket to the Raspberry Pi on the Robot, and passes the command to it.
This is just one of many ways to do this, but it works well for me, and may be a starting place for you.
I chose to run my webserver (Apache/Php/MySQL) on a dedicated computer, as my Raspberry Pi is up and down as I'm working on it, or as the battery dies. You may chose to run the webserver on your Pi.
A slider Control or HTML5 <input type= "range"> is used to send speed control messages using the same methods described below.
On action, the Command and Parameter values are passed to php via the sendCommand function.
The php script accepts the Command and Parameter values, formats them into a string, and passes them to the Raspberry Pi, via a Web Socket.
As I stated, this is an example... If you wish for me to go further into detailed explanation, please comment below.
In the next article (2 of 3), I will describe how to receive and parse the command in python on the Raspberry Pi and forward it to an attached Arduino via the I2C bus.
And finally in article 3 of 3, I will describe the Arduino code that receives the I2C command, and turn it into motor actions to steer and run the robot.
Edit (05/13/2014): here is the button_box image... it's missing from my github...