当前位置:网站首页>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
边栏推荐
- Swiper window width changes, page width height changes lead to automatic sliding solution
- 面部识别:攻击类型和反欺骗技术
- Face recognition: attack types and anti spoofing techniques
- 解决RabbitMQ消息丢失与重复消费问题
- 什么你的电脑太渣?这几招包你搞定! (Win10优化教程)
- Cloud Alibabab笔记问世,全网详解仅此一份手慢无
- Distributed consensus mechanism
- Which is more worth starting with the difference between vivos7e and vivos7
- Wanxin Finance
- 盘点那些你没想到的云计算应用场景(上)
猜你喜欢
“智能5G”引领世界,数位智能网优+5G能带来什么?
QT hybrid Python development technology: Python introduction, hybrid process and demo
微信昵称emoji表情,特殊表情导致列表不显示,导出EXCEL报错等问题解决!
Daily challenges of search engines_ 4_ External heterogeneous resources - Zhihu
模板链表类学习
Seven features of Python 3.9
IOS learning note 2 [problems and solutions encountered during the installation and use of cocopods] [update 20160725]
C++在C的基础上改进了哪些细节
C / C + + Programming Notes: what are the advantages of C compared with other programming languages?
0.计算机简史
随机推荐
蓝牙2.4G产品日本MIC认证的测试要求
vivoy73s和荣耀30青春版的区别
高并发,你真的理解透彻了吗?
Review the cloud computing application scenarios you didn't expect (Part 1)
C++基础知识篇:C++ 基本语法
5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
C语言I博客作业03
More than 50 object detection datasets from different industries
搜索引擎的日常挑战_4_外部异构资源 - 知乎
OSChina 周日乱弹 —— 之前呢,我一直以为自己是个……
Swiper window width changes, page width height changes lead to automatic sliding solution
Macquarie Bank drives digital transformation with datastex enterprise (DSE)
Unparseable date: 'Mon Aug 15 11:24:39 CST 2016',时间格式转换异常
QT hybrid Python development technology: Python introduction, hybrid process and demo
归纳一些比较好用的函数
These core technology of object-oriented, after you master it, you can have a good interview
1. In depth istio: how is sidecar auto injection realized?
Experience the latest version of erofs on Ubuntu
Learn Scala if Else statement
【原创】关于高版本poi autoSizeColumn方法异常的情况