APM飞控系统详细介绍
apm飞控入门教程

Apm 飞控较为详细的入门教程最近发现很多模友在看了泡泡老师的视频有很多细节没有看懂在群上提问,为了能使刚用上apm的模友一步到位,再来一个文字教程帮助你们快速使用。
在此也感谢apm2.8交流群中的冷风群主提供的教程~废话不多说了硬件安装1、通过USB接口供电时,如果USB数据处于连接状态,APM会切断数传接口的通讯功能,所以请不要同时使用数传和USB线连接调试APM,USB接口的优先级高于数传接口,仅有供电功能的USB线不在此限;2、APM板载的加速度传感器受震动影响,会产生不必要的动差,直接影响飞控姿态的计算,条件允许请尽量使用一个减震平台来安装APM主板;3、APM板载的高精气压计对温度的变化非常敏感,所以请尽量在气压计上覆盖一块黑色海绵用来遮光,以避免阳光直射的室外飞行环境下,光照热辐射对气压计的影响。
另外覆盖海绵,也可以避免飞行器自身气流对气压计的干扰。
使用建议对于初次使用APM自驾仪的用户来说,建议你分步骤完成APM的入门使用:1、首先安装地面站控制软件及驱动,熟悉地面站界面的各个菜单功能;2、仅连接USB线学会固件的下载;3、连接接收机和USB线完成APM的遥控校准、加速度校准和罗盘校准;4、完成各类参数的设定;5、组装飞机,完成各类安全检查后试飞;6、PID参数调整;7、APM各类高阶应用地面站调试软件Mission Planner安装首先,MissionPlanner的安装运行需要微软的Net Framework 4.0组件,所以在安装Mission Planner之前请先下载Net Flamework 4.0并安装安装完NetFramework后开始下载Mission Planner安装程序包,最新版本的Mission Planner可以点击此处下载,下载页面中每个版本都提供了MSI版和ZIP版可供选择。
MSI 为应用程序安装包版,安装过程中会同时安装APM的USB驱动,安装后插上APM的USB 线即可使用。
apm芯片

apm芯片APM芯片(Autopilot Module,自动驾驶模块)是一种用于无人机和飞行器的控制系统,它可以实现飞行器的自动导航、姿态稳定控制、飞行轨迹规划等功能。
APM芯片的优势在于其开放性和可自定义性,使用户可以根据特定需求进行二次开发和定制。
APM芯片的核心是一款开源硬件——APM飞控主板,它基于ARM Cortex-M系列的32位处理器,并集成了加速度计、陀螺仪、磁力计、气压计等传感器,以及无线通信模块。
通过APM飞控主板,用户可以将无人机与地面站连接,实现远程遥控和数据传输。
APM芯片的设计理念是模块化和可扩展性。
它提供了多个接口和插槽,以支持不同的传感器和设备的连接。
用户可以根据需要选择合适的模块,如GPS模块、超声波模块、红外线模块等,以实现特定的功能。
同时,APM芯片还提供了大量的软件库和开发工具,方便用户进行定制开发。
APM芯片在无人机领域有着广泛的应用。
它可以实现无人机的自动起飞、降落、悬停等基本功能,同时还支持航点和航线规划,使无人机可以在预设的路径上按序执行任务。
此外,APM芯片还具备姿态稳定控制功能,可以根据传感器数据对无人机的飞行姿态进行实时调整,确保稳定飞行。
除了无人机领域,APM芯片还可以应用于其他飞行器,如飞行汽车、航空器等。
它可以提供精准的导航和控制能力,确保飞行器的安全和可靠性。
在航空器市场日益火热的今天,APM芯片具有很大的潜力和市场前景。
尽管APM芯片具备很多优势,但也存在一些挑战和限制。
首先,APM芯片需要进行定制开发,对用户的技术要求较高。
其次,APM芯片的性能受硬件限制,无法满足一些高级应用的需求。
此外,APM芯片在应对复杂环境和异常情况时可能存在一定的局限性。
总之,APM芯片是一种功能强大且可定制的控制系统,在无人机和飞行器领域具有广泛的应用前景。
随着技术的不断进步和市场需求的增长,APM芯片有望进一步发展壮大,成为无人机控制领域的重要技术。
APM飞控介绍

Ardupilot飞控示意图
地面站软件系统
Ardupilot系统的地面控制站是一个运行在地面上
电脑中的应用程序,通过无线通信模块与无人机通 信,显示无人机实时性能和位置,显示载机仪表面 盘,实时发送飞行过程控制指令,上传新的任务命 令和设定参数,显示航拍实时视频流。目前较成熟 的Ardupilot地面站软件包括:APM Mission Planner、HappyKillmore、QGroundControl。
机械部分(无人机/汽车/机械手臂) Microcontroller(Arduino)
Serial Port/有线/无线网络
Server
Database:Sqlserver/Oracle/DB2
1. Web services (c#/VB/java/python) 2. Form Application(c#/VB/java/python)
相关技术说明
Arduino:是一个开放源代码的单芯片微电脑,它
使用了Atmel AVR单片机,采用了基于开放源代码 的软硬件平台,构建于开放源代码 simple I/O 接 口板,并且具有使用类似Java、C 语言的 Processing/Wiring开发环境。 MAVLINK:Micro Air Vehicle Link是一个用于小 型无人机的通信协议. 它是一个只有头文件信息的 类型库列集,MAVlink最早以 LGPL协议在2009年发 布。MAVLINK主要被用于地面站和无人机间通信, 可以用来传递方向、GPS位置、速度等信息。
一种开源的航空电磁法运载工具: Ardupilot无人机系统
江苏大学 计算机科学与通信工程学院 通信工程系 朱轶
无人机简介
无人机(Unmanned Aerial Vehicle,UAV)指借助遥
APM飞控程序解读

/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-#define THISFIRMWARE "ArduCopter V3.1-rc5"/*This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see </licenses/>.*//** ArduCopter Version 3.0* Creator: Jason Short* Lead Developer: Randy Mackay* Based on code and ideas from the Arducopter team: Pat Hickey, Jose Julio, Jani Hirvinen, Andrew Tridgell, Justin Beech, Adam Rivera, Jean-Louis Naudin, Roberto Navoni* Thanks to: Chris Anderson, Mike Smith, Jordi Munoz, Doug Weibel, James Goppert, Benjamin Pelletier, Robert Lefebvre, Marco Robustini** Special Thanks for Contributors (in alphabetical order by first name):** Adam M Rivera :Auto Compass Declination* Amilcar Lucas :Camera mount library* Andrew Tridgell :General development, Mavlink Support* Angel Fernandez :Alpha testing* Doug Weibel :Libraries* Christof Schmid :Alpha testing* Dani Saez :V Octo Support* Gregory Fletcher :Camera mount orientation math* Guntars :Arming safety suggestion* HappyKillmore :Mavlink GCS* Hein Hollander :Octo Support* Igor van Airde :Control Law optimization* Leonard Hall :Flight Dynamics, Throttle, Loiter and Navigation Controllers* Jonathan Challinger :Inertial Navigation* Jean-Louis Naudin :Auto Landing* Max Levine :Tri Support, Graphics* Jack Dunkle :Alpha testing* James Goppert :Mavlink Support* Jani Hiriven :Testing feedback* John Arne Birkeland :PPM Encoder* Jose Julio :Stabilization Control laws* Marco Robustini :Lead tester* Michael Oborne :Mission Planner GCS* Mike Smith :Libraries, Coding support* Oliver :Piezo support* Olivier Adler :PPM Encoder* Robert Lefebvre :Heli Support & LEDs* Sandro Benigno :Camera support** And much more so PLEASE PM me on DIYDRONES to add your contribution to the List** Requires modified "mrelax" version of Arduino, which can be found here:* /p/ardupilot-mega/downloads/list*////////////////////////////////////////////////////////////////////////////////// Header includes////////////////////////////////////////////////////////////////////////////////#include <math.h>#include <stdio.h>#include <stdarg.h>// Common dependencies#include <AP_Common.h>#include <AP_Progmem.h>#include <AP_Menu.h>#include <AP_Param.h>// AP_HAL#include <AP_HAL.h>#include <AP_HAL_AVR.h>#include <AP_HAL_AVR_SITL.h>#include <AP_HAL_PX4.h>#include <AP_HAL_FLYMAPLE.h>#include <AP_HAL_Linux.h>#include <AP_HAL_Empty.h>// Application dependencies#include <GCS_MAVLink.h> // MAVLink GCS definitions#include <AP_GPS.h> // ArduPilot GPS library#include <AP_GPS_Glitch.h> // 全球定位系统干扰保护库#include <DataFlash.h> // ArduPilot Mega Flash Memory Library#include <AP_ADC.h> // ArduPilot Mega Analog to Digital Converter Library#include <AP_ADC_AnalogSource.h>#include <AP_Baro.h>#include <AP_Compass.h> // ArduPilot Mega Magnetometer Library#include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library#include <AP_Curve.h> // Curve used to linearlise throttle pwm to thrust#include <AP_InertialSensor.h> // ArduPilot Mega Inertial Sensor (accel & gyro) Library #include <AP_AHRS.h>#include <APM_PI.h> // PI library#include <AC_PID.h> // PID library#include <RC_Channel.h> //遥控通道库#include <AP_Motors.h> // AP Motors library#include <AP_RangeFinder.h> // Range finder library#include <AP_OpticalFlow.h> // Optical Flow library#include <Filter.h> // Filter library#include <AP_Buffer.h> // APM FIFO Buffer#include <AP_Relay.h> // APM relay#include <AP_Camera.h> // Photo or video camera#include <AP_Mount.h> // Camera/Antenna mount#include <AP_Airspeed.h> // needed for AHRS build#include <AP_Vehicle.h> // needed for AHRS build#include <AP_InertialNav.h> // ArduPilot Mega inertial 导航 library#include <AC_WPNav.h> // ArduCopter waypoint navigation library#include <AP_Declination.h> // ArduPilot Mega Declination Helper Library#include <AC_Fence.h> // Arducopter Fence library#include <memcheck.h> // memory limit checker#include <SITL.h> // software in the loop support#include <AP_Scheduler.h> // 主循环调度程序#include <AP_RCMapper.h> // RC input mapping library#include <AP_Notify.h> // Notify library#include <AP_BattMonitor.h> // Battery monitor library#if SPRAYER == ENABLED#include <AC_Sprayer.h> // crop sprayer library// AP_HAL to Arduino compatibility layer#include "compat.h"// Configuration#include "defines.h"#include "config.h"#include "config_channels.h"// Local modules#include "Parameters.h"#include "GCS.h"//////////////////////////////////////////////////////////////////////////////// // cliSerial//////////////////////////////////////////////////////////////////////////////// // cliSerial isn't strictly necessary - it is an alias for hal.console. It may // be deprecated in favor of hal.console in later releases.static AP_HAL::BetterStream* cliSerial;// N.B. we need to keep a static declaration which isn't guarded by macros// at the top to cooperate with the prototype mangler.//////////////////////////////////////////////////////////////////////////////// // AP_HAL instance//////////////////////////////////////////////////////////////////////////////// const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;//////////////////////////////////////////////////////////////////////////////// // Parameters//////////////////////////////////////////////////////////////////////////////// //// Global parameters are all contained within the 'g' class.//static Parameters g;// main loop schedulerstatic AP_Scheduler scheduler;// AP_Notify instancestatic AP_Notify notify;//////////////////////////////////////////////////////////////////////////////// // prototypes//////////////////////////////////////////////////////////////////////////////// static void update_events(void);static void print_flight_mode(AP_HAL::BetterStream *port, uint8_t mode);//////////////////////////////////////////////////////////////////////////////// // Dataflash//////////////////////////////////////////////////////////////////////////////// #if CONFIG_HAL_BOARD == HAL_BOARD_APM2static DataFlash_APM2 DataFlash;#elif CONFIG_HAL_BOARD == HAL_BOARD_APM1static DataFlash_APM1 DataFlash;#elif CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL//static DataFlash_File DataFlash("/tmp/APMlogs");static DataFlash_SITL DataFlash;#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4static DataFlash_File DataFlash("/fs/microsd/APM/logs");#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUXstatic DataFlash_File DataFlash("logs");#elsestatic DataFlash_Empty DataFlash;#endif////////////////////////////////////////////////////////////////////////////////// the rate we run the main loop at////////////////////////////////////////////////////////////////////////////////static const AP_InertialSensor::Sample_rate ins_sample_rate = AP_InertialSensor::RATE_100HZ;////////////////////////////////////////////////////////////////////////////////// Sensors//////////////////////////////////////////////////////////////////////////////////// There are three basic options related to flight sensor selection.//// - Normal flight mode. Real sensors are used.// - HIL Attitude mode. Most sensors are disabled, as the HIL// protocol supplies attitude information directly.// - HIL Sensors mode. Synthetic sensors are configured that// supply data from the simulation.//// All GPS access should be through this pointer.static GPS *g_gps;static GPS_Glitch gps_glitch(g_gps);// flight modes convenience arraystatic AP_Int8 *flight_modes = &g.flight_mode1;#if HIL_MODE == HIL_MODE_DISABLED#if CONFIG_ADC == ENABLEDstatic AP_ADC_ADS7844 adc;#endif#if CONFIG_IMU_TYPE == CONFIG_IMU_MPU6000static AP_InertialSensor_MPU6000 ins;#elif CONFIG_IMU_TYPE == CONFIG_IMU_OILPANstatic AP_InertialSensor_Oilpan ins(&adc);#elif CONFIG_IMU_TYPE == CONFIG_IMU_SITLstatic AP_InertialSensor_HIL ins;#elif CONFIG_IMU_TYPE == CONFIG_IMU_PX4static AP_InertialSensor_PX4 ins;#elif CONFIG_IMU_TYPE == CONFIG_IMU_FLYMAPLEAP_InertialSensor_Flymaple ins;#elif CONFIG_IMU_TYPE == CONFIG_IMU_L3G4200DAP_InertialSensor_L3G4200D ins;#endif#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL// When building for SITL we use the HIL barometer and compass driversstatic AP_Baro_HIL barometer;static AP_Compass_HIL compass;static SITL sitl;#else// Otherwise, instantiate a real barometer and compass driver#if CONFIG_BARO == AP_BARO_BMP085static AP_Baro_BMP085 barometer;#elif CONFIG_BARO == AP_BARO_PX4static AP_Baro_PX4 barometer;#elif CONFIG_BARO == AP_BARO_MS5611#if CONFIG_MS5611_SERIAL == AP_BARO_MS5611_SPIstatic AP_Baro_MS5611 barometer(&AP_Baro_MS5611::spi);#elif CONFIG_MS5611_SERIAL == AP_BARO_MS5611_I2Cstatic AP_Baro_MS5611 barometer(&AP_Baro_MS5611::i2c);#else#error Unrecognized CONFIG_MS5611_SERIAL setting.#endif#endif#if CONFIG_HAL_BOARD == HAL_BOARD_PX4static AP_Compass_PX4 compass;#elsestatic AP_Compass_HMC5843 compass;#endif#endif// real GPS selection#if GPS_PROTOCOL == GPS_PROTOCOL_AUTOAP_GPS_Auto g_gps_driver(&g_gps);#elif GPS_PROTOCOL == GPS_PROTOCOL_NMEAAP_GPS_NMEA g_gps_driver;#elif GPS_PROTOCOL == GPS_PROTOCOL_SIRFAP_GPS_SIRF g_gps_driver;#elif GPS_PROTOCOL == GPS_PROTOCOL_UBLOXAP_GPS_UBLOX g_gps_driver;#elif GPS_PROTOCOL == GPS_PROTOCOL_MTKAP_GPS_MTK g_gps_driver;#elif GPS_PROTOCOL == GPS_PROTOCOL_MTK19AP_GPS_MTK19 g_gps_driver;#elif GPS_PROTOCOL == GPS_PROTOCOL_NONEAP_GPS_None g_gps_driver;#else#error Unrecognised GPS_PROTOCOL setting.#endif // GPS PROTOCOLstatic AP_AHRS_DCM ahrs(&ins, g_gps);#elif HIL_MODE == HIL_MODE_SENSORS// sensor emulatorsstatic AP_ADC_HIL adc;static AP_Baro_HIL barometer;static AP_Compass_HIL compass;static AP_GPS_HIL g_gps_driver;static AP_InertialSensor_HIL ins;static AP_AHRS_DCM ahrs(&ins, g_gps);#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL// When building for SITL we use the HIL barometer and compass drivers static SITL sitl;#endif#elif HIL_MODE == HIL_MODE_ATTITUDEstatic AP_ADC_HIL adc;static AP_InertialSensor_HIL ins;static AP_AHRS_HIL ahrs(&ins, g_gps);static AP_GPS_HIL g_gps_driver;static AP_Compass_HIL compass; // never usedstatic AP_Baro_HIL barometer;#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL// When building for SITL we use the HIL barometer and compass driversstatic SITL sitl;#endif#else#error Unrecognised HIL_MODE setting.#endif // HIL MODE////////////////////////////////////////////////////////////////////////////////// Optical flow sensor////////////////////////////////////////////////////////////////////////////////#if OPTFLOW == ENABLEDstatic AP_OpticalFlow_ADNS3080 optflow;#elsestatic AP_OpticalFlow optflow;#endif////////////////////////////////////////////////////////////////////////////////// GCS selection////////////////////////////////////////////////////////////////////////////////static GCS_MAVLINK gcs0;static GCS_MAVLINK gcs3;////////////////////////////////////////////////////////////////////////////////// SONAR selection//////////////////////////////////////////////////////////////////////////////////ModeFilterInt16_Size3 sonar_mode_filter(1);#if CONFIG_SONAR == ENABLEDstatic AP_HAL::AnalogSource *sonar_analog_source;static AP_RangeFinder_MaxsonarXL *sonar;#endif////////////////////////////////////////////////////////////////////////////////// User variables////////////////////////////////////////////////////////////////////////////////#ifdef USERHOOK_VARIABLES#include USERHOOK_VARIABLES#endif////////////////////////////////////////////////////////////////////////////////// Global variables/////////////////////////////////////////////////////////////////////////////////* Radio values* Channel assignments* 1 Ailerons (rudder if no ailerons)* 2 Elevator* 3 Throttle* 4 Rudder (if we have ailerons)* 5 Mode - 3 position switch* 6 User assignable* 7 trainer switch - sets throttle nominal (toggle switch), sets accels to Level (hold >1 second)* 8 TBD* Each Aux channel can be configured to have any of the available auxiliary functions assigned to it.* See libraries/RC_Channel/RC_Channel_aux.h for more information*///Documentation of GLobals:static union {struct {uint8_t home_is_set : 1; // 0uint8_t simple_mode : 2; // 1,2 // This is the state of simple mode : 0 = disabled ; 1 = SIMPLE ;2 = SUPERSIMPLEuint8_t pre_arm_rc_check : 1; // 3 // true if rc input pre-arm checks have been completed successfully uint8_t pre_arm_check : 1; // 4 // true if all pre-arm checks (rc, accel calibration, gps lock) have been performeduint8_t auto_armed : 1; // 5 // stops auto missions from beginning until throttle is raised uint8_t logging_started : 1; // 6 // true if dataflash logging has starteduint8_t do_flip : 1; // 7 // Used to enable flip codeuint8_t takeoff_complete : 1; // 8uint8_t land_complete : 1; // 9 // true if we have detected a landinguint8_t new_radio_frame : 1; // 10 // Set true if we have new PWM data to act on from the Radio uint8_t CH7_flag : 2; // 11,12 // ch7 aux switch : 0 is low or false, 1 is center or true, 2 is highuint8_t CH8_flag : 2; // 13,14 // ch8 aux switch : 0 is low or false, 1 is center or true, 2 is highuint8_t usb_connected : 1; // 15 // true if APM is powered from USB connectionuint8_t yaw_stopped : 1; // 16 // Used to manage the Yaw hold capabilitiesuint8_t disable_stab_rate_limit : 1; // 17 // disables limits rate request from the stability controlleruint8_t rc_receiver_present : 1; // 18 // true if we have an rc receiver present (i.e. if we've ever received an update};uint32_t value;} ap;////////////////////////////////////////////////////////////////////////////////// Radio////////////////////////////////////////////////////////////////////////////////// This is the state of the flight control system// There are multiple states defined such as STABILIZE, ACRO,static int8_t control_mode = STABILIZE;// Used to maintain the state of the previous control switch position// This is set to -1 when we need to re-read the switchstatic uint8_t oldSwitchPosition;static RCMapper rcmap;// receiver RSSIstatic uint8_t receiver_rssi;////////////////////////////////////////////////////////////////////////////////// Failsafe////////////////////////////////////////////////////////////////////////////////static struct {uint8_t rc_override_active : 1; // 0 // true if rc control are overwritten by ground stationuint8_t radio : 1; // 1 // A status flag for the radio failsafeuint8_t battery : 1; // 2 // A status flag for the battery failsafeuint8_t gps : 1; // 3 // A status flag for the gps failsafeuint8_t gcs : 1; // 4 // A status flag for the ground station failsafeint8_t radio_counter; // number of iterations with throttle below throttle_fs_valueuint32_t last_heartbeat_ms; // the time when the last HEARTBEAT message arrived from a GCS - used for triggering gcs failsafe} failsafe;////////////////////////////////////////////////////////////////////////////////// Motor Output////////////////////////////////////////////////////////////////////////////////#if FRAME_CONFIG == QUAD_FRAME#define MOTOR_CLASS AP_MotorsQuad#elif FRAME_CONFIG == TRI_FRAME#define MOTOR_CLASS AP_MotorsTri#elif FRAME_CONFIG == HEXA_FRAME#define MOTOR_CLASS AP_MotorsHexa#elif FRAME_CONFIG == Y6_FRAME#define MOTOR_CLASS AP_MotorsY6#elif FRAME_CONFIG == OCTA_FRAME#define MOTOR_CLASS AP_MotorsOcta#elif FRAME_CONFIG == OCTA_QUAD_FRAME#define MOTOR_CLASS AP_MotorsOctaQuad#elif FRAME_CONFIG == HELI_FRAME#define MOTOR_CLASS AP_MotorsHeli#else#error Unrecognised frame type#endif#if FRAME_CONFIG == HELI_FRAME // helicopter constructor requires more argumentsstatic MOTOR_CLASS motors(&g.rc_1, &g.rc_2, &g.rc_3, &g.rc_4, &g.rc_8, &g.heli_servo_1, &g.heli_servo_2,&g.heli_servo_3, &g.heli_servo_4);#elif FRAME_CONFIG == TRI_FRAME // tri constructor requires additional rc_7 argument to allow tail servo reversing static MOTOR_CLASS motors(&g.rc_1, &g.rc_2, &g.rc_3, &g.rc_4, &g.rc_7);#elsestatic MOTOR_CLASS motors(&g.rc_1, &g.rc_2, &g.rc_3, &g.rc_4);#endif////////////////////////////////////////////////////////////////////////////////// PIDs////////////////////////////////////////////////////////////////////////////////// This is a convienience accessor for the IMU roll rates. It's currently the raw IMU rates// and not the adjusted omega rates, but the name is stuckstatic Vector3f omega;// This is used to hold radio tuning values for in-flight CH6 tuningfloat tuning_value;// used to limit the rate that the pid controller output is logged so that it doesn't negatively affect performance static uint8_t pid_log_counter;////////////////////////////////////////////////////////////////////////////////// LED output////////////////////////////////////////////////////////////////////////////////// Blinking indicates GPS statusstatic uint8_t copter_leds_GPS_blink;// Blinking indicates battery statusstatic uint8_t copter_leds_motor_blink;// Navigation confirmation blinksstatic int8_t copter_leds_nav_blink;////////////////////////////////////////////////////////////////////////////////// GPS variables////////////////////////////////////////////////////////////////////////////////// This is used to scale GPS values for EEPROM storage// 10^7 times Decimal GPS means 1 == 1cm// This approximation makes calculations integer and it's easy to readstatic const float t7 = 10000000.0;// We use atan2 and other trig techniques to calaculate angles// We need to scale the longitude up to make these calcs work// to account for decreasing distance between lines of longitude away from the equatorstatic float scaleLongUp = 1;// Sometimes we need to remove the scaling for distance calcsstatic float scaleLongDown = 1;////////////////////////////////////////////////////////////////////////////////// Location & Navigation////////////////////////////////////////////////////////////////////////////////// This is the angle from the copter to the next waypoint in centi-degreesstatic int32_t wp_bearing;// The original bearing to the next waypoint. used to point the nose of the copter at the next waypoint static int32_t original_wp_bearing;// The location of home in relation to the copter in centi-degreesstatic int32_t home_bearing;// distance between plane and home in cmstatic int32_t home_distance;// distance between plane and next waypoint in cm.static uint32_t wp_distance;// navigation mode - options include NAV_NONE, NAV_LOITER, NAV_CIRCLE, NAV_WPstatic uint8_t nav_mode;// Register containing the index of the current navigation command in the mission scriptstatic int16_t command_nav_index;// Register containing the index of the previous navigation command in the mission script// Used to manage the execution of conditional commandsstatic uint8_t prev_nav_index;// Register containing the index of the current conditional command in the mission scriptstatic uint8_t command_cond_index;// Used to track the required WP navigation information// options include// NAV_ALTITUDE - have we reached the desired altitude?// NAV_LOCATION - have we reached the desired location?// NAV_DELAY - have we waited at the waypoint the desired time?static float lon_error, lat_error; // Used to report how many cm we are from the next waypoint or loiter target positionstatic int16_t control_roll;static int16_t control_pitch;static uint8_t rtl_state; // records state of rtl (initial climb, returning home, etc)static uint8_t land_state; // records state of land (flying to location, descending)////////////////////////////////////////////////////////////////////////////////// Orientation(方向)////////////////////////////////////////////////////////////////////////////////// Convienience accessors for commonly used trig functions. These values are generated// by the DCM through a few simple equations. They are used throughout the code where cos and sin// would normally be used.// The cos values are defaulted to 1 to get a decent initial value for a level statestatic float cos_roll_x = 1.0;static float cos_pitch_x = 1.0;static float cos_yaw = 1.0;static float sin_yaw;static float sin_roll;static float sin_pitch;////////////////////////////////////////////////////////////////////////////////// SIMPLE Mode////////////////////////////////////////////////////////////////////////////////// Used to track the orientation of the copter for Simple mode. This value is reset at each arming// or in SuperSimple mode when the copter leaves a 20m radius from home.static float simple_cos_yaw = 1.0;static float simple_sin_yaw;static int32_t super_simple_last_bearing;static float super_simple_cos_yaw = 1.0;static float super_simple_sin_yaw;// Stores initial bearing when armed - initial simple bearing is modified in super simple mode so not suitable static int32_t initial_armed_bearing;////////////////////////////////////////////////////////////////////////////////// Rate contoller targets////////////////////////////////////////////////////////////////////////////////static uint8_t rate_targets_frame = EARTH_FRAME; // indicates whether rate targets provided in earth or body framestatic int32_t roll_rate_target_ef;static int32_t pitch_rate_target_ef;static int32_t yaw_rate_target_ef;static int32_t roll_rate_target_bf; // body frame roll rate targetstatic int32_t pitch_rate_target_bf; // body frame pitch rate targetstatic int32_t yaw_rate_target_bf; // body frame yaw rate target////////////////////////////////////////////////////////////////////////////////// Throttle(风门,调节) variables////////////////////////////////////////////////////////////////////////////////static int16_t throttle_accel_target_ef; // earth frame throttle acceleration targetstatic bool throttle_accel_controller_active; // true when accel based throttle controller is active, false when higher level throttle controllers are providing throttle output directlystatic float throttle_avg; // g.throttle_cruise as a floatstatic int16_t desired_climb_rate; // pilot desired climb rate - for logging purposes onlystatic float target_alt_for_reporting; // target altitude in cm for reporting (logs and ground station)////////////////////////////////////////////////////////////////////////////////// ACRO(高) Mode////////////////////////////////////////////////////////////////////////////////// Used to control Axis lockstatic int32_t acro_roll; // desired roll angle while sport modestatic int32_t acro_roll_rate; // desired roll rate while in acro modestatic int32_t acro_pitch; // desired pitch angle while sport modestatic int32_t acro_pitch_rate; // desired pitch rate while acro modestatic int32_t acro_yaw_rate; // desired yaw rate while acro modestatic float acro_level_mix; // scales back roll, pitch and yaw inversely proportional to input from pilot// Filters#if FRAME_CONFIG == HELI_FRAME//static LowPassFilterFloat rate_roll_filter; // Rate Roll filter//static LowPassFilterFloat rate_pitch_filter; // Rate Pitch filter#endif // HELI_FRAME////////////////////////////////////////////////////////////////////////////////// Circle Mode / Loiter(走停) control////////////////////////////////////////////////////////////////////////////////Vector3f circle_center; // circle position expressed in cm from home location. x = lat, y = lon// angle from the circle center to the copter's desired location. Incremented at circle_rate / secondstatic float circle_angle;// the total angle (in radians) travelledstatic float circle_angle_total;// deg : how many times to circle as specified by mission commandstatic uint8_t circle_desired_rotations;static float circle_angular_acceleration; // circle mode's angular accelerationstatic float circle_angular_velocity; // circle mode's angular velocitystatic float circle_angular_velocity_max; // circle mode's max angular velocity// How long we should stay in Loiter Mode for mission scripting (time in seconds)static uint16_t loiter_time_max;// How long have we been loitering - The start time in millisstatic uint32_t loiter_time;////////////////////////////////////////////////////////////////////////////////// CH7 and CH8 save waypoint(航路点) control////////////////////////////////////////////////////////////////////////////////// This register tracks the current Mission Command index when writing// a mission using Ch7 or Ch8 aux switches in flightstatic int8_t aux_switch_wp_index;////////////////////////////////////////////////////////////////////////////////// Battery Sensors////////////////////////////////////////////////////////////////////////////////static AP_BattMonitor battery;////////////////////////////////////////////////////////////////////////////////// Altitude////////////////////////////////////////////////////////////////////////////////// The (throttle) controller desired altitude in cmstatic float controller_desired_alt;// The cm we are off in altitude from next_WP.alt – Positive value means we are below the WP static int32_t altitude_error;// The cm/s we are moving up or down based on filtered data - Positive = UPstatic int16_t climb_rate;// The altitude as reported by Sonar in cm – Values are 20 to 700 generally.static int16_t sonar_alt;static uint8_t sonar_alt_health; // true if we can trust the altitude from the sonarstatic float target_sonar_alt; // desired altitude in cm above the ground// The altitude as reported by Baro in cm – Values can be quite highstatic int32_t baro_alt;static int16_t saved_toy_throttle;////////////////////////////////////////////////////////////////////////////////// flight modes////////////////////////////////////////////////////////////////////////////////// Flight modes are combinations of Roll/Pitch, Yaw and Throttle control modes// Each Flight mode is a unique combination of these modes//// The current desired control scheme for Yawstatic uint8_t yaw_mode;// The current desired control scheme for roll and pitch / navigationstatic uint8_t roll_pitch_mode;// The current desired control scheme for altitude holdstatic uint8_t throttle_mode;////////////////////////////////////////////////////////////////////////////////// flight specific////////////////////////////////////////////////////////////////////////////////// An additional throttle added to keep the copter at the same altitude when banking。
详细的APM飞控调试资料

调整ArduCopter 参数如果你使用的机身不是官方ArduCopter 套件,你可能需要改变一些PID设置(PID 是比例-积分- 微分的简称,是一个标准的控制方法。
更多的资料在这里)。
在此页底部的有一个PID的全面的指导.你可以在任务规划器的配置选项卡中以交互方式调整PID:基本性能故障排除•我的多旋翼在稳定模式下缓慢震荡(大幅运动): 降低 STABILIZE_ROLL_P,STABILIZE_PITCH_P.•我的多旋翼在稳定模式下***震荡(小幅运动): 降低 RATE_ROLL_P, RATE_PITCH_P。
•我的飞机过于迟钝:降低 RATE_ROLL_P,RATE_PITCH_P,和/或增加 STABILIZE_ROLL_P, STABILIZE_PITCH_P.•我调整了 Rate_P,还是不行:也许你的 STABILIZE_P gain 增益过高。
降低一点(见上文),并再次尝试调整 RATE_P.•我的飞机在起飞时向左或向右旋转15°:你的电机不直或着电调没有校准。
扭转电机,直到他们都直了。
运行ESC校准程序。
•激烈飞行后我的飞机偏向一方 10 - 30°:如该文所述,焊接 IMU 的滤波器U。
你可以在 system.pde 里调整漂移校正。
如果需要,大概调高0。
5.此外,降落30秒,然后继续飞行。
•我的飞机无法在空中保持完全静止:确保在飞机的重心在正中心。
然后在水平面上运行水平命令(保持关闭状态15秒,调用该功能).你也可以在无风的环境(重要)使用自动微调模式飞行。
任何风将导致四轴旋转180度后你的修改产生相反的作用。
你可以使用遥控俯仰和横滚微调,但记得在用配置工具设置遥控时,要把它们放回中心.我不喜欢使用发射微调,但永远不要使用偏航微调.(四轴也很容易受到紊流的影响。
他们将需要不断的修正,除非你安装一个光流传感器。
某天……)•我的飞机飞行很好,但后来在悬停时一条电机臂奇怪地下降了:你的电机坏了。
APM Flight Modes 飞行模式介绍(超详细)

APM Flight Modes 飞行模式介绍概述多旋翼(直升机)一共有14 个内置的飞行模式,10个的常用的。
飞行模式可以通过遥控器控制,也可以通过GCS地面站进行发送命令更改遥控器和地面站都可以同时控制飞行模式,通常以最后一个命令为准推荐使用的飞行模式一般来讲,当第一次使用APM:Copter的时候,你应该依次使用下列飞行模式获得提高,要保证熟练了再进行下一个。
点击下方任意飞行模式可获得更多信息。
•Stabilize (增稳模式)•Alt Hold (定高模式、高度保持模式)•Loiter (悬停模式)•RTL (Return-to-Launch) (回家模式:返回起飞点)•Auto (自动模式:自动航点飞行,需要依靠GPS)其他飞行模式:•Acro 特技模式(没有飞控辅助增稳的模式)•AutoTune 自动微调(当飞机往一个严重偏的时候,可以执行自动微调)•Brake 刹车锁定模式(将飞机锁定在一个位置,而不受遥控器摇杆影响)•Circle 绕圈模式(绕着兴趣点画圈)•Drift 漂移模式•Guided 引导模式Guided_NoGPS 引导模式-不需要GPS•Land 降落模式•PosHold 定点模式•Sport 运动模块•Throw 抛飞模式(把无人机抛在空中,自动起飞稳定)•Follow Me 跟随模式(无人机跟着你飞行,但是需要GPS和手机地面站配合)•Simple and Super Simple (简单和超级简单模式)•Avoid_ADSB (基于ADSB的避让载人飞机模式。
需要外界ADSB模块)•大多数遥控器只有一个三段开关,所以只能设置三种模式。
如果需要设置6种模式,可以进行开关混控需要依赖GPS的飞行模式:有些飞行模式需要依赖GPS才能飞行,你可以通过状态灯或者地面站获知GPS 是否已经锁定。
以下飞行模式需要GPS锁定才能解锁飞行:•Loiter 悬停模式•RTL (Return-to-Launch) 回家模式•Auto 自动模式•Guided 引导模式•Drift 漂移模式•PosHold 定点模式•Follow Me 跟随模式•Circle 绕圈模式•Throw 抛飞模式不需要依赖GPS锁定的飞行模式:•Stabilize 自稳模式•Alt Hold 定高模式•Acro 特技模式•Sport 运动模式•Land 降落模式全部模式列表:(点击对应的模式查看详解)•Acro Mode•Altitude Hold Mode•Auto Mode•Brake Mode•Circle Mode•Drift Mode•Follow Me Mode (GSC Enabled)•Guided Mode•Land Mode•Loiter Mode•PosHold Mode•Position Mode•RTL Mode•Simple and Super Simple Modes•Sport Mode•Stabilize Mode•Throw ModeStabilize增稳模式概述:•飞手用roll与pitch操作控制飞行器的倾斜角度。
APM飞控介绍范文

APM飞控介绍范文APM(ArduPilot Mega)飞控是一款开源的无人机飞行控制器,使用Arduino Mega 2560开发板和ATmega2560微控制器进行控制。
它可以支持多种飞行器类型,包括多旋翼、固定翼、直升机、车辆和船只等,且适用于初学者和专业人士。
APM飞控的功能非常强大,具备多种传感器与功能模块的接口,包括陀螺仪、加速度计、罗盘、GPS、气压计、导航模块、通信模块等。
这些传感器和模块提供了飞行姿态稳定性、位置定位、导航、高度控制、避障等功能。
APM飞控使用可视化的图形用户界面(Ground Control Station,简称GCS)来进行配置和控制。
用户可以通过电脑、手机或平板等设备与APM飞控进行通信,实时获取飞行数据,在线调整参数和模式,进行飞行计划等。
1.多种飞行器类型支持:APM飞控可以支持各种飞行器类型的控制,包括四旋翼、六旋翼、八旋翼、固定翼、直升机等。
通过选择不同的飞行器类型,用户可以针对不同的应用场景进行配置和飞行。
2.多种飞行模式:APM飞控支持多种飞行模式,包括手动模式、稳定模式、姿态模式、定高模式、定点模式、跟随模式、航点模式等。
用户可以根据需求选择不同的飞行模式,以实现自由飞行、稳定飞行、自动飞行等功能。
3.导航和定位功能:APM飞控可以通过GPS进行导航和定位,实现自动驾驶功能。
用户可以设置航点和航线,飞行器能够自动按照设定的航线进行飞行,同时实时在GCS上显示当前位置和飞行状态。
4.传感器和稳定性:APM飞控配备了陀螺仪、加速度计和罗盘等传感器,能够实时获取飞行器的姿态信息。
通过PID控制算法和传感器反馈,可以实现飞行器的姿态稳定和控制。
5.遥控器和数据链路:APM飞控支持与遥控器和数据链路进行通信和控制。
用户可以通过遥控器操控飞行器的飞行,实现手动控制、姿态控制等功能。
同时,用户还可以通过数据链路将APM飞控与地面站进行通信,实时获取飞行数据和调整参数。
APM飞行模式解说

APM飞行模式注解ELEV是俯仰或升降 1通道对 PitchAILE是横滚或副翼 2通道对 RollTHRO是油门 3通道对 ThrottlRUDD是方向 4通道对 Yaw红正黑负白信号,红正棕负橙信号Pitch 俯仰 Roll 横滚 Throttl 油门 Yaw 方向1、稳定模式Stabilize稳定模式是使用得最多的飞行模式,也是最基本的飞行模式,起飞和降落都应该使用此模式。
此模式下,飞控会让飞行器保持稳定,是初学者进行一般飞行的首选,也是FPV第一视角飞行的最佳模式。
一定要确保遥控器上的开关能很方便无误地拨到该模式,应急时会非常重要。
2、比率控制模式Acro这个是非稳定模式,这时apm将完全依托遥控器遥控的控制,新手慎用。
3、定高模式ALT_HOLD定高模式(Alt Hold)是使用自动油门,试图保持目前的高度的稳定模式。
定高模式时高度仍然可以通过提高或降低油门控制,但中间会有一个油门死区,油门动作幅度超过这个死区时,飞行器才会响应你的升降动作当进入任何带有自动高度控制的模式,你目前的油门将被用来作为调整油门保持高度的基准。
在进入高度保持前确保你在悬停在一个稳定的高度。
飞行器将随着时间补偿不良的数值。
只要它不会下跌过快,就不会有什么问题。
离开高度保持模式时请务必小心,油门位置将成为新的油门,如果不是在飞行器的中性悬停位置,将会导致飞行器迅速下降或上升。
在这种模式下你不能降落及关闭马达,因为现在是油门摇杆控制高度,而非马达。
请切换到稳定模式,才可以降落和关闭马达。
4、自动模式 AUTO自动模式下,飞行器将按照预先设置的任务规划控制它的飞行由于任务规划依赖GPS的定位信息,所以在解锁起飞前,必须确保GPS已经完成定位(APM 板上蓝色LED常亮)切换到自动模式有两种情况:如果使用自动模式从地面起飞,飞行器有一个安全机制防止你误拨到自动模式时误启动发生危险,所以需要先手动解锁并手动推油门起飞。
起飞后飞行器会参考你最近一次ALT Hold 定高的油门值作为油门基准,当爬升到任务规划的第一个目标高度后,开始执行任务规划飞向目标;如果是空中切换到自动模式,飞行器首先会爬升到第一目标的高度然后开始执行任务6、悬停模式Loiter悬停模式是GPS定点+气压定高模式。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
APM飞控系统详细介绍
APM飞控系统的硬件部分主要由处理器、传感器模块和扩展模块组成。
处理器采用32位的ARM Cortex-M4内核,性能强大,能够处理复杂的算
法和控制逻辑。
传感器模块包括加速度计、陀螺仪、磁力计、气压计等,
用于测量无人机的姿态、运动状态和环境参数。
扩展模块可以根据具体需
求增加,如GPS模块、无线通信模块等,可以实现定位和遥控功能。
APM飞控系统的软件部分主要由固件和地面站软件组成。
固件是嵌入
在硬件中的软件程序,实现了飞行控制算法和导航功能。
固件基于开源协
议发布,可以在开源社区中进行开发和修改。
地面站软件是一款PC端软件,用于与无人机通信、调试和飞行参数的设置。
地面站软件支持Windows、Mac和Linux等多个操作系统,用户可以通过USB或无线通信
与飞控系统进行交互。
APM飞控系统具有多种飞行模式,包括手动模式、稳定模式、定高模式、定点模式、自动模式等。
手动模式下,飞行员可以通过遥控器直接控
制飞行器的姿态和运动。
稳定模式下,飞控系统会自动控制飞行器保持平
稳飞行。
定高模式下,飞行器会自动控制飞行高度,保持稳定飞行。
定点
模式下,飞行器会自动控制飞行位置,保持固定的坐标。
自动模式下,飞
行器会根据用户设置的任务点和航线自主飞行。
APM飞控系统还支持一系列高级功能,如航点导航、飞行轨迹规划、
跟踪目标、自主避障等。
航点导航功能可以实现无人机按照预设的航点序
列自主飞行。
飞行轨迹规划功能可以根据用户设置的起始点和目标点规划
最优飞行路径。
跟踪目标功能可以通过视觉或无线信号识别目标物体并进
行跟踪飞行。
自主避障功能可以根据传感器获取的环境信息进行障碍物的
避让。
这些高级功能大大增强了无人机的自主性和智能性。
总之,APM飞控系统是一款功能强大、灵活可扩展的飞行控制系统。
它广泛应用于无人机领域,可用于各种类型的飞行器,包括多旋翼、固定翼和垂直起降等。
作为开源项目,APM飞控系统吸引了众多开发者和爱好者的参与,形成了庞大的用户社区,用户可以从社区获取和共享各种有用的资源和经验。
随着技术的发展,APM飞控系统的性能和功能还将不断提升,为无人机的应用和发展提供更加完善的解决方案。