Mercury Software

Mercury Software
This page gives some helpful tips that worked for us and links to websites that we referenced in building robots for previous years. Until you decide to move away from Raspberry Pis as the main computer for the robot, use Python. It has lots of easy-to-use libraries that make your life a whole lot easier. It also works great on Linux machines, which is what the Pi and basestation computer in the lab run on.

2018-19
This year, we used Python 3.5.3 on the robot and 3.5.2(double-check these numbers) on the basestation.

Software Diagrams
These are some software diagrams created to represent the software. Check github or the following links for the most up-to-date versions. Embedded (Robot) Algorithm

Embedded (Robot) Class Diagram

Mercury Basestation Class Diagram

List of Packages Used
Below is a list of packages used on the robot and basestation, as well as links to the official documentation or helpful websites. They are in no particular order of importance or usage.

Requests - used for passing messages to and from web server: Official site This calls made by this package are blocking, meaning that the program will stall and not do anything until it gets a response from the web server that it calls its method on.

Django - this is what the web server is written in: Official Docs We used Django version 2.1 this year. I used Steps 1 and 2 from the First Steps tutorial on this page when creating the server.

Threading - used to run parts of the code in different user threads: Official Docs We used Thread and Lock from this package to run the code that interacts with the controller and web server alongside the GUI that shows sensor info.

Tkinter - GUI framework: Official Docs We used tkinter as the framework for the GUI that shows sensor information.

Json - simplifies messages passed to and from web server: Official Docs This compresses the messages we need to send to and from the server into a string for us to use easily. Highly recommended if using a web server in the future.

Adafruit_PCA9685 - library that interfaces with our servo driver: Reference page for driver board This library helps us talk to our servos on the robot easier through the Adafruit board.

RPi.GPIO - official library for Raspberry Pi's GPIO pins: Some examples This library helps with interfacing directly with the GPIO pins on the Pi.

Run Python Script on Startup
To run a Python script on startup, type 'sudo nano /etc/rc.local' into a terminal. Before the line containing 'exit 0', put the line you would normally type into the terminal to run the Python command. You will need to put in the absolute file path of the file (/home/pi/Desktop/file.py instead of file.py). IMPORTANT: If your file has an infinite loop, PLEASE PLEASE PLEASE put an ampersand (&) at the end of the line. This will background the process so that you can actually run other things. This also works for shell scripts.

Example: python3 /home/pi/Desktop/updateIP.py &

Save the file by pressing Ctrl+X and then Y. Reboot the Pi to see the changes.