Skip to content

Latest commit

 

History

History
292 lines (224 loc) · 14.1 KB

README.md

File metadata and controls

292 lines (224 loc) · 14.1 KB

pipeline status


taproot-template-project

This is a blank project fully configured for use of Taproot. It is designed to be a starting point for your own RoboMaster software projects. Be sure to check out Taproot for more information.

This template includes the following:

  • Code generated from the taproot and modm repositories. This generated code is located in /template-project/taproot and includes the hardware abstraction layer provided by modm as well as Taproot library code that sits on top of modm.

    See here for more information on code generation.

  • A .vscode folder with C++ configurations for developing in a simulated, test, and hardware environment. This also includes convenient VS Code tasks for building code and debug launch configuration for debugging the simulated, test, or hardware environment.

  • A Doxygen document generation configuration that renders a documentation webpage sourced from commented code.

  • Various linting scripts that are used for maintaining high quality source code.

  • A clang format configuration (see .clang-format). This should be configured based on user preferences.

  • Build scripts supporting configurable target profiles, including environment (simulator, tests, hardware) and robot type (Standard, Hero, etc.).

  • A basic GitLab Continuous Integration (CI) Pipeline that lints the source code, builds all targets, and runs your tests (see .gitlab-ci.yml).

  • Instructions and a configuration file for deploying your software to hardware via the command line.

Usage of the template

This project is provided to reduce the configuration overhead when adopting Taproot. We recommend creating a new blank GitLab project and pushing the history of this repository there. This will be similar to a fork, but omit the "forked from..." badge, which you likely don't want.

Assuming your new project is at https://gitlab.com/my-team/my-amazing-project, the setup process is as follows:

git clone --recursive https://gitlab.com/my-team/my-amazing-project.git
cd my-amazing-project
git remote add template https://gitlab.com/aruw/controls/taproot-template-project.git
git pull template develop
# replace "main" with your main branch name of choice
git push --set-upstream origin main

If you visit the project's GitLab page, starter files should be present and GitLab will likely have kicked off a Continuous Integration (CI) Pipeline, indicated by the blue "waiting" icon or a green "checkmark".

Configuring your new project

By using this template, your project will start out with a fully-functional Taproot instance and build tools. The provided main.cpp (/template-project/src/main.cpp) includes initialization of all core systems and drivers. This should allow you to develop control systems starting day one.

To automatically configure your project, you should run the python script rename_template_project.py. This script takes a couple arguments, the name of your repository (for example, aruw-mcb) and the name of your team (used for updating copyright headers). This script will rename the project for you with the given name. Once you have run this script, you may delete it.

To refer to your own team, year and email. Do so in all template source files, excluding files in **/taproot. Also update scripts/check_license_headers.py accordingly.

A note on copyright headers: The above suggestions regarding copyright headers are purely for your convenience. You are free to decide how you would like to manage these, including omitting the license headers entirely if preferred, so long as you abide by the original license terms of the files. You may opt to disable the automated license header check; do so by removing the below line from .gitlab-ci.yml:

    - python3 ./scripts/check_license_headers.py

To start developing software, place your source code in /template-project/src and your tests in /template-project/test. See the workflow guide for how to build, test, and deploy your code.

Finally, after you are done with it, we recommend removing the portion of this README between <!-- ... --> comments. The rest of the file is intended to provide a starting point for your team.

(Optional) Using the RoboMaster Development Board Type C

By default, this project targets the RoboMaster Development Board Type A. However, Taproot also supports the newer Type C board. If you would like to use this board instead (replace template-project with the new name if it has been renamed):

  1. Commit any work so you don't lose it
  2. Edit template-project/project.xml according to the included comment
  3. Run rm -r template-project/taproot
  4. Run cd template-project and then lbuild build
  5. Commit the result: git add . && git commit -m "Target RM Dev Board Type C"

Contacting

If you have any questions please contact us at [email protected].

Licensing

taproot-template-project is covered under the GPL-3.0-or-later with the following exceptions:

  • /taproot/modm and /template-project/taproot/modm are licensed under MPL 2.0 by the modm project. We are not the license holder for these files. See /modm/LICENSE for license information.
  • /template-project/taproot/src/taproot/algorithms/MahonyAHRS.h and /template-project/taproot/src/taproot/algorithms/MahonyAHRS.cpp are licensed under the GPL by SOH Madgwick. The repo containing this code can be found here.

Other RoboMaster teams are invited, and encouraged, to utilize this library. We have licensed this template project and Taproot under the GPL to encourage collaboration and open publishing of RoboMaster controls codebases. We politely request that other teams choosing to utilize this library, or parts of it (including its design), open-source their own code in turn.


Resources

New user guide

Setting up a development environment

If you want the easiest setup experience and do not require deploying code to hardware, consider developing within the provided Docker container.

Otherwise, follow the guide appropriate for your operating system.

Finally, install pipenv and set up the build tools:

pip3 install pipenv
cd template-project/
pipenv install

Getting started with this repo

Make sure you have followed the above setup instructions.

Run the following to clone this repository:

git clone --recursive https://gitlab.com/my-team/my-amazing-project.git

If you use the Docker container, or have already cloned the repository yourself, you should instead run:

git submodule update --init --recursive

Now, cd into the project directory, activate the virtualenv, and run some builds:

cd my-amazing-project/template-project
pipenv shell
# Build for hardware
scons build
# Run automated tests
scons run-tests

Returning to the development environment

You will need to run pipenv shell from this directory every time you open a new terminal, before using scons or lbuild.

Workflow guide

Getting around VSCode

Microsoft provides a helpful website with a number of shortcuts for getting around VSCode. There are many shortcuts that make programming faster.

Building code and programming the RoboMaster Development Board

If you would like to use the terminal instead, see the section "Building and running via the terminal" below.

  1. Make sure you have VSCode opened in the folder taproot-template-project (not template-project)
  2. Connect an ST-Link to the RoboMaster Development Board and your computer.
  3. In VSCode, open the Command Palette (Ctrl+shift+P)
  4. Find Tasks: Run Task. You should see the options below. Select Program - Debug or Program - Release.

Debugging with an ST-Link

  1. Open the folder aruw-template-project in VSCode. Hit the debug tab on the left side or type Ctrl+shift+D.
  2. Hit the green play arrow on the left top of the screen.
  3. See this page for more information about using the ST-Link for programming the MCB and debugging.

Debugging with a J-Link

See the wiki for an explanation on the difference between an ST-Link and J-Link and a step-by-step procedure on how to use the J-Link.

Selecting and using robot types

Specify the robot type via the command line when compiling (see below). For vscode IntelliSense, navigate to /template-project/robot-type/robot_type.hpp and change the macro defined in this file.

Each robot is signified by a unique macro which can be checked to special-case code:

#if defined(TARGET_STANDARD)
// Only included if building for the Standard
initializeStandard();
#endif

How to select an appropriate VSCode C/C++ configuration

This codebase has a number of different build targets (see this wiki page for more information). Because the build setup is different for the test, sim, and RoboMaster Development Board (aka MCB) environments, while working on a particular portion of code you may select an appropriate profile that provides optimal intellisense. To select a configuration, in VSCode, type Ctrl+Shift+P, then type "C/C++:Select a Configuration" and hit enter. A dropdown menu will appear where you may choose either the "Test", "Sim", or "Hardware" configuration.

Upgrading Taproot

The Taproot project recommends that user projects occasionally upgrade the version of Taproot that they depend on. The guide for doing so is here.

Building and running via the terminal

The below commands require that your working directory is /template-project (where the SConstruct and project.xml files are).

  • lbuild build: Re-generates out copy of taproot and modm.
  • scons build: Builds the firmware image for the hardware target. Creates a "release" folder located in build/hardware/ which contains the final .elf file as well as the intermediate object files (.o).
  • scons build-tests: Builds a program which hosts our unit tests. This executable can be run on your host computer (only supported on Linux) and prints results for each unit test run.
  • scons run: Builds as with scons build and then programs the board.
  • scons run-tests: Builds and runs the unit test program.
  • scons size: Prints statistics on program size and (statically-)allocated memory. Note that the reported available heap space is an upper bound, and this tool has no way of knowing about the real size of dynamic allocations.

Below is the full usage statement from our scons build environment. Note that you can select the robot, profile, or whether or not you want profiling to be on using the various options.

Usage: scons <target> [profile=<debug|release|fast>] [robot=TARGET_<ROBOT_TYPE>] [profiling=<true|false>]
    "<target>" is one of:
        - "build": build all code for the hardware platform.
        - "run": build all code for the hardware platform, and deploy it to the board via a connected ST-Link.
        - "build-tests": build core code and tests for the current host platform.
        - "run-tests": build core code and tests for the current host platform, and execute them locally with the test runner.
        - "run-tests-gcov": builds core code and tests, executes them locally, and captures and prints code coverage information
        - "build-sim": build all code for the simulated environment, for the current host platform.
        - "run-sim": build all code for the simulated environment, for the current host platform, and execute the simulator locally.
    "TARGET_<ROBOT_TYPE>" is an optional argument that can override whatever robot type has been specified in robot_type.hpp.
        - <ROBOT_TYPE> must be one of the following:
            - STANDARD, DRONE, ENGINEER, SENTRY, HERO: