欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

向Ardupilot中添加新的飛行模式(以ArduSub為例) - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開發(fā)/軟件開發(fā)

知識

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏壧峁┍憬莸闹С郑?

您當(dāng)前位置>首頁 » 新聞資訊 » 技術(shù)分享 >

向Ardupilot中添加新的飛行模式(以ArduSub為例)

發(fā)表時(shí)間:2020-10-19

發(fā)布人:葵宇科技

瀏覽次數(shù):131

本次以ArduSub為例介紹若何向APM固件中添加新的飛翔模式以便利后續(xù)開辟,其他車輛類型操作類似,本篇也可用作參考。

參考材料:

Adding a New Flight Mode

Creating newflight mode in Ardusub


起首在ardupilot/ArduSub/文件路徑下,新建一個(gè)用于添加新的飛翔模式的文件control_newMode.cpp。然后,向內(nèi)部添加代碼如下:

#include "Sub.h"

bool Sub::newmode_init()
{
	return true;
}

void Sub::newmode_init()
{

}

保存退出之后,進(jìn)入ardupilot/libraries/AP_JSButton/AP_JSBottton.h,找到k_mode_xxx情勢的模式定義如下:

        k_mode_manual           = 5,            ///< enter enter manual mode
        k_mode_stabilize        = 6,            ///< enter stabilize mode
        k_mode_depth_hold       = 7,            ///< enter depth hold mode
        k_mode_poshold          = 8,            ///< enter poshold mode
        k_mode_auto             = 9,            ///< enter auto mode
        k_mode_circle           = 10,           ///< enter circle mode
        k_mode_guided           = 11,           ///< enter guided mode
        k_mode_acro             = 12,           ///< enter acro mode
        k_mode_newmode			= 13,			///...

在最后添加你的新模式,我這里選擇的數(shù)字為13(只要不跨越后面參數(shù)的值21即可)。然后添加你對應(yīng)的備注。

回到ardupilot/ArduSub/defines.h文件中,找到control_mode_t列舉類型定義,在最后面添加你的新模式,并添加備注描述

// Auto Pilot Modes enumeration
enum control_mode_t {
    STABILIZE =     0,  // manual angle with manual depth/throttle
    ACRO =          1,  // manual body-frame angular rate with manual depth/throttle
    ALT_HOLD =      2,  // manual angle with automatic depth/throttle
    AUTO =          3,  // fully automatic waypoint control using mission commands
    GUIDED =        4,  // fully automatic fly to coordinate or fly at velocity/direction using GCS immediate commands
    CIRCLE =        7,  // automatic circular flight with automatic throttle
    SURFACE =       9,  // automatically return to surface, pilot maintains horizontal control
    POSHOLD =      16,  // automatic position hold with manual override, with automatic throttle
    MANUAL =       19,  // Pass-through input with no stabilization
    MOTOR_DETECT = 20,  // Automatically detect motors orientation
	NEWMODE =	   21	// ...
};

再進(jìn)入ardupilot/ArduSub/Sub.h,向內(nèi)部添加代碼段如下(理論上是可以在隨便率性地位,然則最好添加在其余飛翔模式的旁邊)

bool newmode_init(void);
void newmode_run();

然后在ardupilot/ArduSub/flight_mode.cpp中,對set_mode()和update_flight_mode()辦法進(jìn)行修改,具體就是在switch函數(shù)下面添加對應(yīng)的case情況函數(shù)。

// 在set_mode()辦法中
    case NEWMODE:
    	success = newmode_init();
    	break;
...
///在update_flight_mode()辦法中
    case NEWMODE:
    	success = newmode_run();
    	break;

最后,在ardupilot/ArduSub/joystick.cpp中,找到

void Sub::handle_jsbutton_press(uint8_t button, bool shift, bool held)

在個(gè)中的switch-case語句中的default前添加

    case JSButton::button_function_t::k_mode_newmode:
    	set_mode(NEWMODE, MODE_REASON_TX_COMMAND);

然后保存退出即可。


編譯

cd ardupilot/
rm -rf build/
./waf configure --board Pixhawk1
./waf sub

編譯成功!

在這里插入圖片描述
后續(xù)工作是若何使QGC可以或許辨認(rèn)出新的飛翔模式,今朝尚在研究中。也可推敲應(yīng)用mavros或者pymavlink進(jìn)行后續(xù)的開辟生發(fā)火業(yè)。今朝先研究到這~

相關(guān)案例查看更多