Welcome to the PiE Runtime repo! This README will only cover how to install, build, and run Runtime. If you want to learn more info about how Runtime works, or are a new member, please check out our wiki https://github.com/pioneers/runtime/wiki.
This is a diagram of the entirety of Runtime. To download and view in detail, see runtime-docs/Runtime-Diagram.png
:
Runtime can be divided into a few neatly containerized parts:
net_handler
, this is a process in Runtime, and is responsible for all communication between the Raspberry Pi and Dawn, and between the Raspberry Pi and Shepherd.dev_handler
, this is a process in Runtime, and is responsible for all communication between the Raspberry Pi and all the devices that are attached to the robot at any given time.shm_wrapper
, this is the tool that facilitates the efficient communication between the above three processes. Think of this wrapper as the "glue" that holds the three processes together, and lets them talk to each other.lowcar
" 1 this is the set of all the code on the Arduinos that directly control an individual device that is connected to the robot. All of this code is collectively called the "lowcar library".lowcar
devices.lowcar
devices. All of them are called by the runtime
script in the root directory.In addition to these parts, there are a number of configuration files for Runtime to manage the various tools that we use. They are listed here, with a brief explanation about what they do:
.gitignore
: this file lists out all of the directories and files that we don't want in our Git repository. This includes things like executables, build files, and .DS_Store
..gitattributes
: this file is purely for aesthetic purposes. It tells Github which files to exclude when calculating the repository language makeup you see in the repo (below the "Contributors" section in the sidebar on the web page that you're probably looking at right now)..github/workflows/pull_request_ci.yml
: this file outlines the steps taken by the Github Action that we use to test our code before we release Runtime. See our most recent CI builds here!runtime
: this file is a convenience shell script that makes it easy to call the various other shell scripts in our directory, which you will read more about later.This README will not go into each of these parts into exhaustive detail; explanations for each part can be found in the corresponding folder's README in the repo as well as our wiki.
Runtime is designed to be used on the Raspberry Pi, and with a distribution of Linux called Raspbian, a slight variant of the extremely popular Debian. We tested Runtime to work well on Linux systems. Only some parts of Runtime work on macOS and may require different commands to compile; no parts of Runtime can operate on Windows. Please use a Linux machine or (preferably) a Raspberry Pi to run Runtime!
As a baseline, Runtime uses the following commonly used tools that should already be installed on your machine (if you don't have these, ask the Runtime Project Manager to help you install them):
gcc
: short for "GNU C Compiler", we use this compiler to generate executables from C source code.Runtime has the following third-party library dependencies:
Cython
: this library is used by executor
to implement the Student API in a way that is both callable from Runtime (which is written in C) and from student code (which is written in Python)
protobuf
and protobuf-c
: Google protobuf
is the library that we use to serialize our messages between Runtime and Shepherd, and Runtime and Dawn.
sudo apt-get -y install python3-dev
(get <Python.h>
, libpython3.7m.so
)sudo apt-get -y install python3-pip
(get pip
)python3 -m pip install Cython
(get Cython
using pip
)protobuf-c
From https://github.com/protobuf-c/protobuf-c/releases
download version 1.4.1, i.e. protobuf-c-1.4.1.tar.gz
and extract it (for help, click here)
You may need to install some tools (libtool
, pkg-config
, g++
). To install a tool you don't have, run sudo apt-get -y install <tool-name>
, replace <tool-name>
with what you want to install.
To install Google Protobuf, run:
sudo apt-get -y install protobuf-compiler
sudo apt-get -y install libprotoc-dev
To install protobuf-c
, first cd
into the folder for protobuf-c-<release>.tar.gz
and run:
./configure
make
sudo make install
sudo ldconfig
(optional) To view protobuf-c
documentation:
doxygen
: sudo apt-get -y install doxygen
protobuf-c
directory, then do make html
html/index.html
file by double clicking on ittar
file from the command line First, download the tar archive into your current working directory with
wget https://github.com/protocolbuffers/protobuf/releases/download/<release>.tar.gz
Then, extract the files with
tar -xzf protobuf-cpp-<release>.tar.gz
You might need to install wget
and tar
with sudo apt-get -y install wget tar
.
ncurses
for Shared Memory UIThe Shared Memory UI allows the user to have a real-time view of data flowing in and out of shared memory. This is analogous to the "shm_cli
" among dev_handler_cli
, executor_cli
, and net_handler_cli
. Note that the UI is used in development only as a debugging tool and should not be used in production. The command below will install ncurses
on Linux machines:
sudo apt-get -y install libncurses5-dev libncursesw5-dev
Clang Format is used to format code to comply with our code style. Code that is not formatted with Clang cannot be merged into master
. After installing, use the runtime script to format code. (See runtime format
)
sudo apt-get -y install clang-format
We use the bash script runtime
in this root directory as the entrypoint to our code. You can call it with ./runtime <args>
in this folder. However, you can also have it be callable from any directory by adding it to your PATH
variable. This can be done automatically adding the following line to your ~/.bashrc
file:
export PATH="$PATH:<path to runtime folder>"
Then either close and reopen the terminal, or do source ~/.bashrc
.
If you now type runtime
it will list all the possible subcommands you can run. We currently have
build
: will build the code baserun
: will run Runtime like how it will on the Raspberry Pi robotstest
: will run our test suiteformat
: will format your code to match our styleflash
: will flash an Arduino as a Lowcar deviceclean
: will remove all artifacts generated when building or running Runtimeupdate
: waits for new runtime.zip
to appear in /tmp
and then will unzip it and reboot the robotstatus
: will display the currently running processes under the ubuntu
user (to list active Runtime processes)The first version of runtime
in C was written in the summer of 2020 (when we all had lots of time.... fuck covid and trump) nearly entirely by:
Some inspiration and design was drawn from previous iterations of Runtime and Lowcar, written mostly by:
1: This name has an interesting origin. The code for the devices used to be in a completely separate PiE project called "Hibike" (pronounced HEE-bee-kay). Some members of Hibike who wrote much of the original Arduino code were avid fans of anime. So, they named the project Hibike after the anime "Hibike! Yufoniamu" (Sound! Euphonium). Later, some members who were not such avid fans of anime decided to pronounce "Hibike" as "HAI-bike", which sounds like the two English words "High Bike". Later still, when members decided to refactor the code to be more object-oriented, it was decided that a new name was needed for the project. Ben Liao coined the name "Low Car" as wordplay on "High Bike", and the name stuck. ↩