Mechatronics Project Report

Akshay Shetty, Dan Block

 

For my Mechatronics course project, we (Dan and me) decided to work on improving the quadrotors for the AE483 (UAV) class. At the beginning of the semester, we outlined three main aspects that we plan to work on.

1.       Reducing the yaw offset observed during flight

2.       Reducing the position offset observed during flight

3.       Building a simulator for students to test their C codes before flying the quadrotors

In the rest of the report I will briefly go over each part, and mention what steps we took in solving the step.

 

Reducing yaw offset

                During flight we had observed that the yaw of the quadrotors were substantially offset from the commanded yaw. This occurred due to the incorrect attitude estimate obtained by the compass. Since the entire setup is indoors, the compass measurements were greatly affected, resulting in incorrect yaw estimates. To solve this problem, we just changed a line of code on the on-board AscTec controller. We changed the current yaw estimate to the motion capture yaw value, instead of the compass yaw value.

Original code:

                cnt_u[2] = Ktz_P*(yaw_desired-imusensor.dThetaz)-Ktz_D*(imusensor.dOmegaz);

Altered code:

                cnt_u[2] = Ktz_P*(yaw_desired-real_mocap.dThetaz)-Ktz_D*(imusensor.dOmegaz);

 

Reducing position offset

While performing hovering tests, we observed that the quadrotor would generally hover at a slightly offset position. To locate the problem we recorded many variables from the on-board processor and stepped through them one by one. We eventually found out that the error was due to offset measurements from the inertial/magnetic sensors. Again, this seems to be due to the indoor setup affecting the magnetometers. To solve this, we added the option to send correction parameters to the quadrotor at the beginning of the flight. These values can be adjusted until good position accuracy seems to have been achieved. The snippet of code on the on-board processor that incorporates these offsets are:

                cnt_u[0] = Ktx_P*(roll_desired-imusensor.dThetax)-Ktx_D*(imusensor.dOmegax) + u1_offset;

                cnt_u[1] = Kty_P*(pitch_desired-imusensor.dThetay)-Kty_D*(imusensor.dOmegay) + u2_offset;

At the beginning of the flight, the user can edit the values u1_offset and u2_offset on a text file at the Groundstation. These values should be adjusted to make sure that the quadrotor hovers close where it is supposed to.

 

Simulator

                From our previous experience with AE483 we observed that many students would spend majority of the time trying to verify their path planning algorithm for the quadrotor. Due to limited space and to maintain safety we do not fly multiple quadrotors simultaneously. This resulted in long waiting lines for the students. Thus before the course next year, we planned to come up with a simulator that would allow the students to test their algorithm without needing to fly the quadrotors. To build the simulator, we took the following steps:

·         Installed Visual Studio 2015 (primarily for the x64 compilers) and set up link between the C program and MATLAB.

·         Set up such that the quadrotor states are updated every 20ms (50Hz) by the MATLAB simulation.

·         Incorporated the planner.c into the Visual Studio project. This is where you can try out different algorithms. The planner looks at the quadrotor and obstacle states to decide where to move.

·         At the end, all the states are recorded and an animation is shown to demonstrate how the quadrotor would actually fly. The animation also includes a movable object.

We implemented the gradient descent method including obstacle avoidance. Here are two videos showing the method:

·         Gradient descent with static obstacle: https://youtu.be/zUW_Z1QNdl8

·         Gradient descent with moving obstacle: https://youtu.be/2m13Lw5Nxu0

Steps to get started with the Simulator on a new machine:

·         Install Visual Studio 2015 and MATLAB 2015

·         Copy the ‘Quad_Sim’ folder to the MATLAB root directory (Example: “C:\MATLAB 2015a\”)

·         Copy and unzip the Visual Studio code. In the Visual Studio code, make sure the additional linker and header files are included (http://www.mathworks.com/matlabcentral/answers/164250-how-can-i-compile-a-matlab-engine-application-using-microsoft-visual-studio-2012 )

·         Copy paste your entire planner.c code into the planner.c file inside the project. Remember to include the “stdafx” header file.

·         Configure all the initial settings at the beginning of the code and press Ctrl+F5. If prompted to build, click yes.

-

Group Members:

 

         alt text                          Daniel J. Block

        Akshay Shetty                                                                           Dan Block