Android based autonomous mobile robot

—The spreading of mobile robots is getting more significant nowadays. This is due to their ability to perform tasks that are dangerous, uncomfortable or impossible to people. The mobile robot must be endowed with a wide variety of sensors (cameras, microphones, proximity sensors, etc.) and processing units that makes them able to navigate in their environment. This generally carried out with unique, small series produced and thus expensive equipment. This paper describes the concept of a mobile robot with a control unit integrating the processing and the main sensor functionalities into one mass produced device, an Android smartphone. The robot is able to perform tasks such as tracking colored objects or human faces and orient itself. In the meantime, it avoids obstacles and keeps the distance between the target and itself. It is able to verbally communicate wit .


I. INTRODUCTION
The computing capacity of today's mobile phones is many times greater than the one's was used for Moon landing [1], yet commonly used for entertainment purposes.These pocket computers are equipped with many different kind of sensors that are also used in robotics.Advanced robots often need GPS, inertial sensors and e-compass, for navigation and orientation, cameras for image processing, microphone as audio input and wireless connectivity.These are all included in smartphones.This paper not only draws attention to smartphones for their integrated sensors, but the enormous software support and open source solutions.
There have already been researches using smartphones in robotics.A common application uses smartphones as user interfaces for remote controlling [2] [3].A semi autonomous robot presented by Stansfield and Bothma is still remote controlled and has Android device on both sides, but on the robot side it is used for interfacing an external distance sensor and also implements a simple collision avoidance algorithm [4].A mobile robot presented by Lim, Lee and Tewolde is additionally to the previous robot uses the inertial sensors of the smartphone to improve indoor navigation capabilities of the robot [5].Another robot takes advantage of the camera integrated in the smartphone for implementing image processing for line following [6].
Smartphone based mobile robots are used for educational purposes, where smartphone based image processing is also implemented [7] [8].There are already robot platforms for smartphones that are commercial products with easy to use developer environment designed for children educational programming [9] [10].
The present project aimed to build a mobile robot that is capable of fulfilling the following objectives while taking advantage of the advanced functionality of an everyday smartphone: 1) capable of tracking human faces and colored object 2) implements collision avoidance while following its target 3) capable of verbal communication with humans, receives orders and answers simple questions Such robot that can understand human questions and intelligently answer them seemed very high tech a few years ago, but today this technology is in everyone's pocket [11] [12].
The robot is a car-like vehicle with ultrasonic distance sensors and a 2 DOF consol for holding the Android phone.Two servo motors can change the yaw and pitch angles of the phone in 180°.A third servo is responsible for steering the vehicle.Fig. 1 illustrates the mechanical construction of the robot.In the view of organization the paper has the following sections: Section I was a short introduction.Section II describes different possibilities for connecting the smartphone to external hardware.Section III is about the software solutions of the robot.Section IV shortly describes the architecture of the software.Section V concludes the paper.

II. CONNECTING THE SMARTPHONE TO THE ROBOT
The project was carried out with a Samsung Galaxy Ace S5830 type smartphone.This was a mid-range device announced in 2011, January.It has an 800 MHz ARM11 processor and 278 Mb of RAM.The latest official software update for it was Android 2.3.3Gingerbread.In the view of connectivity this setup can act as a USB slave device.It can also be connected through Bluetooth to an external hardware.Direct Wi-Fi connection is only possible from Android 4.0 and above [13].
Many microcontroller manufacturers offer now Android accessory frameworks to their IC-s [14].These establish communication through USB between the Android device and the embedded system.In the USB communication there is always a host controller and a slave device [14].The host powers the bus while usually the slave device represents simpler functionality.Devices running Android 3.1 and above can act as USB host controller.Older systemssuch as in this projectcan only act as slaves.Therefore, USB communication requires an external microcontroller with USB host peripheral.This solution can benefit during longer operations of the robot, because the robot can charge the Android device.
However, wireless connection is always offers wider accessibility.With the above described setup, the communication can be carried out with Bluetooth as well.This does not require Bluetooth module in the embedded system, but a USB-Bluetooth adapter can be used.
In the described system a Microchip PIC24FJ256DA microcontroller was used.The microcontroller implements an open source framework called IOIO that handles the USB peripheral and supports the Bluetooth communication [15].The framework comes with an Android library, which offers high level functions for initializing and operating digital IO-s, PWM outputs, UART peripheral and timer functions in the microcontroller.This means that functionalities can be programmed through the Android program.Fig. 2 shows the layout plan of the system.

A. Image processing
The main functions of the robot are face tracking and color blob tracking.These tasks can be solved with external image processing software libraries such as OpenCV [16] or with native Android functions.

1) Face tracking
In the case of face tracking, the methods described in this section can be compared in the perspective of frame rate, and the precision of recognition.Spontaneous false positive recognitions can be filtered out with low pass filter.In case of short time false negative results during tracking the robot will look for the face in the previously identified region of interest.

2) Face tracking with native Android functions
Above Android 4.0 there is a Face detector function in the camera class [17].This finds faces in the camera preview image, thus it natively serves with the highest frame rate.The function's return array contains the position of the faces in the preview image.This certainly the most optimized solution but was not yet available due to the system setup.
Another native solution for face detection in Android is the findFaces function, which is available in every Android version [18].This does not work on the live preview image but needs a bitmap image for processing and is relatively slow.

3) Face tracking with OpenCV
The OpenCV face detection uses Viola-Jones object detection algorithm [18], which is a Haar-feature based cascade classifier [20].The operation and training of the detector is described in details by Viola and Jones in their work on rapid object detection [19].OpenCV comes with many pre-trained classifier for face, eyes, smile etc.These are stored in XML files and can be simply loaded into the program.The OpenCV provides a wide scale for algorithm customization compared to the previously mentioned face detectors.The image to be processed can be downscaled, which reduces processing time per frame.Also the size of the smallest detectable face can be given.The smaller the face we want to detect the more times the algorithm has to scan the image with increasingly smaller detection window.By varying these two features an optimum can be found where the robot can sense faces in an acceptable distance, while providing sufficient frame rate.

4) Color blob tracking
The input image of the color blob tracker algorithm is coded in RGB color space.In the first step this is converted into HSV color space.HSV color model is a method to define colors according to the three basic features of the color: hue, saturation and luminance [21].In the present application the robot follows a colored object.The changes of light conditions due to the environment and robot orientation affect the detected colors.These changes in RGB color space affect all the three color feature, whereas in HSV color space these mostly affect the luminance component of the color.This feature of the HSV color space allows a more useable color based segmentation.The hue of the color can be more specified, while a wider tolerance can be set to the luminance feature.
The algorithm under-samples the image i.e. reduces resolution to reduce processing time.Creates a new binary matrix where only fills those positions, where the corresponding pixel falls between the allowed thresholds in hue, saturation and luminance.This binary mask is expanded to the original size of the image.A border following algorithm developed by Suzuki and Abe [22] finds the contours around the mask and returns an array with the bounding rectangles of the individual contours.The robot wants to follow the largest object that matches the target color, therefore takes the largest contour as the representation of the followed object.It calculates the difference between the center point of the detected color blob and the center of the processed image as the regulator's error (Fig. 3).The error signal of the object follower controller is calculated similarly during face tracking with the largest, hence closest face.Table I. summarizes the frame rate results between the experimented color blob and face detector methods in respect to their different parameter setups.

B. Speech recognition and verbal response
Speech recognizer service and text-to-speech engine are basic services in Android, and can be easily implemented in any program.The speech recognizer requires internet connection, because the processing is done in the cloud [23].It returns a set of the possibly heard word combinations.The given order to the robot is validated if the returned set contains it or something very similar.The robot answers to each instruction using the text-to-speech engine, and notifies if the instruction was misunderstood.It can also answers to some basic questions from a preprogrammed answer bank.
The verbal orders are also used for changing between the face tracking and object tracking.For a specified order the robot takes a color sample from the object held front of its camera and will follow it.The speech recognizer can be triggered with a short whistle.

IV. SOFTWARE ARCHITECTURE
The software builds on parallel running threads.The two main threads are the image processing and the microcontroller interface thread that reads the external sensors and drives the robot.These two threads communicate to each other through an intermediate controller object.There are two minor threads responsible for whistle detection.
The analog digital converter module of the microphone is capable of 44100 Hz sampling frequency on 16 bits.One thread records these samples and feeds them to the whistle detector thread in 2048 sample big packages.The detector than applies a Fast Fourier Transformation on the dataset.Spikes between 1 and 3 kHz are considered as whistles.When a whistle is detected the speech recognizer service is being launched, but first the recording has to be stopped to release the microphone as system resource.
The intermediate controller object is responsible for the eventual tracking of the detected objects.It also implements a state machine for enhanced collision avoidance algorithm.
The image processing thread does not supply the data with fixed sampling rate, thus the system clock is used to establish the elapsed time for the vertical and horizontal PID controllers.
Fig. 4 summarizes the software organization.This paper presented a possible usage of smartphones in mobile robotics as complex processing units and sensor arrays.Usage of smartphones in robotic applications can extend the capabilities of robots compared to conventional embedded systems.However, with mid-range phones the response time of the system will be too long.Simultaneous running of advanced functions might results phase shift on the real-time behavior.Higher-end smartphones can extend the embedded computers of mobile robots by taking advantages of all benefits of mass production and open source in the aspects of costs, software and hardware development.

Fig. 2 .
Fig. 2. Layout of the external system.The charging current can be set with a potentiometer.Bluetooth adapter requires maximum current, while direct USB communication can be operational with minimal current, thus saves robot battery

TABLE I .
FPS VALUES WITH DIFFERENT TRACKING ALGORITHMS (THE VALUES ARE IN FRAME/SECOND)