Skip to content

Sepishoon/Bicopter-Path-Planning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RRT Path Planning for a Tilt Bicopter with Obstacle Avoidance

Path planning and autopilot design for a tilt bicopter UAV, covering 6-DOF dynamics, LQR control, AHRS attitude estimation, and RRT-based path planning with obstacle avoidance, implemented in MATLAB and Simulink.

Course: Aerial Robotic Design
Department: Aerospace Engineering, Sharif University of Technology
Authors: Sepehr Mahfar & Mohammad Nayebi
Date: July 2024


Overview

This project presents a complete autopilot pipeline for a tilt bicopter — an underactuated UAV with two tilting rotors providing four control channels. The workflow proceeds from Newton–Euler derivation of the equations of motion through LQR control design, AHRS-based state estimation, and finally RRT-based path planning with path smoothing and management.

All derivations, implementation details, and simulation results are documented in Report.pdf.


Project Structure

.
├── Animations/
│   ├── Pitch_ramp.mp4          # Pitch channel ramp response animation
│   ├── Pitch_Sine-.mp4         # Pitch channel sine response animation
│   ├── Roll_Ramp.mp4           # Roll channel ramp response animation
│   ├── Roll_Sine.mp4           # Roll channel sine response animation
│   ├── Yaw_Ramp.mp4            # Yaw channel ramp response animation
│   └── Yaw_Sine.mp4            # Yaw channel sine response animation
├── Codes/
│   ├── RRT_Code.m              # RRT path planning algorithm
│   ├── PathSmoothing.m         # Path smoothing algorithm
│   ├── insertPoints.m          # Path management and waypoint insertion
│   ├── K_Mat.m                 # LQR gain matrix computation
│   ├── LQR_Controller.slx      # Simulink — LQR closed-loop simulation
│   ├── PID_Controller.slx      # Simulink — PID closed-loop simulation
│   ├── datacnavlab.mat         # Navigation lab sensor data
│   ├── linsys1.mat             # Linearised bicopter state-space model
│   ├── Q.mat                   # LQR state weighting matrix
│   ├── R.mat                   # LQR input weighting matrix
│   └── Animation Codes/        # Scripts for generating flight animations
└── Report.pdf

Methods

Dynamic Model

The bicopter is modelled as a six-degree-of-freedom system using Newton–Euler relations. Four coordinate frames are defined — inertial, body, and two motor frames (one per rotor). The equations of motion cover:

  • Angular velocity dynamics — rotational equations in body frame
  • Euler angle kinematics — mapping body rates to Euler angle rates
  • Translational dynamics — force balance in body frame
  • Position kinematics — inertial position integration

External forces include gravity, aerodynamic drag, and rotor thrust. Moments arise from rotor thrust arms and rotor drag torques.

LQR Control

The bicopter is controlled by a Linear Quadratic Regulator (LQR) with four virtual control channels derived from rotor speeds and tilt angles:

uz = Ω₁² cos δ₁ + Ω₂² cos δ₂    (altitude)
uφ = Ω₁² cos δ₁ − Ω₂² cos δ₂    (roll)
uθ = Ω₁² sin δ₁ + Ω₂² sin δ₂    (pitch)
uψ = Ω₁² sin δ₁ − Ω₂² sin δ₂    (yaw)

The LQR minimises a quadratic cost over the 12-state vector x = [pₐ, pₑ, p_d, u, v, w, φ, θ, ψ, p, q, r]ᵀ. The optimal gain matrix K is computed from the solution to the Algebraic Riccati Equation. Actuator commands (Ω₁, Ω₂, δ₁, δ₂) are recovered analytically via closed-form inversion relations.

AHRS Navigation

Since the LQR requires all vehicle states, an Attitude and Heading Reference System (AHRS) is implemented. GPS provides position and velocity; Euler angles are estimated by fusing gyroscope and accelerometer/magnetometer data through a complementary filter:

  • High-pass branch — gyroscope dead reckoning for high-frequency attitude rates
  • Low-pass branch — accelerometer/magnetometer for low-frequency fixed positioning

Roll and pitch are initialised from the accelerometer specific-force measurement; yaw from the magnetometer.

RRT Path Planning

The Rapidly-Exploring Random Tree (RRT) algorithm generates a collision-free waypoint sequence in an obstacle-rich 2D occupancy grid. At each iteration a random configuration is sampled, the nearest tree node is identified, and the tree is extended by the maximum connection distance (MCD = 1 m) if the segment is obstacle-free. A Voronoi bias drives exploration toward unvisited regions.

The raw RRT output is post-processed in two stages:

  • Path smoothing — iteratively removes intermediate waypoints where a direct collision-free segment exists, reducing the path to five waypoints
  • Path management — assigns active waypoints based on closest-approach criterion, converting the discrete list into a time-parameterised reference for the tracking controller

Control Performance

The LQR controller was benchmarked against a PID baseline on both a fixed-altitude square path and the RRT-generated path. Key results:

Metric LQR PID
Squared error cost (RRT path) baseline
Improvement 66.34%
Overshoot (square path) smaller larger
Altitude settling time faster slower

Simulink Models

File Description
LQR_Controller.slx Full closed-loop simulation with LQR autopilot and RRT path
PID_Controller.slx Equivalent simulation with PID autopilot for comparison

Animations

Six animations demonstrate the bicopter's attitude response to standard reference inputs across all three axes:

File Axis Input
Pitch_ramp.mp4 Pitch Ramp
Pitch_Sine-.mp4 Pitch Sine
Roll_Ramp.mp4 Roll Ramp
Roll_Sine.mp4 Roll Sine
Yaw_Ramp.mp4 Yaw Ramp
Yaw_Sine.mp4 Yaw Sine

Requirements

  • MATLAB R2023b or later
  • Control System Toolbox
  • Simulink

Usage

  1. Open MATLAB and navigate to the Codes/ directory
  2. Run K_Mat.m to compute the LQR gain matrix (requires linsys1.mat, Q.mat, R.mat)
  3. Run RRT_Code.m to generate the planned path, then PathSmoothing.m and insertPoints.m to post-process it
  4. Open LQR_Controller.slx or PID_Controller.slx in Simulink to run the closed-loop autopilot simulation

About

Full autopilot pipeline for a tilt bicopter: 6-DOF dynamics, LQR control, complementary-filter AHRS, and RRT path planning with obstacle avoidance.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages