知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏壧峁┍憬莸闹С郑?
向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)案例查看更多
相關(guān)閱讀
- 搜索引擎排名
- web學(xué)習(xí)路線
- 模版消息
- 開發(fā)微信小程序
- 搜索引擎優(yōu)化
- 快排推廣
- 小程序技術(shù)
- 保山小程序開發(fā)
- 汽車回收系統(tǒng)
- 排名
- 國內(nèi)知名網(wǎng)站建設(shè)公司排名
- 服務(wù)器
- 微信分銷
- 汽車回收管理系統(tǒng)
- 云南百度小程序
- 云南小程序制作
- python開發(fā)小程序
- 汽車報(bào)廢管理系統(tǒng)
- 云南網(wǎng)站建設(shè)靠譜公司
- 云南網(wǎng)站建設(shè)
- 云南小程序開發(fā)制作
- 汽車回收管理
- 昆明小程序公司
- web教程
- 出入小程序
- 網(wǎng)絡(luò)公司報(bào)價(jià)
- 重慶網(wǎng)站建設(shè)公司
- 汽車報(bào)廢回收
- 云南網(wǎng)站建設(shè)費(fèi)用
- 昆明做網(wǎng)站