Saturday, May 4, 2013

Testing and Analysis


The tests that were performed during the course of the project development were:
  • Unit testing of each software module developed.
  • Control of robot: Initial test involved sending commands from a PC to check if the robot behaves as expected. Next, we tested the control of the robot from the Android application. 
  • Resource utilization tests:
    • Battery usage test against theoretical calculations based on the speci cations.
    • Memory usage tests
  • Ping Accuracy test

MEMORY USAGE ON ANDROID:

The total heap memory used by the android application is about 2.88MB which is about 48% of the total memory. The memory allocated is mainly to transmit the data from the android application to the robot.


PING ACCURACY ANALYSIS:

To test the accuracy of the ping sensor we used an obstacle of dimensions 30cm * 20 cm. The obstacle was placed at different distances from the ping sensors and the output values were noted. The table below gives values obtained during the test. It is clear from the observed values that the accuracy of ping sensor reduces for very large distances

Actual Distance(cm) Ping Value(cm)
5 6
10 11
15 16
25 26
36 35
72 71
95 92


BATTERY LIFE ANALYSIS:

Battery Used: 9V Duracell batteries (2 No). 
Two 9V batteries were used along with another Duracell 5V source which powered the Beagle bone.

Tests were conducted to check the life of the 9V battery sources.
The current ratings of the various peripherals are :


  • Wi Adapter 500 mA(max)
  • Webcam 150mA (Operating)
  • Arduino 40 -50 mA (Assumed)
  • Motors 200 mA
  • Ping Sensor 20 mA


Application Screens

In this section, we explain the di erent screens of the Android app and how to navigate them.


OPENING SCREEN:

Figure 1 shows the opening screen of the app. This is the first screen that is loaded when the application is launched. This screen gives the user two options . One is to connect to the robot by clicking the START button , or to quit the application by clicking the QUIT button. When the user presses the START button the android application initializes the communication sockets with the robot and establishes a connection with the robot.

Figure 1. Screenshot showing the opening screen of the App

MAIN SCREEN:

Once the user clicks the start button on the opening screen the application opens the Main Screen of the android application . If the user is able to connect to the robot then it gives the user to start controlling the robot. If the android application isn't able to connect to the robot then a dialog box is shown displaying that the connection to the robot couldn't be established and asks the user to try again, and takes the user back to the Opening Screen.

If the application establishes a connection with the robot and the user presses start on the dialog box, then the application displays the video on the screen and the ping distance on the top of the screen. The slider to determine the speed of the robot is to the right of the screen. When the application loads the main screen for the first time the slider is in the middle to indicate that robot is in not being powered to go forward nor backward. This activity is FULL SCREEN Activity and the main view item of the activity is the video view. The ping distance and the slider have been added on top of the video view using the fragment layouts. Also the PAUSE and the SETTINGS button have been added using the Fragment Layout . The two buttons are displayed when the user taps on any part of the screen other than the slider.


Figure 2. Screenshot showing the main screen of the App

In Figure 2 we can see that the video view (GstreamerSurfaceView) is the main view of the full screen activity and the other components of the screen have been added on top of that view. When the user presses the PAUSE button the application sends a STOP signal to the robot and stops sending/receiving data over the sockets to the robot. The accelerometers also get disabled. A dialog box is displayed giving the user the option either to play again or go back to the opening screen. If the user selects the play button then the video starts streaming again and the inputs from the user are sent to the robot. If the user presses back, the user is taken back to the opening screen and all the connections with the robot are closed immediately. 

When the user presses the SETTINGS button the settings activity is started and the robot is stopped till the user returns from the settings activity. When the user returns from the settings activity the user again has the option to either play or go back to the opening screen. 


SETTINGS SCREEN:

The settings screen gives the user option to edit the settings related to application . The first option is to either enable/disable the ping sensor on the android application . The second option is to select the distance at which the robot has to come to halt in front of an obstacle. The user can select from 10 cm, 15 cm, 20 cm, 30 cm and 40 cm. Once the user selects the options and presses back button on the settings screen the application transmits the selections back to the robot immediately. This activity extends a PreferenceActivity and the uses Shared Preferences to store the options of the
user.


Communication over Sockets


The android application communicates with the robot over TCP and UDP sockets. There are three main sockets on the android application side which are all clients to the servers created on the robot.
The three sockets are used for:
  • TCP Socket for the Video Stream: This socket connects to the TCP server which is hosting the video stream. The TCP socket connects to the server over the PORT:5000 . The video stream is transmitted over this socket connection.
  • UDP Socket for the sending the control data from the application to the robot: The UDP socket is used to send the accelerometer data as well as the slider input to the robot. The UDP socket was chosen so that the there is no delay in the transmission of the control signals from the application to the robot. The same socket is also used to send the ping sensor distance readings to the android application. The application receives the ping data over the this socket and it displays the data on the User Interface.
  • TCP Socket for Commands: This third socket is used to send start and stop signals to the robot. The start signal is encoded as hex byte 0x02. When the robot receives this signal it opens the UDP port and starts listening for control data from the application and also starts transmitting the ping distance. The hex byte 0x01 is used to inform the robot to stop. The table given below shows messages and their corresponding codes:
    Commands Code
    Start 0x02
    Stop 0x01
    Ping Enable 0x50
    Ping Disable 0x51
    Stop at 10cm 0x0A
    Stop at 15cm 0x0F
    Stop at 20cm 0x14
    Stop at 30cm 0x1E
    Stop at 40cm 0x28


Android Application


The android application developed has a very intuitive and simple User Interface . This application allows the user to control the robot as well as watch the video stream on the phone.

FUNCTIONALITIES:


The main functionalities on the android application are :

1. The robot can be controlled using the phone.
2. The video stream from the robot can be watched on the android phone.
3. The user can connect and disconnect from the robot at any point of time
4. The application displays the distance to the nearest obstacle
5. The application allows the user to turn on/o the ping sensors The user can also set the
distance at which the robot needs to come to halt from the obstacle


CONTROL OF THE ROBOT USING THE APPLICATION:

The robot movements are controlled based on the inputs from the user on the phone. The movement of the robot forward or backward is controlled by the slider bar which is present on the Main Screen of the phone. By pushing the slider forward the user can make the robot move forward and by sliding the slider backwards the user can make the robot move backwards. The side ways movement of the robot is controlled by the accelerometer inputs from the phone. The user can tilt the phone to the right to make the robot turn right or tilt the phone to the left to make the robot turn left. The amount of turn that the robot makes depends on the amount of tilt. The robot tries to maintain a constant speed of one wheel and will reduce the speed of the other wheel. The amount by which the speed of the other wheel is reduced depends on the amount of tilt. If the tilt is very high, then the wheel will start to turn in the opposite direction. The slider ensures that the robot moves with the same speed as long the slide remains in the same position. This enables us to maintain a constant speed.

LIVE VIDEO STREAM FROM THE ROBOT:

The video stream is transmitted by the robot over a TCP connection on PORT 5000. To obtain the video stream on the Android application the Gstreamer SDK has been used . The native functions of the SDK have been used to initialize, play and pause the video. The user can watch the live video stream on the Main Screen of the application. When the user decides the pause the robot, the video stream also pauses. The video stream starts playing once the user starts controlling the robot again.

CONNECTION OF THE ROBOT:


The user can connect and disconnect from the robot at any point of time. When the user connects to the robot , the three sockets are opened and connected to the server on the robot. If the sockets cannot be opened or the communication channel between the robot and the phone cannot be established then a dialog box is displayed saying that the application couldn't connect to the robot.  At any point of time once the connection is established with the robot the user can disconnect from the robot. When the user decides to disconnect from the robot the application ensures that the robot is brought to a stop and then closes the socket connection with robots. The user can reconnect to the robot at any point of time.



PING SENSOR DATA:

The application displays the distance to the obstacle on the Main screen of the application. The distance is displayed on the top of the screen. When the ping sensors have been disabled the distance shown by the ping sensor is 0 cm.

Disable/Enable Ping Sensor:

The user can either disable or enable ping sensor from the android application. To do so the user has to open the settings menu of the application and select/deselect the check-box pertaining to the ping sensor.

Distance at which the robot has to come to a halt: 

The user can select the distance at which the robot has to come to a halt . The user has five options: 10 cm, 15 cm, 20 cm, 30 cm, 40 cm. To do so the user has to open the settings menu of the application and select the distance at which the robot has to come to a stop.