This repository contains the final version of the flight fsm used at the Mach25 competition. The software is inspired by the FSM used by the endeavour software team, following similar logic and state transition triggers. Note that the number of states required for payload is reduced compared to the main rocket FSM due to the variation in complexity at each stage.
For ground station software, please refer to the /ground_station folder in the mach25 cansat repo: https://github.com/Janvdk5/mach25-cansat. NOTE: this ground station software may be outdated. Check with @Dom
NOTE: please branch off main if you wish to make versions for upcoming launches to maintain the record of the Mach25 version.
- '/bno055' contains the library for the BNO055 IMU. This includes a specific ReadMe with installation instructions and code explanations. Please refer to that for more information.
- '/states' contains the different states of the FSM as separate files. Each file contains the code for that specific state. NOTE: State transitions after lift off detection are overlapped with hardcoded time delays. This was done to reduce risk of rover activation inside the rocket. You may wish to remove this for future launches.
- 'subsystems.py' contains the code for the different subsystems of the rover. This includes the buzzer, rover and sampling system. Note that the piezo ML code is not included here due to this software being implemented on seperate hardware within the CanSat. Refer to subsytem ReadMe's for more information.
- 'constants.py' contains the constants used throughout the code. This currently only locates the FSM states.
- 'fsm.py' contains the main FSM code. This includes simply the loop that runs the current state and transitions between states. It also includes specific state transition trigger thresholds.
- 'startscript.sh' is the script that runs on startup of the Raspberry Pi. This simply runs the fsm.py code but note that it is depricated currently.
- 'transmit.py' contains the code for transmitting data via the LoRa module.
- 'requirements.txt' contains the required libraries for the code to run. Use pip to install these.
- Set up raspi and connect to it via ssh. Refer here for more info: https://www.notion.so/Electronics-Help-1a19e217370880fca59beeeba6c9b726
- Clone this repository
- Follow instructions in the BNO055 folder to install the BNO055 library.
- Create virtual environment.
python3 -m venv venv - Activate the venv.
source venv/bin/activate - Install required libraries via pip:
pip install -r requirements.txt - Follow prompts to clear any remaining issues.
- ssh into payload@cansat.local, password rover.
- cd to Documents
- Activate the venv:
source venv/bin/activate - Activate GPS socket with gpsd command:
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock - Start the FSM implementation:
nohup python fsm.py > fsm_stdout.log 2> fsm_stderr.log &- The
nohupcommand allows the process to continue running after logging out or losing ssh connection. - The
&at the end runs the process in the background, allowing you to continue using the terminal if needed. - The fsm_stdout.log and fsm_stderr.log files will contain the standard output and error messages respectively to allow fsm verification
- The
- Verify operation by checking the fsm_stdout.log file:
tail -f fsm_stdout.log
- If BNO055 fails to initialize, check connections and ensure I2C is enabled on the raspi.
- If LoRa fails to initialize, ensure only 1 SPI device is connected.
- If SSH fails to see the MC, double check there’s not other hotspots active before starting
- See Issues for future improvements.
- Startup sequence is not set up with systemd to run on boot on current hardware. Follow the sequence above and verify with buzzer beeps.