-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4be1e9f
commit 89e6679
Showing
3 changed files
with
105 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
function [outputArg1,outputArg2] = droneDynamics(inputArg1,inputArg2) | ||
%DRONEDYNAMICS Summary of this function goes here | ||
% Detailed explanation goes here | ||
outputArg1 = inputArg1; | ||
outputArg2 = inputArg2; | ||
function dqdt = droneDynamics(t,q,u,params) | ||
%droneDynamics Drone dynamics function, includes low level attitude | ||
%controller | ||
|
||
% q = x, y, z, dx, dy, dz, roll, pitch | ||
x=q(1);y=q(2);z=q(3); | ||
dx=q(4);dy=q(5);dz=q(6); | ||
roll=q(7);pitch=q(8); | ||
|
||
% u = roll, pitch, thrust (command, angles in world frame); | ||
roll_command=u(1);pitch_command=u(2);thrust_command=u(3); | ||
|
||
% Attitude controller here, update dpitch and droll | ||
|
||
R = rotz(0)*roty(pitch_command)*rotx(roll_command); % roll and pitch in world frame so yaw irrelevant | ||
acc = [0;0;-params.g] + R*[0;0;thrust_command/params.m]; | ||
|
||
dqdt = [dx;dy;dz;acc;0;0]; | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters