Firefly Chi is designed to be simple to understand, but for students without strong software development skills it may still be daunting. Hopefully this guide will clear some things up. Before you begin, try to read the short summary of this system so you understand what it does and doesn't do.
- Install Firefly Chi
If on linux/macos, install Firefly Chi by going to your favorite projects directory
and running
git clone https://github.com/CURocketEngineering/firefly_chi. If on windows, you will likely like a client like Github Desktop. Setup is straightforward, just install and follow the directions to download this project. - Most basic dependency
For development, you will need a modern version of
Python3.Python3.8and further should work. On windows you can easily install python for free through the system shop. On linux, you'll need to use your package manager. - Further dependencies
The only other dependency you "need" for development is python's
yamlmodule.pip install pyyamlshould take care of it. Depending on what you're testing you can try runningother/setup/setup-test.sh. The rest of the system should print out error messages if a dependency is missing for a plugin, but it should continue working all other systems nonetheless. - Test!
Run
python3 main.pyto start the system. Follow instructions below to modify the configuration file.
For efficiency, the Raspberry Pi should probably run a headless version of Raspbian/Raspberry Pi OS. You can easily follow a guide like this, just make sure to download the headless iso to conserve battery life if used on an actual rocket.
- Install Firefly Chi
Log into the Pi and open a terminal. You can install Firefly Chi via git,
versioning software. If the folder
Documentsdoes not exist, simply create it withmkdir Documents. Navigate insidecd Documentsand install Firefly Chi withgit clone https://github.com/CURocketEngineering/firefly_chi. Navigate insidecd firefly_chiand make sure everything is therels -la. - Install dependencies
The Pi does not come with all of the dependencies needed for the system. To
install these, navigate to the
other/setupdirectory and run the setup-pi script./setup-pi.sh. - Configure the program
The configuration file used to define the system is
config/config.yaml. Modify this file to reflect any changes/desired settings for the flight system. For instance, settingmain_altitude: 1500.0tomain_altitude: 9500.0will make theEJECTstate occur much higher for the second (main) parachute ejection. - Set up autorun
At this point, the Pi needs to start this system when it is first plugged in,
so we don't have to manually turn it on before putting it inside a rocket.
First run
sudo raspi-configand change the settings to allow ssh and immediate boot into user mode. Runsudo rpi-updateandsudo apt upgradeto make sure your software is up to date and will turn on without hdmi plugged in. No create or edit the file/etc/rc.local(using nano, that'ssudo nano /etc/rc.local). Near the end, add the linecd /home/pi/Documents/firefly_chi && sudo -H -u pi /usr/bin/python3 main.py > /dev/null 2>&1 &. This ensures that after the Pi boots, it will enter into our programs folder and run the system with full priveleges as the specified user. For the sake of sanity when you reboot the system and need to use it, all output is ignored. - Test it!
At this point, your system should start when it is plugged in. If this is the
case, you can check the
recordsfolder for flight logs after running it. If developing, you can kill the process just like you'd kill any other.
The core system contains how flight configurations are handled, the state system used to control/define the flight of the rocket, and a system for handling collected data. The plugin system was defined to keep anything unique or dynamic in each flight seperated. If changes/features for actions such as logging, telemetry, flight stabilization, data collection, etc are needed, this should be done in the form of a plugin for the system.
The core system is located in the src/ directory. Information on each file
is here. Each file is written in an object-oriented way
with classes that reflect the names of the file.
Editing the core system should be done very carefully. After any change, make sure to run the system with a simulation configuration in order to make sure everything still operates as expected.
Plugins are found in the plugins directory. Not all plugins are executed when
the system starts. They are executed when the system reaches a state where a
hook is defined. Hooks consist of the state name along with the time of
execution in the format <state_name>_<time>. For example: halt_start,
recover_start, upward_end, and eject_end.
Plugins can be written like any other python file. Simply define a function
inside a new file in plugins that accepts two arguments: conf and dataobj.
For example:
def test_plugin(conf, dataobj):
print("Activating `test_plugin`")
if conf.DEBUG:
print("Current altitude is", dataobj.current_data["sensors"]["alt"])conf is an object instance of the src/Config.py Config class and dataobj
is an object instance of the src/Data.py Data class.
To make the plugin callable, you must edit plugins/__init__.py. First, import
the correct file with something like from . import test_plugin_file.
Second, add the name of the plugin and the function to the plugins dictionary.
For instance, "TestPlugin": test_plugin_file.test_plugin,.
For a plugin to be called, you will need to define the time for a plugin to be
called along with the plugin name inside the current config file
config/config.yaml. A plugins definition could look something like
plugins:
halt_start:
- "FileSimulation"
- "FileLogging"
apogee_end:
- "TestPlugin"
recover_start:
- "TestPlugin"This means that Firefly Chi will execute FileSimulation and FileLogging
at the start of the HALT state (when the system starts). At the end of the
APOGEE state, the system will first call the test_plugin(conf, dataobj)
function. Also, at the start of RECOVER our new plugin will be called a
second time. A plugin can end and exit immediately or continue operating in
the background depending on how its made.
If your new plugin or change to the system required a new python package that
is not part of the standard library, make sure to add the instructions to
any documentation files or edit other/setup/setup-test.sh and
other/setup/setup-pi.sh to reflect the necessary installation of another
dependency.
| Title | Description |
|---|---|
| General | Explanation of avionics. |
| Flight logic | Explanation of flight logic. |
| Setup | Setup procedure. |
| Short Summary | Simple description of project. |
| Hardware Table | Past and current hardware table. |