Skip to content
Snippets Groups Projects
Commit 1015231e authored by burneykb's avatar burneykb
Browse files

Merge branch 'master' into groundStation-dev-setpointcontrollers

parents 47e38bee 35f72ed8
No related branches found
No related tags found
No related merge requests found
Showing
with 1437 additions and 1261 deletions
function J = J_calc_bifilar( m , g, D, L, t, n , varargin)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
average_strings = {'average','mean','ave'};
least_squares_strings = {'least squares','ls'};
mode = 0;
if ~isempty(varargin)
for k = 1:length(varargin)
if any(strcmpi(varargin{k},average_strings))
mode = 0;
end
if any(strcmpi(varargin{k},least_squares_strings))
mode = 1;
end
end
end
if mode == 0 %averge
N = length(t);
Js = zeros(1,N);
for k = 1:N
Js(k) = m(k)*g*D(k)^2/(16*pi^2*L(k))*(t(k)/n(k))^2;
end
J = mean(Js);
end
if mode == 1 %least squares
J = (16*pi^2*L./(m*g.*D.^2))\(t./n).^2 ;
end
end
% inches2meters = 0.0254 ;
%%
% %Jxx
% m = 1.244*ones(5,1);
% D = (12+3/8)*inches2meters*ones(5,1);
% L = (81+3/4)*inches2meters*ones(5,1);
% t = [ 94.58 ; 93.91 ; 93.81 ; 94.16 ; 94.04 ] ;
% n = 50*ones(5,1);
% %Jyy
% m = 1.244*ones(5,1);
% D = (12+3/8)*inches2meters*ones(5,1);
% L = (91+3/4)*inches2meters*ones(5,1);
% t = [ 103.31 ; 103.15 ; 103.31 ; 103.47 ; 103.13 ] ;
% n = 50*ones(5,1);
% %Jzz
% m = 1.244*ones(5,1);
% D = (19+3/16)*inches2meters*ones(5,1);
% L = (96+1/4)*inches2meters*ones(5,1);
% t = [ 96.64 ; 97.47 ; 97.75 ; 97.35 ; 97.78 ] ;
% n = 50*ones(5,1);
load .\git_repos\microCART_17-18\controls\dataCollection\bifilar_inertia_2_18_2017\MicroCART_bifilar_Jxx_2_18_2017 ;
Jxx_a = J_calc_bifilar( m , g, D, L, t, n , 'average')
Jxx_ls = J_calc_bifilar( m , g, D, L, t, n , 'least squares')
clear D L m n t
load .\git_repos\microCART_17-18\controls\dataCollection\bifilar_inertia_2_18_2017\MicroCART_bifilar_Jyy_2_18_2017 ;
Jyy_a = J_calc_bifilar( m , g, D, L, t, n , 'average')
Jyy_ls = J_calc_bifilar( m , g, D, L, t, n , 'least squares')
clear D L m n t
load .\git_repos\microCART_17-18\controls\dataCollection\bifilar_inertia_2_18_2017\MicroCART_bifilar_Jzz_2_18_2017 ;
Jzz_a = J_calc_bifilar( m , g, D, L, t, n , 'average')
Jzz_ls = J_calc_bifilar( m , g, D, L, t, n , 'least squares')
File added
File added
File added
% Model Parameters
m = 1.19; % Quadrotor + battery mass
m = 1.244; % Quadrotor + battery mass
g = 9.81; % Acceleration of gravity
%Jxx = 0.0218; % Quadrotor and battery motor of inertia around bx (pitch)
%Jyy = 0.0277; % Quadrotor and battery motor of inertia around by (roll)
Jxx = 0.0277;
Jyy = 0.0218;
Jzz = 0.0332; % Quadrotor and battery motor of inertia around bz (yaw)
% Jxx = 0.0277; % Quadrotor and battery motor of inertia around bx (pitch)
% Jyy = 0.0218; % Quadrotor and battery motor of inertia around by (roll)
% Jzz = 0.0332; % Quadrotor and battery motor of inertia around bz (yaw)
Jxx = 0.0130; % Quadrotor and battery motor of inertia around bx (pitch)
Jyy = 0.0140; % Quadrotor and battery motor of inertia around by (roll)
Jzz = 0.0285; % Quadrotor and battery motor of inertia around bz (yaw)
Jreq = 4.2012e-05; % Rotor and motor moment of inertia around axis of rotation
Kt = 8.6519e-6; % Rotor thrust constant
Kh = 0; % Rotor in-plane drag constant
......
No preview for this file type
This diff is collapsed.
File added
......@@ -10,7 +10,8 @@
#include "control_algorithm.h"
#include "communication.h"
#define ROLL_PITCH_MAX_ANGLE 0.3490 // 20 degrees
#define ROLL_PITCH_MAX_ANGLE 1.5708 // 90 degrees
#define PWM_DIFF_BOUNDS 30000
int control_algorithm_init(parameter_t * parameter_struct)
{
......@@ -184,13 +185,13 @@
parameter_struct->pid_controllers[PITCH_ID].current_point = sensor_struct->pitch_angle_filtered;
parameter_struct->pid_controllers[PITCH_ID].setpoint =
/*(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)?
(parameter_struct->pid_controllers[LOCAL_X_ID].pid_correction) + pitch_trim :*/ user_input_struct->pitch_angle_manual_setpoint;
(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)?
(parameter_struct->pid_controllers[LOCAL_X_ID].pid_correction) + pitch_trim : user_input_struct->pitch_angle_manual_setpoint;
parameter_struct->pid_controllers[ROLL_ID].current_point = sensor_struct->roll_angle_filtered;
parameter_struct->pid_controllers[ROLL_ID].setpoint =
/*(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)?
(parameter_struct->pid_controllers[LOCAL_Y_ID].pid_correction) + roll_trim :*/ user_input_struct->roll_angle_manual_setpoint;
(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)?
(parameter_struct->pid_controllers[LOCAL_Y_ID].pid_correction) + roll_trim : user_input_struct->roll_angle_manual_setpoint;
//logging and PID computation
......@@ -232,15 +233,17 @@
memcpy(raw_actuator_struct->controller_corrected_motor_commands, user_input_struct->rc_commands, sizeof(int) * 6);
// don't use the PID corrections if the throttle is less than about 10% of its range
// NOTE!!!!!!!!!!!!!!!!!!!!!!
// re-enable the check for AUTO_FLIGHT_MODE when autonomous is fully enabled
if((user_input_struct->rc_commands[THROTTLE] >
118000) || (user_defined_struct->flight_mode == AUTO_FLIGHT_MODE))
118000))// || (user_defined_struct->flight_mode == AUTO_FLIGHT_MODE))
{
if(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)
{
//THROTTLE
raw_actuator_struct->controller_corrected_motor_commands[THROTTLE] =
((int)(parameter_struct->pid_controllers[ALT_ID].pid_correction)) + sensor_struct->trims.throttle;
//raw_actuator_struct->controller_corrected_motor_commands[THROTTLE] =
// ((int)(parameter_struct->pid_controllers[ALT_ID].pid_correction)) + sensor_struct->trims.throttle;
//ROLL
raw_actuator_struct->controller_corrected_motor_commands[ROLL] =
......@@ -284,23 +287,23 @@
raw_actuator_struct->controller_corrected_motor_commands[THROTTLE] = 0;
//BOUNDS CHECKING
if(raw_actuator_struct->controller_corrected_motor_commands[ROLL] > 20000)
raw_actuator_struct->controller_corrected_motor_commands[ROLL] = 20000;
if(raw_actuator_struct->controller_corrected_motor_commands[ROLL] > PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[ROLL] = PWM_DIFF_BOUNDS;
if(raw_actuator_struct->controller_corrected_motor_commands[ROLL] < -20000)
raw_actuator_struct->controller_corrected_motor_commands[ROLL] = -20000;
if(raw_actuator_struct->controller_corrected_motor_commands[ROLL] < -PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[ROLL] = -PWM_DIFF_BOUNDS;
if(raw_actuator_struct->controller_corrected_motor_commands[PITCH] > 20000)
raw_actuator_struct->controller_corrected_motor_commands[PITCH] = 20000;
if(raw_actuator_struct->controller_corrected_motor_commands[PITCH] > PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[PITCH] = PWM_DIFF_BOUNDS;
if(raw_actuator_struct->controller_corrected_motor_commands[PITCH] < -20000)
raw_actuator_struct->controller_corrected_motor_commands[PITCH] = -20000;
if(raw_actuator_struct->controller_corrected_motor_commands[PITCH] < -PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[PITCH] = -PWM_DIFF_BOUNDS;
if(raw_actuator_struct->controller_corrected_motor_commands[YAW] > 20000)
raw_actuator_struct->controller_corrected_motor_commands[YAW] = 20000;
if(raw_actuator_struct->controller_corrected_motor_commands[YAW] > PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[YAW] = PWM_DIFF_BOUNDS;
if(raw_actuator_struct->controller_corrected_motor_commands[YAW] < -20000)
raw_actuator_struct->controller_corrected_motor_commands[YAW] = -20000;
if(raw_actuator_struct->controller_corrected_motor_commands[YAW] < -PWM_DIFF_BOUNDS)
raw_actuator_struct->controller_corrected_motor_commands[YAW] = -PWM_DIFF_BOUNDS;
}
else
......
......@@ -65,7 +65,7 @@ int startMPU9150(){
// Set clock reference to Z Gyro
iic0Write(0x6B, 0x03);
// Configure Digital Low/High Pass filter
iic0Write(0x1A,0x06); // Level 4 low pass on gyroscope
iic0Write(0x1A,0x06); // Level 6 low pass on gyroscope
// Configure Gyro to 2000dps, Accel. to +/-8G
iic0Write(0x1B, 0x18);
......
......@@ -24,13 +24,10 @@ int protection_loops(modular_structs_t *structs)
// wait until throttle is low and the gear switch is engaged (so you don't immediately break out of the main loop below)
// also wait for the flight mode to be set to manual
while(rc_commands[THROTTLE] > 125000 || read_kill(rc_commands[GEAR]) || !read_flap(rc_commands[FLAP]))
read_rec_all(rc_commands);
// wait until the ground station has connected to the quad and acknowledged that its ready to start
while (!structs->user_input_struct.receivedBeginUpdate) {
while(rc_commands[THROTTLE] > 125000 || read_kill(rc_commands[GEAR]) || !read_flap(rc_commands[FLAP]) ||
!structs->user_input_struct.receivedBeginUpdate) {
process_received(structs);
usleep(10000);
read_rec_all(rc_commands);
}
// let the pilot/observers know that the quad is now active
......
......@@ -143,7 +143,7 @@ void printLogging(){
);
strcat(buf,comments);
//strcat(buf,comments);
strcat(buf,header);
strcat(buf,units);
......
File added
File added
File added
......@@ -4,11 +4,14 @@ sortorder: 005
## Project Plan
[Project Plan 1](/files/ProjectPlan1Template.docx.pdf)
[Project Plan 1](/files/ProjectPlan1Template.docx.pdf)
[Project Plan 2](/files/ProjectPlanVersion2.pdf)
[Project Plan 3](/files/ProjectPlanVersion3.pdf)
## Design Document
[Design Document 1](/files/DesignDocument1.docx.pdf)
[Design Document 1](/files/DesignDocument1.docx.pdf)
[Design Document 2](/files/DesignDocument2.pdf)
## Weekly Reports
<iframe src="https://drive.google.com/embeddedfolderview?id=0BywzM7Q_7PUSeF8tdWpmMVN0eG8#list" width="100%" height="500" frameborder="0"></iframe>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment