当前位置:网站首页>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
边栏推荐
- Blazor 准备好为企业服务了吗?
- Fgagt: flow guided adaptive graph tracking
- 5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
- NOIP 2012 提高组 复赛 第一天 第二题 国王游戏 game 数学推导 AC代码(高精度 低精度 乘 除 比较)+60代码(long long)+20分代码(全排列+深搜dfs)
- Six key points of data science interview
- 进程、线程和协程的区别
- Is blazor ready to serve the enterprise?
- golang 匿名结构体成员,具名结构体成员,继承,组合
- Ulab 1.0.0 release
- 数据科学面试应关注的6个要点
猜你喜欢
More than 50 object detection datasets from different industries
laravel8更新之速率限制改进
C language I blog assignment 03
SQL Server 2008R2 18456 error resolution
Basic knowledge of C + +
Cloud Alibabab笔记问世,全网详解仅此一份手慢无
An error occurred while starting the kernel was successfully resolved
China Telecom announces 5g SA commercial scale in 2020
ASP.NET A complete solution based on exception handling in MVC
OSChina 周日乱弹 —— 之前呢,我一直以为自己是个……
随机推荐
UCGUI简介
The difference between vivoy 73s and glory 30 Youth Edition
QT hybrid Python development technology: Python introduction, hybrid process and demo
Fgagt: flow guided adaptive graph tracking
Oschina plays on Sunday - before that, I always thought I was a
Basic concepts of computer network (5) basic principles of local area network
Judging whether paths intersect or not by leetcode
golang 匿名结构体成员,具名结构体成员,继承,组合
Littlest JupyterHub| 02 使用nbgitpuller分发共享文件
数据科学面试应关注的6个要点
sed之查找替换
FORTRAN77从文件中读入若干数据并用heron迭代公式开方
Brief history of computer
C/C++编程笔记:C语言相比其他编程语言,有什么不一样的优势?
接口
Mouse small hand
分布式共识机制
Qt混合Python开发技术:Python介绍、混合过程和Demo
ts流中的pcr与pts计算与逆运算
Face recognition: attack types and anti spoofing techniques