\subsectionauthor{Author: Lars Jonsson \\Reviewer: Max Unander}
To be able to fly the copter up and down these shafts without colliding, we have put six ultrasonic sensors on the copter in each direction, see figure \ref{label}.
In this case there will be three pair of sensors, where each pair represent one axis in the Cartesian coordinate system.
To be able to fly the copter up and down these shafts without colliding, we have put six ultrasonic sensors on the copter in each direction.
For this project there will be three pair of sensors, where each pair represent one axis in the Cartesian coordinate system.
In Figure~\ref{fig:twosonarcopter} you can see one of these pairs mounted on the x-axis.
\caption{Copter at early stage with only one sonar-pair mounted.}
\label{fig:twosonarcopter}
\end{figure}
With help of the measurement from each sensor, a controller for collision avoidance will be implemented.
The collision avoidance will consist of three individual PID-controllers, where each one will control the position on each axis.
To get this to work we will have to map the copters movement in the Cartesian coordinate system to roll, pitch and throttle commands that will be sent to the flight controller.
This will work in the way that the output from the PIDs in each direction will be represented by either a pitch, roll or throttle command to the flight controller.
...
...
@@ -13,7 +21,7 @@ This will work in the way that the output from the PIDs in each direction will b
The PID controller will have the difference value between the measurement of the two ultrasonic sensors as control variable, and it's task is to converge this difference into 0.
When the difference value goes to 0 it means that the copter is right in the middle between two objects.
The output of the PID will be a number between 1000 and 2000, because that is the input the flight controller can receive.
The input to the flight controller is a linear function where for the roll and pitch command where 1000 represents by a setpoint of $-10^\circ$ and 2000 will induce a setpoint of $+10^\circ$.
The input to the flight controller is a linear function where for the roll and pitch command 1000 represents by a setpoint of $-10^\circ$ and 2000 will induce a setpoint of $+10^\circ$.
This function is linear so 1500 represent no inclination.
For the throttle command 1000 will be no throttle at all and 2000 will set full throttle to the motors.
The yaw command do differ a bit, it will not set a specific set-point, it will instead set an angular velocity to the copter.
...
...
@@ -30,24 +38,37 @@ When we had the hovering function working quite good, we started out with trying
To do this we used the SonarDifference algorithm mentioned above.
We started out with just the P variable and saw that it "bounced" a lot between the walls.
We concluded that we needed the D parameter as well to reduce the bouncing.
When we saw that this worked we started to fine tune the variables.
This was done by logging data while flying, and afterwards we could check the graphs and from those do some conclusions on how we should change the variables.
The graphs from the final tuning of the \texttt{PID\_Roll} is shown in Fiugre~\ref{fig:PIDtuning1}.
When we saw that this worked, we started to fine tune the variables.
This was done by logging data while flying, plotting of the data, and from those do some conclusions on how we should change the variables.
Before tuning the plots did look like the on in Figure~\ref{fig:PIDtuning1}.
In this graph we see that the Roll command is clipped a lot.
This is because the controller is to aggressive and the roll command reaches its maximum/minimum values at 1750 and 1250.
These maximum values are changeable, and we saw that $1500\pm{250}$ worked quite well.
\caption{SonarDiff X, shows the difference between the measurement of two sonars placed on the same axis. ROLL command show the value that is sent to the flight controller. SWH is the switch that starts the PID, how these are mapped on the RC transmitter can be seen in Table~\ref{tab:controller_channels}.}