Skip to content
CalumWest edited this page Apr 16, 2018 · 12 revisions

Overview

The GUI for the BowlsEye system has been designed using Python. In order to run the program you must also have the PyQt, Time and PyBluez libraries installed.

Operation

  1. From terminal run python3 main.py
  2. Perform a scan using the 'Device Search' button and select the appropriate device from the drop-down menu below
  3. Establish a Bluetooth link with the Raspberry Pi using the 'Connect' button
  4. Ensure the scanning parameters are set as required
  5. Press 'Start Scan' and the BowlsEye should begin to move!
  6. The circular display will update as the distances are measured
  7. Once the scan is complete clicking on a point on the display will show the measure distance and angle in the dialog boxes below
  8. If required scan data may be written to disc by pressing 'Save'
  9. To perform another scan press 'Start Scan'

Alternative Text

Structure

The GUI program consists of a set of PyQt objects with customised methods. Code for handling of communication with the pi is contained in comm.py whilst code for display of received data is stored in rx_display.py. When first run the graphic display is initialised, which will show the widgets for Bluetooth connection, user input and data display. There is also a QTextEdit object to provide communication with the user.

'Device Search' will intialise a thread to scan the area for Bluetooth devices which will then be passed to a QComboBox object. 'Connect' will start a thread creating a Bluetooth client to begin sending data to the Raspberry Pi at the selected Bluetooth address, which will close after successful completion. This thread will automatically attempt to connect for a maximum of 10 times before ending the thread with an unsuccessful connection. Successful connection will initiate a thread which creates a Bluetooth client and begins listening for received distance data.

User parameters to define the ADC sample rate, motor step size and maximum distance measure are stored in QComboBox objects. When the 'Start' button is pressed, this data is packed into a single CSV string along with a '1' start byte and sent immediately to the RPi which begins the scanning process.

Data is received as a single string consisting of distance and angle data. This is parsed using Python list indexing and stored in a buffer within the display object. Once the data is stored the 'repaint' method of the display window is called, which updates the circular data display to show the reflection data at the correct distance and angle from the centre of the circle. Use of a QLineF allows the plotting of points from a defined centre point using this data alone. The circular data display window will maintain a consistently square aspect ratio for accurate display as the widget size is used to update a QRect object which acts as a reference for the rest of the display. The latency between reception of Bluetooth data and GUI display is neglible. Once a 'complete' message is received then the closest calculated distance is displayed on the plot in red.

Clone this wiki locally