UavHeightControl_onboard.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00029
00030
00035
00036
00037 #ifndef UAV_HEIGHTCONTROL_ONBOARD_TASK_H_
00038 #define UAV_HEIGHTCONTROL_ONBOARD_TASK_H_
00039
00040 #include <Task.h>
00041 #include <Resource.h>
00042 #include <Uav.h>
00043 #include <CommonOptions.h>
00044 #include <Keyboard.h>
00045
00046 #include <iostream>
00047
00048 #ifndef MIP_PLATFORM_ARM
00049 #include <DraWin.h>
00050 #endif
00051
00052 #define M2INCH 0.0254
00053
00054 namespace MipTasks{
00055
00057
00058
00062 enum UavHeiConOnboardStates{
00063 UAV_HEIGHT_CONTROL_ONBOARD_FIRST_RUN,
00064 UAV_HEIGHT_CONTRO_ONBOARDL_NORMAL_RUN,
00065 UAV_HEIGHT_CONTROL_ONBOARD_ONOFF_MOTORS,
00066 UAV_HEIGHT_CONTROL_ONBOARD_STATES_NUM
00067 };
00068
00071 static const char* UavHeiConOnboardStatesNames[UAV_HEIGHT_CONTROL_ONBOARD_STATES_NUM] = {
00072 "FirstRun",
00073 "NormalRun_pid",
00074 "OnOffMotors"
00075 };
00076
00077
00080 class UavHeiConOnboardOptions : public Options {
00081 public:
00082 DecimalOption* Kp;
00083 DecimalOption* Kd;
00084 DecimalOption* Ki;
00085
00086 DecimalOption* height_ref;
00087
00089 UavHeiConOnboardOptions();
00090
00091 string getObjectName() const {
00092 return "UavHeiConOnboardOptions";
00093 }
00094 };
00095
00096
00100 class UavHeiConOnboard : public Task{
00101 private:
00102
00104 static const TaskPlate _plate = OHC_TASK;
00105
00107 static const long int _maxDurSec = 0, _maxDurUsec = 100000;
00108 static const long int _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 20000;
00109 static const long int _minSamplPeriodSec = 0, _minSamplPeriodUsec = 10000;
00110
00112 Uav* _uav;
00113
00115 UavHeiConOnboardOptions _options;
00116
00118 UavHeiConOnboardStates _state;
00119
00121 void _firstRun();
00122 void _normalRun();
00123 void _onoff_motors();
00124
00126 void readInput();
00127
00129 Decimal Kp;
00130 Decimal Kd;
00131 Decimal Ki;
00132
00133 Decimal last_quad_time;
00134
00136 Decimal posZ_des;
00137
00139 Time t_motor;
00140
00141 Keyboard* _keyboard;
00142
00144 ofstream logfile;
00145 public:
00147 UavHeiConOnboard(ResourcePointers resources,int argc, const char* argv[]);
00148
00150 ~UavHeiConOnboard();
00151
00154 TaskPlate getPlate() const {
00155 return _plate;
00156 }
00158 Time getMaxDuration(){
00159 return Time(_maxDurSec,_maxDurUsec);
00160 }
00162 Time getMaxSamplPeriod(){
00163 return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00164 }
00166 Time getMinSamplPeriod(){
00167 return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00168 }
00169
00171 TaskOutputs run();
00172 };
00173
00174
00175
00176
00177 };
00178
00179 #endif
00180
00181
00182
00183
00184