Overall introduction

The new structure of our projects are using PROS as the structure, which allows us to make a deeper customize.

RTOS

Because of the real-time needs, multithreading will be used. In embedded systems, this is usually called RTOS(Real Time Operation System). If you are interested in that, you can take a look at FreeRTOS or ThreadX.

FreeRTOS is a lite, open-sourced and easy-to-use RTOS widely used in many robotic labs/teams/companies.

ThreadX belongs to Microsoft, and is a more industrialised RTOS. One of the benefits is that ThreadX support multi-core, while FreeRTOS can only supply single-core.

And the PROS uses the FreeRTOS as the RTOS.

BUT, don't worry about that, these are just background knowledge, usually, you do not need to learn more about that.

Tasks

In PROS, there is a thing called "task". 

You can regard them as: all of the tasks are working at the same time. (Sounds like listening to music while doing homework while playing computer games while eating hamburgers

Detailed usages you can find in PROS documents, here are some tips:

  1. what is initial: usually we will do initials at the start of the task, which includes syncing the data from sensors, setting params for motors/servos, getting the pointer of other devices(such as motor/controller).. and other things you need to prepare.
  2. why use a `while(true)` loop: all of the tasks will be executed at the same time, but they will only be executed once. So if we want to let these tasks continue working, we can use `while(1)`.( What a capitalist
  3. how to transfer messages between tasks: many methods are allowed, such as semaphores, share memories, and so on. In our project, we mainly use pointers. We know that in processor, each code piece, including variables and functions, are stored in a place of memory. In C++, pointers are the addresses of variables and functions in memory. So if we transfer the pointers, we transfer the variables. The benefit is that, pointers usually have a smaller size than variables, so transfering pointers is much more qiucker and easier than transfering variables.

File structure

Basically, you just need to focus on "include" folder and "src" folder.

The head files(.hpp) are stored in "include/dku", while the source code filed are stored in "src/dku" folder.

Usually, we do not change the apis of PROS, which means usually you only need to edit the file under "dku" folders, "main.cpp" and "main.hpp". If you want to edit other files, please connect code reviewers(Tianyi and Yihe).

Code Structure

The code is devided in to "layers".

TODO:

  1. Learn and use new features of C++. Currently PROS suppurt C++11(maybe), and we need to transfer some codes to new features to let project more stable and faster
  2. More sensors and algorithms 
  3. More effective way to transfer signals between tasks. And use task notify to detailed control task lifecircle
  4. deeper decoupling the code in auto stage and the opcontrol stage(the code can only be used this season and can be used in next seasons)