2. HW/SW Implementation
mbed
Set up for GPS, and compass is in the mbed cook page. Corresponding pin can be found in the mbed code.
The Main
The Main program collects all data needed and send control command to the robot.
The pseudocode of the Main program is
Create a thread to communicate with follower detection Create Named Pipe to received the result of follower detection Get location data of current position Convert destination address to location data Query Google Maps for navigation data While Destination Not Achieved Get Next Step from navigation data While a Follower Detected Turn to align with desired heading Move forward certain distances
Computer Vision
The OpenCV library is used to process images captured by the camera. To determine whether a person is following the robot, a notecard with three circles is inserted at the front of the camera. When a image is captured, the program will try to identify whether there're three circles found. If two or more circles are found, the robot assume a person is following. Otherwise, the robot will assume a follower is lost and stop to wait for him/her.
The information of the follower detection is transfered to the "Main" program by Named Pipe. When the Main program started, a thread is created which the Named Pipe Server is running on. The Follower Detection program connect to the Named Pipe Server as client. The data type is a boolean value. 0 means no follower. 1 means the opposite.
Google Maps API
Google provides API to query data from their server which is called web service API. Two of them are used in this project: Geocode API and Direction API. Geocode API is used to convert human readable address to location data(longtitude and latitude). Direction API return the path from start location and destination. To use these API, the program make HTTP request to Google server. The HTTP request is send to the URL http://maps.googleapis.com/maps/api/service/(output)?(parameters). The "output" and "parameters" is cutomizable according the program. The URL has to be construct correctly to meet the requirement of Google. The data returned from Google Web Service API is in JSON format. A .Net library named "JSON.Net" is used to serialize the data.
iRobot Create
We use the iRobot Open Interface to communicate with our iRobot Create. The communication is done through a USB-Serial port and using the Windows SerialPort class. We choose to set the robot to Full Mode so that we had full control of the robot's actions and used scripts for some set commands, drive direct commands for moving, and wait angle commands for turning. The sensor data is handled by serial stream functions that read out bytes and set flags for when the bumpers were hit.