# Getting started

***This page:** *structure of this subsystem and where to find what.**

<p class="callout success">**Make sure you understand the embedded structure:**<span style="white-space: pre-wrap;"> </span>[Embedded Infastructure](https://bookstack.roboteamtwente.nl/books/embedded-infastructure "Embedded Infastructure")</p>

---

## 1) Main

<p class="callout info"><span style="white-space: pre-wrap;">Main.c can be found in </span>`<span class="editor-theme-code">src/arm_board</span>`</p>

This is the code that will be ran when building and uploading using platformio. Main should contain some multithreading for running separate tasks, otherwise it should use the libraries (common and arm board specific) that are created.

---

## 2) Libraries

<p class="callout info"><span style="white-space: pre-wrap;">The libraries for the arm board can be found in </span>`<span class="editor-theme-code">components/arm_board</span>`</p>

The arm board uses 3 libraries:

- firmware
- movement
- simulink

**Firmware** <span style="white-space: pre-wrap;">contains the generated CubeMX code. </span><span style="background-color: rgb(251, 238, 184);">You do not need to touch this after generating</span>.

<p class="callout info">**NOTE:**<span style="white-space: pre-wrap;"> do make sure that after generating your code in CubeMX, you run the post generation script. You </span>**can** <span style="white-space: pre-wrap;">set a post generation script in CubeMX itself. However, if you use </span>**Windows** <span style="white-space: pre-wrap;">you may need to run the bash script manually. This script can be found in </span>`<span class="editor-theme-code">scripts/post_code_generation.bash</span>`.</p>

**Simulink** <span style="white-space: pre-wrap;">contains code generated by control subteam. </span><span style="background-color: rgb(251, 238, 184);">You also do not need to touch this</span><span style="white-space: pre-wrap;">, since it is not code that is ran on embedded side. It is a helpful </span>**reference** <span style="white-space: pre-wrap;">for the output data that control will be giving your system. </span>  
<span style="white-space: pre-wrap;">Specifically, in </span>`<span class="editor-theme-code">control.h</span>`<span style="white-space: pre-wrap;">, struct </span>`<span class="editor-theme-code">ExtY</span>`<span style="white-space: pre-wrap;"> gives the external outputs. These will be transferred across the robot using protobufs. So for us, this struct contains the inputs for the motors on the robotic arm.</span>

**Movement** is currently the only "real" library that is written by hand. It contains the source code for controlling stepper motors.

---

## 3) Protobuffers

<p class="callout info">**Information on the arm board protobuffers can be found here:**<span style="white-space: pre-wrap;"> </span>[Arm Board Protobuffers](https://bookstack.roboteamtwente.nl/books/communication-system/page/arm-board-protobuffers "Arm Board Protobuffers")</p>