Skip to content

Project Structure

Files and Organization

Each ArPiRobot program has a file arpirobot-proj.json. This file is used by the deploy tool to determine which files to deploy to the robot. While the contents of this file will differ based on the programming language used, this file will be present for a project using any language. Typically, this file does not need to be edited.

Additionally, there is a main.sh file that defines how the robot should run the program once it is deployed. This file should almost never be edited and is present for any language (again, its contents depend on the language).

The other files present in the project depend on the language used by the project.

A python project is very simple and includes only source files. These are located in a directory named src. By default a project will have three source files robot.py, actions.py, and main.py. main.py generally should not be edited as it determines what to do when the program is run. The use of the other two files is described in more detail below.

A C++ project includes more than just source files.

In addition to the code of the project, files for the cmake build system are included. This is mainly just CMakeLists.txt which defines how to compile the robot program. Additionally, there is a file named arpirobot-cross.cmake which is used to help cmake fine the cross compiler for the raspberry pi. Neither of these files should generally be edited.

Aside from the build system there are two folders: include and src. The include folder contains header files and src contains source files. Headers are .hpp files and sources are .cpp files. There is a source and header file for each of main, robot and actions. Their uses are detail in more detail below.

Manually Creating a Project

If you are not using VSCode you can still create a project. It is recommended to duplicate the structure of the projects generated by the VSCode extension. This can be done by downloading / referencing the templates used by the extension located here

Use of Each Source File

By default, a project has three source files (and also three corresponding headers in a C++ project).

Main

The main source file is used to start the robot program defined by the other source files when the program is run. This file should generally not be edited.

The robot source file contains the Robot class definition. This class is a child class of BaseRobot and defines the core behavior of the robot program, as well as the components that make up the robot. Any device instances should be created in the Robot class.

The actions source file is generally used to define custom actions (classes that inherit from Action). Typically, any action used in a robot program is defined in this source file. Actions use the devices in the Robot class and the Robot class controls which action(s) run at any given time.