# Results & Observations
###### tags: `Results`
## Cruise Control
Control Objective:
To control the velocity of car and make it reach desired velocity.
Here the cars expriences drag due to air proportional to its velocity which is $bv$
and it is given an input $u$

Model Dynamics:
$m \dot v + bv = u$
PID controller is used to reach the given desired value of velocity
P : Proportional gain (helps to reach desired value but does not reachs desired value)
I : Integral gain (helps to reach desired value but overshoots)
D : Derivate gain (helps to reduce overshoot due to integral gain)
Desired value of velocity: $60 km/hr$

## 1D Control of Quadrotor
We implemented a PD controller for height control of the quadrotor. We tuned the proportional gain(kP) and derivative gain(kD) for two different cases.
### Hover Control
The first case was of hover control where the quadrotor was simply stabilized at the height of 0m.

### Step Response
The second case was of step response where the quadrotor was given an input height of 1m.
The rise time was kept as less than 1 second and the maximum overshoot was capped at 5%.

## 2D Control of Quadrotor
After controlling quadrotor in 1 Dimension, our next objective is to build a PD controller to control the motion of quadrotor in Y-Z (2D) plane. Below are results ,we moved the quadrotor from some y postion to another, keeping heigth (z) constant.
### Hover Controller
The Quadcopter was moved to a desired position in y direction

### Trajectory Controller
The Quadcoptor followed the desired trajectory.

## 3D Control of Quadrotor
Since now we have applied 1D and 2D to our Quadcopter, Now we will be extending it to 3D control and then to trajectory generation. We will firstly make the drone to follow Line and Helix trajectory, whose corresponding gifs are shown below.
**The position and attitude control loops can be given as:**

### Line Trajectory

#### **Quad Velocity**

### **Quad Position**

### Helix Trajectory

#### **Quad Velocity**

#### **Quad Position**

### Trajectory Generation
We generated a minimum snap trajectory using a $7^{th}$ order polynomial. In Trajectory generation we are given a cerain number of waypoints, and the drone has to follow the path from one way point to other. In this way if we increase the number of waypoints bascially we can improve drone's trajectory.

#### **Quad Velocity**

#### **Quad Position**

### PID Control of Inverted Pendulum
Here PID control was used to stabilize the inverted pendulum in upright position. It was observed that a large amount of force is applied initially. From the graphs it can be seen that the value of x is increasing ie the cart keeps on moving towards right.



### LQR Control of Inverted Pendulum
Here we build an LQR controller to stabilize the pendulum in upright position. We tunned the Q (penalty on states) and R (penalty on actuators) matrix to obtain the desired results. Below graphs shows variation of theta, force, postion(x) with time. In animation we can see pendulum stabilize in upright postion at desired (x=5).


### Inverted Pendulum(LQR + Energy Control)
This is a hybrid approach to Inverted pendulum. Here we use Energy Control along with LQR to make the pendulum stand at upright position.
What we observed is LQR is unable to take the pendulum directly to the upright position in a efficient manner and it also gives absurd results when did so.
So In hybrid model the changes done are intially directly the corresponding energy at upright position is given to the pendulum and as it reaches close to vertical force is applied through LQR model. In this way we get better graphs and there is no need to apply caps on any of the quantity.




### Human State Aware Controller for Tethered UAV
#### Version 1.1
- In the first version of the code, we did not involve the direction of force and gave the human constant velocity in the desired direction of motion.
- If the x and y components of force becomes too less, the velocity of human becomes zero.
- Euler dynamics is used to calculate both the position and velocity of drone as well as human.
- A disturbance in the velocity of human was introduced at a particular instant(iteration), which caused spike in some of the graphs.











#### Version 1.2
- We changed the direction of velocity of human according to the direction of f_c (tension in the cable).
- If lc_norm - lc_bar (difference between magnitude of position vector between drone & human and original length of tether) is less or equal to zero, then f_c(tension in the cable) is zero.
- If the x and y components of force becomes too less, the velocity of human becomes zero.
- If the magnitude of force becomes zero at any instant, velocity of human becomes zero.
- Human is capable of varying its damping coefficient to achieve constant velocity.
-




#### Version 1.3
- Includes all assumptions from version 1.2
- Near the final position, when x and y components of force are very small and the z component is greater than zero, the human leaves the handle i.e. we make the magnitude of f_c as zero.
- The magnitude of the human velocity has been increased to 0.5 m/s
#### Version 1.4
- The cable force is assumed to be constant (represented by gamma) which implies the control force is constant.
- Human and drone have the same velocity and follow a constant velocity trajectory
- The product of kH and e_R is assumed to be constant



#### Version 1.5
- For the initial 50 seconds it was assumed that the product of kH and e_R, i.e. the control force, is large and was considered to be constant(represented by gamma). And for the rest of the time span proportional was implemented.




#### Tasks Ahead
- Make the fixed position of winch visible in animation.(done)
- Change initial position of drone and check whether the trajectories for all these positions are similar/circular.(done?)
- Push code in the repo after gaining access.(done)
#### Regarding Papers
- Start reading ETH Zurich paper on TAV.(done)
- Find other papers to understand the dynamics of winch with variable position(post such papers on channel).
#### For main project
- Length of cable is fixed and position of winch is variable (winch can be considered like a human).
- Tension will serve as feedback, when it is zero(or cable is slack), drone will move to make it non zero (make the cable taut).
- At the end final position of drone should be directly above the final position of winch.