APM飞控程序解读.docx

上传人:b****5 文档编号:7435595 上传时间:2023-05-11 格式:DOCX 页数:66 大小:37.07KB
下载 相关 举报
APM飞控程序解读.docx_第1页
第1页 / 共66页
APM飞控程序解读.docx_第2页
第2页 / 共66页
APM飞控程序解读.docx_第3页
第3页 / 共66页
APM飞控程序解读.docx_第4页
第4页 / 共66页
APM飞控程序解读.docx_第5页
第5页 / 共66页
APM飞控程序解读.docx_第6页
第6页 / 共66页
APM飞控程序解读.docx_第7页
第7页 / 共66页
APM飞控程序解读.docx_第8页
第8页 / 共66页
APM飞控程序解读.docx_第9页
第9页 / 共66页
APM飞控程序解读.docx_第10页
第10页 / 共66页
APM飞控程序解读.docx_第11页
第11页 / 共66页
APM飞控程序解读.docx_第12页
第12页 / 共66页
APM飞控程序解读.docx_第13页
第13页 / 共66页
APM飞控程序解读.docx_第14页
第14页 / 共66页
APM飞控程序解读.docx_第15页
第15页 / 共66页
APM飞控程序解读.docx_第16页
第16页 / 共66页
APM飞控程序解读.docx_第17页
第17页 / 共66页
APM飞控程序解读.docx_第18页
第18页 / 共66页
APM飞控程序解读.docx_第19页
第19页 / 共66页
APM飞控程序解读.docx_第20页
第20页 / 共66页
亲,该文档总共66页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

APM飞控程序解读.docx

《APM飞控程序解读.docx》由会员分享,可在线阅读,更多相关《APM飞控程序解读.docx(66页珍藏版)》请在冰点文库上搜索。

APM飞控程序解读.docx

APM飞控程序解读

///-*-tab-width:

4;Mode:

C++;c-basic-offset:

4;indent-tabs-mode:

nil-*-

#defineTHISFIRMWARE"ArduCopterV3.1-rc5"

/*

Thisprogramisfreesoftware:

youcanredistributeitand/ormodify

itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby

theFreeSoftwareFoundation,eitherversion3oftheLicense,or

(atyouroption)anylaterversion.

Thisprogramisdistributedinthehopethatitwillbeuseful,

butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof

MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe

GNUGeneralPublicLicenseformoredetails.

YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense

alongwiththisprogram.Ifnot,see

//www.gnu.org/licenses/>.

*/

/*

*ArduCopterVersion3.0

*Creator:

JasonShort

*LeadDeveloper:

RandyMackay

*BasedoncodeandideasfromtheArducopterteam:

PatHickey,JoseJulio,JaniHirvinen,AndrewTridgell,JustinBeech,AdamRivera,Jean-LouisNaudin,RobertoNavoni

*Thanksto:

ChrisAnderson,MikeSmith,JordiMunoz,DougWeibel,JamesGoppert,BenjaminPelletier,RobertLefebvre,MarcoRobustini

*

*SpecialThanksforContributors(inalphabeticalorderbyfirstname):

*

*AdamMRivera:

AutoCompassDeclination

*AmilcarLucas:

Cameramountlibrary

*AndrewTridgell:

Generaldevelopment,MavlinkSupport

*AngelFernandez:

Alphatesting

*DougWeibel:

Libraries

*ChristofSchmid:

Alphatesting

*DaniSaez:

VOctoSupport

*GregoryFletcher:

Cameramountorientationmath

*Guntars:

Armingsafetysuggestion

*HappyKillmore:

MavlinkGCS

*HeinHollander:

OctoSupport

*IgorvanAirde:

ControlLawoptimization

*LeonardHall:

FlightDynamics,Throttle,LoiterandNavigationControllers

*JonathanChallinger:

InertialNavigation

*Jean-LouisNaudin:

AutoLanding

*MaxLevine:

TriSupport,Graphics

*JackDunkle:

Alphatesting

*JamesGoppert:

MavlinkSupport

*JaniHiriven:

Testingfeedback

*JohnArneBirkeland:

PPMEncoder

*JoseJulio:

StabilizationControllaws

*MarcoRobustini:

Leadtester

*MichaelOborne:

MissionPlannerGCS

*MikeSmith:

Libraries,Codingsupport

*Oliver:

Piezosupport

*OlivierAdler:

PPMEncoder

*RobertLefebvre:

HeliSupport&LEDs

*SandroBenigno:

Camerasupport

*

*AndmuchmoresoPLEASEPMmeonDIYDRONEStoaddyourcontributiontotheList

*

*Requiresmodified"mrelax"versionofArduino,whichcanbefoundhere:

*

*

*/

////////////////////////////////////////////////////////////////////////////////

//Headerincludes

////////////////////////////////////////////////////////////////////////////////

#include

#include

#include

//Commondependencies

#include

#include

#include

#include

//AP_HAL

#include

#include

#include

#include

#include

#include

#include

//Applicationdependencies

#include//MAVLinkGCSdefinitions

#include//ArduPilotGPSlibrary

#include//全球定位系统干扰保护库

#include//ArduPilotMegaFlashMemoryLibrary

#include//ArduPilotMegaAnalogtoDigitalConverterLibrary

#include

#include

#include//ArduPilotMegaMagnetometerLibrary

#include//ArduPilotMegaVector/MatrixmathLibrary

#include//Curveusedtolinearlisethrottlepwmtothrust

#include//ArduPilotMegaInertialSensor(accel&gyro)Library

#include

#include//PIlibrary

#include//PIDlibrary

#include//遥控通道库

#include//APMotorslibrary

#include//Rangefinderlibrary

#include//OpticalFlowlibrary

#include//Filterlibrary

#include//APMFIFOBuffer

#include//APMrelay

#include//Photoorvideocamera

#include//Camera/Antennamount

#include//neededforAHRSbuild

#include//neededforAHRSbuild

#include//ArduPilotMegainertial导航library

#include//ArduCopterwaypointnavigationlibrary

#include//ArduPilotMegaDeclinationHelperLibrary

#include//ArducopterFencelibrary

#include//memorylimitchecker

#include//softwareintheloopsupport

#include//主循环调度程序

#include//RCinputmappinglibrary

#include//Notifylibrary

#include//Batterymonitorlibrary

#ifSPRAYER==ENABLED

#include//cropsprayerlibrary

#endif

//AP_HALtoArduinocompatibilitylayer

#include"compat.h"

//Configuration

#include"defines.h"

#include"config.h"

#include"config_channels.h"

//Localmodules

#include"Parameters.h"

#include"GCS.h"

////////////////////////////////////////////////////////////////////////////////

//cliSerial

////////////////////////////////////////////////////////////////////////////////

//cliSerialisn'tstrictlynecessary-itisanaliasforhal.console.Itmay

//bedeprecatedinfavorofhal.consoleinlaterreleases.

staticAP_HAL:

:

BetterStream*cliSerial;

//N.B.weneedtokeepastaticdeclarationwhichisn'tguardedbymacros

//atthetoptocooperatewiththeprototypemangler.

////////////////////////////////////////////////////////////////////////////////

//AP_HALinstance

////////////////////////////////////////////////////////////////////////////////

constAP_HAL:

:

HAL&hal=AP_HAL_BOARD_DRIVER;

////////////////////////////////////////////////////////////////////////////////

//Parameters

////////////////////////////////////////////////////////////////////////////////

//

//Globalparametersareallcontainedwithinthe'g'class.

//

staticParametersg;

//mainloopscheduler

staticAP_Schedulerscheduler;

//AP_Notifyinstance

staticAP_Notifynotify;

 

////////////////////////////////////////////////////////////////////////////////

//prototypes

////////////////////////////////////////////////////////////////////////////////

staticvoidupdate_events(void);

staticvoidprint_flight_mode(AP_HAL:

:

BetterStream*port,uint8_tmode);

////////////////////////////////////////////////////////////////////////////////

//Dataflash

////////////////////////////////////////////////////////////////////////////////

#ifCONFIG_HAL_BOARD==HAL_BOARD_APM2

staticDataFlash_APM2DataFlash;

#elifCONFIG_HAL_BOARD==HAL_BOARD_APM1

staticDataFlash_APM1DataFlash;

#elifCONFIG_HAL_BOARD==HAL_BOARD_AVR_SITL

//staticDataFlash_FileDataFlash("/tmp/APMlogs");

staticDataFlash_SITLDataFlash;

#elifCONFIG_HAL_BOARD==HAL_BOARD_PX4

staticDataFlash_FileDataFlash("/fs/microsd/APM/logs");

#elifCONFIG_HAL_BOARD==HAL_BOARD_LINUX

staticDataFlash_FileDataFlash("logs");

#else

staticDataFlash_EmptyDataFlash;

#endif

 

////////////////////////////////////////////////////////////////////////////////

//theratewerunthemainloopat

////////////////////////////////////////////////////////////////////////////////

staticconstAP_InertialSensor:

:

Sample_rateins_sample_rate=AP_InertialSensor:

:

RATE_100HZ;

////////////////////////////////////////////////////////////////////////////////

//Sensors

////////////////////////////////////////////////////////////////////////////////

//

//Therearethreebasicoptionsrelatedtoflightsensorselection.

//

//-Normalflightmode.Realsensorsareused.

//-HILAttitudemode.Mostsensorsaredisabled,astheHIL

//protocolsuppliesattitudeinformationdirectly.

//-HILSensorsmode.Syntheticsensorsareconfiguredthat

//supplydatafromthesimulation.

//

//AllGPSaccessshouldbethroughthispointer.

staticGPS*g_gps;

staticGPS_Glitchgps_glitch(g_gps);

//flightmodesconveniencearray

staticAP_Int8*flight_modes=&g.flight_mode1;

#ifHIL_MODE==HIL_MODE_DISABLED

#ifCONFIG_ADC==ENABLED

staticAP_ADC_ADS7844adc;

#endif

#ifCONFIG_IMU_TYPE==CONFIG_IMU_MPU6000

staticAP_InertialSensor_MPU6000ins;

#elifCONFIG_IMU_TYPE==CONFIG_IMU_OILPAN

staticAP_InertialSensor_Oilpanins(&adc);

#elifCONFIG_IMU_TYPE==CONFIG_IMU_SITL

staticAP_InertialSensor_HILins;

#elifCONFIG_IMU_TYPE==CONFIG_IMU_PX4

staticAP_InertialSensor_PX4ins;

#elifCONFIG_IMU_TYPE==CONFIG_IMU_FLYMAPLE

AP_InertialSensor_Flymapleins;

#elifCONFIG_IMU_TYPE==CONFIG_IMU_L3G4200D

AP_InertialSensor_L3G4200Dins;

#endif

#ifCONFIG_HAL_BOARD==HAL_BOARD_AVR_SITL

//WhenbuildingforSITLweusetheHILbarometerandcompassdrivers

staticAP_Baro_HILbarometer;

staticAP_Compass_HILcompass;

staticSITLsitl;

#else

//Otherwise,instantiatearealbarometerandcompassdriver

#ifCONFIG_BARO==AP_BARO_BMP085

staticAP_Baro_BMP085barometer;

#elifCONFIG_BARO==AP_BARO_PX4

staticAP_Baro_PX4barometer;

#elifCONFIG_BARO==AP_BARO_MS5611

#ifCONFIG_MS5611_SERIAL==AP_BARO_MS5611_SPI

staticAP_Baro_MS5611barometer(&AP_Baro_MS5611:

:

spi);

#elifCONFIG_MS5611_SERIAL==AP_BARO_MS5611_I2C

staticAP_Baro_MS5611barometer(&AP_Baro_MS5611:

:

i2c);

#else

#errorUnrecognizedCONFIG_MS5611_SERIALsetting.

#endif

#endif

#ifCONFIG_HAL_BOARD==HAL_BOARD_PX4

staticAP_Compass_PX4compass;

#else

staticAP_Compass_HMC5843compass;

#endif

#endif

//realGPSselection

#ifGPS_PROTOCOL==GPS_PROTOCOL_AUTO

AP_GPS_Autog_gps_driver(&g_gps);

#elifGPS_PROTOCOL==GPS_PROTOCOL_NMEA

AP_GPS_NMEAg_gps_driver;

#elifGPS_PRO

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2