Skip to content
Lauren Greenhill edited this page Oct 1, 2023 · 7 revisions

Welcome to the oop-flight-code wiki!

Code Overview

This code is structured based on Lodestar, a small scale electric demonstrator for the belly-flop and tail-sitting control algorithms necessary for SpaceX's Starship.

Both ClockManager and TimedControlTask are from PAN.

The clang-format file is from this thread.

main.cpp

This file is comparable to a .ino file you would see in the Arduino IDE (notice setup and loop are exactly the same as they would be in an Arduino file).

MainControlLoop

The MainControlLoop initializes and executes every monitor and control task.

MissionManager

The CubeSat has different modes with distinct entrance and exit conditions. MissionManager sets which mode the CubeSat should be in based on these exit/entrance conditions. Please see the Mission Modes page for more details.

SFR

SFR stands for State Field Registry. It contains the mode of each system, all sensor values, and universal flags that should be available to the entire CubeSat.

Control Tasks

Control tasks are any file that actuates/performs a task based on a value in the SFR.

Monitors

Monitors simply read input from sensors and update the sensor values in the SFR.

constants.hpp

Constants contains values that will never be changed. This prevents "magic numbers".

Getting Started

  • Install VSCode
  • Install Git
    • Make a GitHub account if you do not have one already
  • In VSCode, click on "Extensions" on the left hand toolbar. Search for and install PlatformIO IDE.
  • On the top toolbar, click "Terminal" and then "New Terminal". This should open a terminal at the bottom of your screen if it was not open already.
  • In the terminal, type "git clone https://github.com/Alpha-CubeSat/oop-flight-code.git"
  • Now at the bottom of your screen in the blue toolbar you should see a check, arrow, and serial monitor icon (it looks like an electrical cord). If you do not see the blue toolbar make sure you have the cloned git repo folder open.
  • If you would just like to compile code but not upload to the teensy, press the check.
  • If you would like to upload to the teensy, press the arrow.
  • You can also use pio run -e debug -t upload to upload code with debugging print statements, or pio run -e teensy35 -t upload to upload code without debugging print statements.
  • Use pio test to run unit tests.
  • To view the serial monitor press the electrical cord icon.
  • Navigate to View -> Command Palette
  • Search "settings" and select Preferences: Open Settings (JSON)
  • Enter the following in the settings JSON and save

{ "C_Cpp.clang_format_style": "file", "editor.formatOnSave": true, }

  • If the autoformat github action fails upon push, run clang-format -i ./src/*.cpp ./src/*.hpp ./src/**/*.cpp ./src/**/*.hpp in terminal to manually autoformat the source files and retry pushing the code

FAQ:

Q: What should I do if VSCode says, "Found Device But Unable to Read."

A: You should mount the 00-teensy.rules to the /etc/udev/rules.d Ubuntu directory.

  • You can either ask someone on the team for the file or go to this link to download the file: http://www.pjrc.com/teensy/00-teensy.rules.

  • use command sudo mv ~/Downloads/00-teensy.rules /etc/udev/rules.d.

  • After that, restart the machine.

Q: What should I do if I am getting an error on test files that use the line #include "unity.h"?

A: Go to the platformio.ini file, and make sure that includes the line lib_deps = throwtheswitch/Unity@^2.5.2 under [env:debug].

Q: What should I do if Platformio says "PlatformIO: Can not find working Python 3.6+ Interpreter. Please install the latest Python 3 and restart VSCode"?

A: sudo apt install python3-venv

Clone this wiki locally