# Quadcopter

The `quad/` directory contains all code that programs the quadcopter. This
includes any C libraries we have written, any HDL to program the Zybo on
the quad, and the XSDK main project that runs on the Zybo.

## Documents
[Zybo Pinout Assignments](doc/zybo_pinout_assignments.md)  
[How to use Xilinx software tools](doc/how_to_use_xilinx_tools.pdf)  

## Software Instructions

The main quad application is written as a library, and located at 
`src/quad_app/` ("main" function in quad_app.c).

The main XSDK project that actually runs on the Zybo is located at
`xsdk_workspace/real_quad/`

We also have a complemetary "virtual quad" to ease testing located at
`src/virt_quad/`

## Building

To build the libraries:
```
make
```

You can also build each library individually inside their respective project
directories:
```
cd src/<project> && make
```

To build the XSDK project, use the XSDK IDE. Source the proper XSDK files, and
then start up the XSDK IDE. Be sure to select the `xsdk_workspace` directory
in the quad directory as your "workspace":

## Testing

_Write tests! It makes automating things so much easier._

Run the unit and functional tests:
```
make test
```

You can also run the test for a specific library inside its respective project
directory:
```
cd src/<project> && make test
```

### Manually testing the hardware interface

Of course, we cannot run our automated tests on code that needs the Zybo. But
we have manual tests that you can use to test each specific driver in the 
hardware interface.

Look in `xsdk_workspace/real_quad/src/hw_impl_zybo_tests.c` for instructions.
Ideally, you would run these tests from the XSDK IDE.

### XSDK FYIs
The XIlinx SDK has a few quirks that are important to watch out for:
 1. From the [documentation](https://www.xilinx.com/support/documentation/sw_manuals/xilinx14_7/SDK_Doc/tasks/sdk_t_tcf_limitations_faq.htm), if you abort program execution while at a breakpoint inside an interrupt handler, when re-running the program, interrupts don’t fire. You have to do a hard reset of the board (cycle power) to have interrupts work again.
 2. After doing a `git pull`, refresh the files by right-clicking on the project in the sidebar and clicking "Refresh"
 3. The project does not detect changes in header files, so if you modify a `.h` file, you should do a clean before building, otherwise you may experience unexpected behavior.


### Quad Stats
Optical flow sensor is offset by 35.64 degrees.