fprime-python provides an autocoder for automatically binding F Prime C++ code to Python. It is designed to work within the Python interpreter allowing access to standard F Prime components and topologies.
fprime-python-reference (this repository) provides a reference project that builds on top of fprime-python.
The fprime-python-reference repository includes example components that demonstrate how to implement F Prime components in Python. These components are located in the FprimePythonReference/Components directory and include:
- ActiveImager: An
activecomponent that uses Python and OpenCV to capture/downlink camera images - PythonGc: A
queuedcomponent that demonstrates how to telemeter Garbage Collection information - PythonTcpCom: A
passivecomponent that implements a communication interface using TCP sockets
Caution
This reference will use your system's camera.
Note
The fprime-python rate group driver is also used in this reference.
First, clone the project using fprime-bootstrap, which will ensure that requirements.txt is properly installed:
pip install -U fprime-bootstrap
fprime-bootstrap clone https://github.com/fprime-community/fprime-python-reference.gitNext, source the environment created by fprime-bootstrap and build/run as usual:
. fprime-venv/bin/activate
fprime-util generate
fprime-util buildNote
The build for fprime-python projects is slower than a C++ build as it also autocodes and compiles the Python bindings.
The build installs the fprime_py extension module and every Python file of the deployment to build-artifacts/python. Python files are reinstalled by every fprime-util build.
The flight software runs inside a Python interpreter, so it is started separately from the GDS. The reference's communication component, PythonTcpCom, listens for a TCP connection; the GDS must therefore connect as a client.
First, run the GDS in the root of the project:
. fprime-venv/bin/activate
fprime-gds --ip-clientNote
fprime-gds.yml sets --no-app, which starts the GDS without running an executable.
Next, in a second terminal, run the flight software with the same Python that built it:
. fprime-venv/bin/activate
python3 build-artifacts/python/fsw_main.pyfprime-python-runner does the same from any directory of the project. --hostname and --port set the address PythonTcpCom listens on (default 127.0.0.1:50000); give the GDS the matching --ip-address and --ip-port.
With the GDS and the flight software running, run the integration tests from the root of the project:
pytest test/int --dictionary build-artifacts/*/FprimePythonReference_ReferenceDeployment/dict/ReferenceDeploymentTopologyDictionary.json