当前位置:网站首页>PX4添加新的应用
PX4添加新的应用
2020-11-08 08:54:00 【osc_zzg7fpke】
研究了四天怎么添加新的应用程序,前几天都尝试着添加.cpp文件的应用程序,跟着网上的方法都失败了,结果今天试着添加一个.c文件的应用程序居然成功了。
先把.c的添加方法写一写,以后学会了怎么添加.cpp了再来修改吧。
这是官方手册给的添加方法,也是我参考的:
https://dev.px4.io/master/zh/apps/hello_sky.html
一、新建文件
在src下想要的文件夹(如/src/modules 或 /src/examples)中新建一个文件夹,我这里选择在/src/modules中新建一个名为Data_link_read的文件夹。
然后在Data_link_read文件夹中新建一个.c文件和一个CMakeLists.txt文件:

这里建议文件夹名和.c文件名相同
二、写.c和CMakeLists.txt文件
.c如下写:
__EXPORT int Data_link_read_main(int argc, char *argv[]);
int Data_link_read_main(int argc, char *argv[]) { return OK; }
为了避免添加头文件的困扰,我先把官方手册中的 PX4_INFO("Hello Sky!"); 这条语句删了,毕竟我们的目的是新建一个应用程序而以,先追求编译通过,再来考虑让这个应用程序实现一些功能吧!
CMakeLists.txt如下写:
px4_add_module(
MODULE modules__Data_link_read
MAIN Data_link_read
STACK_MAIN 2000
SRCS
Data_link_read.c
DEPENDS
)
*注意:CMakeLists.txt第二行MODULE后面跟着的“modules”是因为我选择了src下的modules文件夹,如果你选择examples,那么就应该写:
MODULE examples__Data_link_read
*题外话:在/PX4-Autopilot/cmake文件夹下的若干个px4_XXX.cmake文件中都有一些关于格式的解释,可以参考一下
三、填写.cmake文件
为了保证我们添加的这个应用程序可以被运行,你首先需要确保编译器会将它作为 PX4 固件的一部分进行编译。
因此要把我们的应用程序添加到/PX4-Autopilot/boards/px4/fmu-v5文件夹中的default.cmake文件中:

这里我们在MODULES下添加我们的应用程序。(如果你的应用程序写在了在examples文件夹中,那么需要就把应用程序添加到EXAMPLES下)。
*注意:这里我选择的是/px4/fmu-v5文件夹下的default.cmake文件,这是因为我在终端(terminal)中编译时用到的语句是make px4_fmu-v5_default。因此,如果你编译时用到的不是px4_fmu-v5,请选择对应文件夹下的default.cmake添加应用程序!
版权声明
本文为[osc_zzg7fpke]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4309973/blog/4707900
边栏推荐
- Windows subsystem Ubuntu installation
- Windows下子系统Ubuntu安装
- SQL Server 2008R2 18456 error resolution
- China Telecom announces 5g SA commercial scale in 2020
- M 端软件产品设计思虑札记 - 知乎
- [summary series] technical system of Internet server: high performance database index
- 5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
- C++基础知识篇:C++ 基本语法
- Python loop distinction (while loop and for loop)
- Cloud alibabab notes come out, the whole network detailed explanation only this one hand is slow
猜你喜欢

盘点那些你没想到的云计算应用场景(上)

i5 1135g7和i5 1035g1参数对比区别大吗? 哪个好

Distributed consensus mechanism

Goland 编写含有template的程序

“智能5G”引领世界,数位智能网优+5G能带来什么?

ASP.NET A complete solution based on exception handling in MVC

将“光头”识别为“足球”,AI 摄像头如何犯的错?

Sum up some useful functions

计算机网络基本概念(五)局域网基本原理

Littlest jupyterhub| 02 using nbgitpuller to distribute shared files
随机推荐
C++在C的基础上改进了哪些细节
来自不同行业领域的50多个对象检测数据集
UCGUI简介
PCR and PTS calculation and inverse operation in TS stream
Swiper window width changes, page width height changes lead to automatic sliding solution
C++基础知识篇:C++ 基本语法
Solve the problem of rabbitmq message loss and repeated consumption
[summary series] technical system of Internet server: high performance database index
微信昵称emoji表情,特殊表情导致列表不显示,导出EXCEL报错等问题解决!
京淘项目知识点总结
数据科学面试应关注的6个要点
5g/4g工业无线路由器
These core technology of object-oriented, after you master it, you can have a good interview
c# 表达式树(一)
什么你的电脑太渣?这几招包你搞定! (Win10优化教程)
How can a technician take over a complex system?
nvm
python_scrapy_房天下
鼠标变小手
M 端软件产品设计思虑札记 - 知乎