Contents
Overview
The objective of the Android Remote Control module in the Project is to serve as a wireless remote control for the robotic system via Bluetooth.
It issues command to the robot to execute various maneuvers, as well as provide a visual representation of the robot and the maze environment.
Functionalities
1) Transmit and receive text Strings over the Bluetooth serial connection link
Writing: When the Android Device is connected to the Raspberry Pi(RPi) via Bluetooth (BluetoothConnectionStatus == true), the message will be transmitted by calling BluetoothConnectionService.write(Bytes) function. The write function calls the outStream.write(Bytes) function in order write the message over to the Bluetooth Serial LinkReading: When the RPi sends over the message in the form of bytes, the bytes are deconstructed to form the String which is then displayed on the chat screen.
2) Functional Graphical User Interface(GUI) that is able to initiate the scanning, selection and connection with a Bluetooth device
Multiple ListViews are created to display the paired devices and newly discovered devices separately on the Android Device.
Scanning: To search for new devices to be connected to over Bluetooth, mBluetoothAdapter.startDiscovery is called which discovers nearby devices.
When a device is chosen by the user, the MAC address of the device is sent back to the parent Activity in the result intent. A new ConnectThread is created to initiate connection with the chosen device. The thread is started by calling mConnectedThread.start() in order for the thread to manage the connection and perform transmissions. Finally, the name of the connected device is sent back to the UI Activity.
3) Functional GUI that provides interactive control of the robot movement via the Bluetooth link
The Android Application has 4 buttons to control the movement of the robot(Up, Down, Left, Right). When the user clicks any of the 4 buttons, the corresponding action and message is sent:
Up: Moves the Robot Forward. sendMessage(“W1|”), Down: Move the Robot Backwards. sendMessage(“S1|”), Right: Robot rotates 90° clockwise. sendMessage(“D|”), Left: Robot rotates 90° anti-clockwise. sendMesssage(“A|”)
4) Functional GUI that indicates the current status of the robot
A status box displays the current status of the robot. A string will be sent from the RPi via Bluetooth. The different status of the Robot includes: “Exploring”, “Fastest Path”, “Moving Forward”, “Calibrating Corner”, “Turning Left”, “Turning Right”, “Idle”, “Taking Picture”, “Sense All”.
5) Functional GUI to enter Way-point & Robot Start Coordinates
The Robot Start coordinates can be set by first pressing the direction button in the “Map” tab and then assign the direction of the robot, the direction can be set to either “up”, “down”, “left” or “right”.
After that, you can press the “SET STARTPOINT” in the map tab to enable the start point coordinates setup. Next, the toggle will be set and you will be able to set the startpoint coordinates, the coordinate can be set by touching the grid map directly inside or it can be canceled by pressing the cancel button. Similarly, for the waypoint, you have to toggle the “SET WAYPOINT” button and set the coordinates in the grid map. Finally, the startpoint change can be reflected by the green grid, with the arrow direction, while the waypoint can be reflected by the yellow grid in the map.
6) 2D Display of the maze environment and the robot’s location
The map of the arena is virtualized as a 15×20 grid. This map will show the obstacle, waypoint, explored and unexplored block, the current location of the robot and also its directions. The grid type is differentiated by colors as follows:
- Obstacle: Black
- Unexplored: Gray
- Explored: White
- Waypoint: Yellow
- Robot: Green
The grid map will be updated within either movement of the robot or receiving MDF string.
7) Functional GUI that provides the selection of Manual or Auto updating of graphical display of the maze environment
The application has 2 modes available for map display, “MANUAL” and “AUTO” mode. During “MANUAL” mode the map can be manually arranged as needed, and we can control the robot in using the move button manually. We can also manually update the map using “UPDATE” button to receive MDF string which will update the map accordingly.
During “AUTO” mode, the command to move is locked, we will only receive and update the map using MDF string that will be given to us. This “AUTO” mode will be used during either exploration or fastest path.
8) Functional GUI that provides two buttons that supports persistent user reconfigurable string commands to the robot
The Android Application has 2 buttons available for configurable commands, which are F1 and F2. The button values can be set according to the user intention, the value set later will be stored in an android database and will persist even until we restart the application.
9) Robust connectivity with Bluetooth device
Once two devices are connected, the connection between them is robust. The Bluetooth connection ensures that even if the connection is lost or gets hanged in between transmission, the connection can re-establish itself without any extra effort from our end.
10) Display Number ID Blocks in the Grid Map
The Android Application will be able to display the number id in the grid map, given a coordinate x, y, and an id number. The block will be displayed as an obstacle with the number attached in the middle of the block. The commands to display the number id blocks is:
{“image”:[x,y,z]} where x and y are coordinates, and z is the number id.
11) Extension beyond the basics
The Android is equipped with a motion control movement using a tilt sensor. By toggling the tilt under the control button, the robot movement will be changed using the tilt sensor set in the android.