StoRC
Autonomous Payload Delivery System
|
00001 /*********************************************************** 00002 * StoRC - Search to Rescue Craft 00003 * MEAM Senior Design 2011-2012 00004 * 00005 * Authors: Michael Posner (CIS, MEAM '12) 00006 * Timothy Hennelly (ESE '12) 00007 * Jacob Orloff (MEAM '12) 00008 * 00009 * (some code from ArduPilot Mega project, found here: 00010 * http://code.google.com/p/ardupilot-mega/ ) 00011 * 00012 * Licensing: 00013 * 00014 * This program is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU General Public License as published by 00016 * the Free Software Foundation, either version 3 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ***********************************************************/ 00028 00029 /** 00030 * @file controls.h 00031 * @brief Controls header file, contains all controls variables, gains, constants, etc. 00032 * @author Michael Posner (CIS, MEAM '12) 00033 * @author Timothy Hennelly (ESE '12) 00034 * @author Jacob Orloff (MEAM '12) 00035 * 00036 */ 00037 00038 // Definitions -------------------------------------------- 00039 00040 // Navigation 00041 #define KP_PSI2PHI 0.25 ///< 45deg of bank / 180deg of error 00042 00043 // Target: North-eastern baseball diamond: 00044 #define target_LAT 399878890 // Commanded latitude (x10^7) 00045 #define target_LON -752113880 // Commanded longitude (x10^7) 00046 00047 //point out by GM, tree circle 00048 //#define target_LAT 399521260 00049 //#define target_LON -751914850 00050 00051 //southwest corner of hill field 00052 //#define target_LAT 399535800 00053 //#define target_LON -751918300 00054 00055 // A Little further out if we wanna change things up: 00056 //#define LAT_C 399882430 // Commanded latitude (x10^7) 00057 //#define LON_C -752103750 // Commanded longitude (x10^7) 00058 00059 // Tolerance radius squared 00060 //#define TRS (DELT_M2GPS_LON(10)*DELT_M2GPS_LON(10)) ///< tolerance radius around drop location (10m)^2 00061 //#define TRS 9000000 // ~ 30 m? 00062 #define DROP_THRESH 400 00063 00064 // Throttle Control 00065 #define KP_THR 50.0 00066 #define KI_THR 10.0 00067 00068 // Rudder Control 00069 #define KP_RUD 5.0 00070 #define KD_RUD 3.0 00071 #define KI_RUD 1.0 00072 00073 // Elevator Control 00074 #define KP_RP 0.05 00075 #define KP_ELE 40.0//120.0//60.0 00076 #define KI_ELE 10.0//100.0 00077 00078 //Variables ---------------------------------------------- 00079 int throttle_mix_result = 0; ///< Additional rc control to add to the rudder based on throttle 00080 00081 unsigned long ptimer = 0; ///< Perturbation timer for step input perturbation routine 00082 00083 // Controls switch variables to detect when they go low to high: 00084 int sw1 = 0; // Throttle 00085 int sw2 = 0; // Rudder 00086 00087 // Navigation 00088 long dist2drop = 10000000; 00089 long LAT_C = target_LAT; 00090 long LON_C = target_LON; 00091 long del_LAT = 1000000; 00092 long del_LON = 1000000; 00093 float psi_c = 0.0; 00094 float psi_error = 0; 00095 00096 // Elevator Control 00097 int del_ELE = 0; 00098 float I_ELE = 0; 00099 int rc_ele_trim = 1500; 00100 float kp_ele_gm = 1.0; 00101 float ki_ele_gm = 1.0; 00102 float q_c = 0.0; // commanded 00103 float q = 0.0; 00104 float alpha_q = 0.5;//0.0385;// 0.0196; 00105 float q_filtered = 0.0; 00106 00107 // Throttle Control 00108 int updated_ALT = 0; 00109 float old_ALT = 0; 00110 float new_ALT = 0; 00111 float del_ALT = 0; 00112 int del_THR = 0; 00113 int I_THR = 0; 00114 int rc_thr_trim = 1500; 00115 float kp_thr_gm = 1.0; // gain multiplier determined by rc6 00116 float ki_thr_gm = 1.0; 00117 00118 // Rudder Control 00119 int del_RUD = 0; 00120 int I_RUD = 0; 00121 int rc_rud_trim = 1500; 00122 float kp_rud_gm = 1.0; // gain multiplier determined by rc6 00123 float kd_rud_gm = 1.0; 00124 float ki_rud_gm = 1.0; 00125 int phi_c = 0; // commanded phi based on rudder stick rc input