Quadrotor Autonomous Control
Quadrotor Mixed Autonomy | Jan-March 2023.
Overview
The goal was to develop a quadrotor autopilot system that can fly autonomously.
The sub-goals of the project involved :
- control of the quadrotor manually via keyboard
- control of the quadrotor manually via joystick
- autonomous control of the quadrotor via Vive Lighthouse
Hardware setup
The harware components of the quadrotor that were assembled primarily comprises
the WIFI module, IMU (Inertial Measurement Unit) sensor, raspberry pi, 4 motors and a rechargable lithium battery.
Additional harware that was used was a joystick and vive sensor.
Control
The roll, pitch, yaw is controlled by using PID (Proportional Integral and Derivative ) algorithm.
This allows for smooth flight in all directions with minimal overshooting or oscillations.
The PID gains were fine-tuned to gain stable and precise control of the quadrotor's orientation.
The thrust is controlled by regulating the PWM of the motors.
//Complementary filter for estimating roll and pitch angles
//using gyroscope and accelerometer data from an IMU:
roll_gyro += imu_data[1]*imu_diff;
pitch_gyro += imu_data[0]*imu_diff;
roll_angle = roll_accel*A_COMP_FILTER + (1-A_COMP_FILTER)*(roll_angle+imu_data[1]*imu_diff);
pitch_angle = pitch_accel*A_COMP_FILTER + (1-A_COMP_FILTER)*(pitch_angle+imu_data[0]*imu_diff);
//motor controls:
motor_cntrl0 = desired_thrust+desired_pitch-desired_roll-yaw_error*P_YAW-yaw_vive_error*P_VIVE_YAW;
motor_cntrl1 = desired_thrust-desired_pitch-desired_roll+yaw_vive_error*P_VIVE_YAW;
motor_cntrl2 = desired_thrust-desired_pitch+desired_roll-yaw_vive_error*P_VIVE_YAW;
motor_cntrl3 = desired_thrust+desired_pitch+desired_roll+yaw_error*P_YAW+yaw_vive_error*P_VIVE_YAW;
Safety
When in manual control i.e while using the keyboard or joystick the heartbeat was measured
to know if the quadrotor is even connected to these input devices or not. There is a pause button that stops the motors, and a shutdown button that kills the program and stops the motors that is incorporated. There is a maximum and minimum thrust and indirect speed or neutral power assigned to the control (via keyboard or joystick).
There is also a maximum and minimum angle that is programmed to not exceed for either of pitch or roll.
Project Partner
Charles Cheng