Skip to content

adidinchuk/2d-unity-quadcopter-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2d-unity-quadcopter-sim

Table of contents

General info

The code in the repo should run as-is out of the box but how the parameters of the simulation can be manipulated are covered below.

Read my related blog post here.

Thrusters

The drone has left and right thrusters, these can be manipulated separately, however for best results their parameters should be identical. Each thruster also has a rigid body with a defined mass (0.3) and this rigid body is attached to the parent drone body using a 2D Fixed Joint.

alt text

The main Thruster.cs parameters to configure would be the thrust coefficient, maximum RPM, and the spinup rate.

Quadcopter

The quadcopter also had a rigid body with a defined mass (1) along with a simple collider to prevent it from passing through the surface platform.

alt text

The rotors and rotor count are set in the Quadcopter.cs script and the target position and PID control coefficients in the FlightControl.cs script.

Technologies

Project is created with:

  • Unity 2020.3.21f1

Running the Code

When we run the scene the quadcopter lifts off the ground, moves towards the specified altitude, and settles there.

alt text

The P thrust values can be modified to change how quickly the drone reaches the desired high.

alt text

The D thrust value dictates how smooth our trajectory is and can be used to minimize overshooting at a cost of slower convergence.

alt text

The I thrust value allows the system to overcome unforeseen disturbances in the environment and have a smoother recovery.

alt text

The roll PID coefficients provide the same role but for pitch.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages