Skip to content

andrewdipper/quadrotor_v1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

    A quaternion based quadrotor flight control software implementation.
    Copyright (C) 2014  Andrew Pratt

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.


Target Board: Teensy 3.1
Compiled with arm-none-eabi toolchain distributed with the Teensy3.1

./hw contains code for enabling the processor's timers, busses and other features
./quadcore contains the code for the control software

Basic Description of How it Works:
	1.reads and adjusts all the sensor values
	2.updates the current state with the values from the gyro
	3.corrects the current state with the values from the magnetometer and accelerometer 
		(effectively a complimentary filter between (acc and mag) and the gyro
	4.computes the desired attitude from the RC controller input
	5.computes the rotation necessary to rotate from the quad's reference frame into the desired reference frame
	6.turns this rotation into individual correcting rotations on each axis
	7.calculates the speed for each motor based on the correcting rotations using a PD controller
	8.sends the desired motor speeds to the ESCs
	9.repeats






Timing:
	1.The main loop executes at ~1000hz
	2.The ESCs are updated at 250hz
	3.The control inputs are received at ~20hz
	4.The sensors update rates are independent (Don't really care about dropped readings)







A note on the combination of rotations:
	rotation1 = q1;
	rotation2 = q2;
	
	Because rotations are non-commutative q1*q2 != q2*q1

	This will be the most commonly used form.
	To find the rotation equivalent to two consecutive rotations defined in the local reference frame:
	q3 = q1*q2

	To find the rotation equivalent to two consecutive rotations defined in the global reference frame:
	q3 = q2*q1





	
A note on the naming of quaternions:
	Names are usually two letters followed by quat to signify that it is a quaternion
	The first and second letters represent coordinate systems and are usually b = body, g = global/earth, t = target

	The quaternion describes the rotation necessary to rotate the first coordinate system into alignment with the second coordinate system.
	
	EX:
	bgquat = the rotation necessary to rotate the body coordinate system into alignment with the global coordinate system	
	btquat = the rotation necessary to rotate the body coordinate system into alignment with the target coordinate system

	To describe a vector in a second coordinate system given a first it is necessary to apply the OPPOSITE ROTATION 
		to that required to rotate the first coordinate system into alignment with the second
	To describe vector v in global coordinates given body coordinates we multiply by gbquat NOT bgquat 








	



About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published