Skip to content

Development Quick Start

jacobterkuc edited this page Nov 6, 2023 · 9 revisions

Required Software

Install Git, Python, and a Text Editor on your System

Before getting to running the ground station back end, you need to set up a few tools. To begin, set up Git, Python, and some sort of IDE/Text editor.

Windows

The first step is to download and set up Git. There are a few options, but here are a few resources to get started...

Git Bash is a quick and easy way to get Git running on Windows. It is a good option if you are planning on developing on Windows

VirtualBox is the most consistent way I've found to install Git, as well as the rest of the software that's needed to run both the ground station Python script, along with the UI. The documentation is written for Ubuntu specifically, but feel free to use whatever distro you are comfortable with.

If you are going this route, feel free to follow the Linux section of the guide.

Windows Subsystem for Linux was what I assumed would be the easiest way to get everything set up, but it was causing a number of problems for people trying to get the UI running. Use at your own risk.

If you are using Git Bash or Pycharm, you're going to have to set up Python for Windows. If you are using any of the other options, follow the steps in the Linux subsection. Follow the steps on the website to install Python and Pip.

Text Editors

VSCode is a great option for a flexible, easy to use text editor. There are a bunch of plugins you can download to make it easier to use. Play around with it a bit and see if you like it.

Sublime Text is a text editor for Windows. It has a perpetual free period, so you don't have to pay for it if you are already a long time WinRAR user.

Pycharm is an IDE for Python from JetBrains, it has lots of quality-of-life features, including Git version management. This is probably the easiest way to get it set up, but if you want to challenge yourself, try some of the other suggestions.

You can get Pycharm Professional and all the other Jetbrains software for free as a student. Go here to learn more.

Linux

It's a bit simpler to install Git on a linux system thanks to package managers. These install steps are specific to Ubuntu/Debian based distros, but the steps are relatively similar regardless of what linux distro you're using.

Before doing anything, make sure apt-get and your packages are all up to date. Run the following commands in your terminal application to do that.

sudo apt-get update && sudo apt-get upgrade

Once you are able to enter commands again, enter the following commands to install everything you need for the ground station.

sudo apt-get install git python3.11

If you get errors, or have trouble installing it, message in the Avionics Discord

Text Editors

There are lots of GUI and TUI based options for Linux, here are a few recommendations:

NeoVim is a very flexible and fast text-based text editor. You can install it with sudo apt-get install neovim. Note that to exit you press the esc key and type :q!.

Nano is another text based text editor. Install it with sudo apt-get install nano in the terminal.

VSCode is a great option if you aren't comfortable using the terminal, or just prefer using a GUI based text editors. There are a bunch of plugins you can download to make it easier to use. Play around with it a bit and see if you like it.

Pycharm is an IDE for Python from JetBrains, it has lots of quality-of-life features, including Git version management. This is probably the easiest way to get it set up, but if you want to challenge yourself, try some of the other suggestions.

You can get Pycharm Professional and all the other Jetbrains software for free as a student. Go here to learn more.

Mac

If you are using a Mac, you can install Git and Python directly from the command line. Follow these steps to get everything set up on your system.

Brew is a Package Manager made specifically for MacOS, since there is none installed by default. To install Brew, either follow the instructions on the website, or copy and paste the following command into the Terminal application:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This command automatically installs Brew, and once it's finished you can use the brew command. Type brew install python@3.11, and brew install git to install Python and Git.

Text Editors

There are lots of GUI and TUI based options for Linux, here are a few recommendations:

Pycharm is an IDE for Python from JetBrains, it has lots of quality-of-life features, including Git version management. This is probably the easiest way to get it set up, but if you want to challenge yourself, try some of the other suggestions.

You can get Pycharm Professional and all the other Jetbrains software for free as a student. Go here to learn more.

Sublime Text is a text editor for Windows. It has a perpetual free period, so you don't have to pay for it if you are already a long time WinRAR user.

NeoVim is a very flexible and fast text-based text editor. You can install it with sudo apt-get install neovim. Note that to exit you press the esc key and type :q!.

Nano is another text based text editor. I don't use it but you can if you want. Install it with sudo apt-get install nano in the terminal.

VSCode is a great option if you aren't comfortable using the terminal, or just prefer using a GUI based text editors. There are a bunch of plugins you can download to make it easier to use. Play around with it a bit and see if you like it.

Development Environment Setup

Now that you have your system set up properly, now you need to set up your development environment.

  1. Clone the ground-station repository to your computer. Copy and paste the following command into your terminal: git clone /~https://github.com/CarletonURocketry/ground-station.git. This command takes all the files from the repository and puts them in a folder named ground-station in the current working directory you are in.
  2. Navigate to the new ground-station folder with the cd ground-station command.
  3. Activate the virtual environment (venv).
    • Install venv with the command pip install venv if you don't have venv already installed.
    • Run python3 -m venv venv(for Linux and Mac) or py -m venv venv(for Windows) to create a new venv in the current directory.
    • Enter the venv\Scripts\activate.bat command (Windows) or the source ./venv/scripts/activate command (Linux or Mac) to activate the virtual environment.
  4. Install the project dependencies using the pip install -r requirements.txt command. After running, you should have all the necessary dependencies installed.

You should now have your Python environment fully set up. Note that you need to make sure that the venv is active in order to run the program.

Using the Virtual Environment in your IDE

You can also link your editor to use the virtual environment when developing on this project:

  • VSCode
  • PyCharm
  • Neovim: Follow the terminal steps to activate your venv, and then run nvim once the environment is active.

Running the Code

Windows

Enter the py main.py command in the ground-station directory.

Linux/Mac

Enter the python3 main.py command in the ground-station directory.

Contributing Code

In order to contribute code to this project, you will need to read through the contribution guidelines.

Workflows

Flake8

Flake8 is a Python linter that checks for unused variables, imports, good code style, etc. Flake8 should already be installed on your machine in the repository's virtual environment, as it's included in the requirements.txt file.

In order to run Flake8 linting in your branch/fork before making a PR, you will need to open the repository directory in your terminal with the virtual environment activated. Then simply execute the command flake8 .. If this doesn't work, you can also try python -m flake8 ..

Black

Black is an opinionated code formatter that is used to keep the codebase nicely formatted in one consistent style. It is also in requirements.txt and should be installed in your virtual environment.

In order to run black and format your code, you can open the repository directory in your terminal, activate your virtual environment and run black .. If that does not work, you can alternatively run py -m black .. It is recommended you install a Black formatter plugin for your IDE (or otherwise configure your IDE to run Black on save) to save you time.

Pyright

Pyright is a static type checker for Python. Since Python is a dynamically typed language (variables do not need to know their types until the program is run), many type errors can arise from not knowing the type of function parameters, variables or class members.

This repository uses strict Pyright rules to ensure that no type errors are possible before the code is run. Pyright also enforces some other small nuances, like not changing constant variables (variables in ALL CAPS), ensuring the first parameter to class methods is named 'cls', etc.

In order to run Pyright on your changes, you can open the repository directory in your terminal, activate your virtual environment and run pyright .. Alternatively, you can run py -m pyright .. You may need to install Node.js for Pyright to work as expected, since it's a JavaScript application.

Pytest

Pytest is a testing library for Python that allows us to write low-boilerplate tests for our project's code. In order for a pull request to be merged, all tests must pass. You are also expected to write additional tests if your PR will add an additional feature/additional functionality.

In order to ensure that all tests are passing before opening a pull request, you should open the project directory in your terminal, activate the virtual environment and run pytest. If that doesn't work, run py -m pytest. You should see full passes in the test results/console output.

If not all tests are passing, look at the errors that occurred and see if you can determine what changes caused the test to fail. You should resolve all errors to get a full pass before opening a pull request (unless there is some exceptional scenario where a test is deprecated, etc., in which case you can remove the test).

Verify Serial Connection

If you are having trouble with the ground station connecting to your system, the first thing to check is the connection between your computer and the ground station hardware.

Windows Instructions

In Windows, you can check if the two devices are communicating by going to Device Manager. Next, click the arrow next to the Ports (COM & LPT) dropdown.

Linux/Mac Instructions

In Linux and Mac, new serial connections appear in the /dev directory. Use the ls /dev command to view.