当前位置:网站首页>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
边栏推荐
- Which is more worth starting with the difference between vivos7e and vivos7
- i5 1135g7和i5 1035g1参数对比区别大吗? 哪个好
- 5G+AR出圈,中国移动咪咕成第33届中国电影金鸡奖全程战略合作伙伴
- Face recognition: attack types and anti spoofing techniques
- C语言I博客作业03
- wanxin金融
- More than 50 object detection datasets from different industries
- Basic knowledge of C + +
- Golang anonymous structure member, named structure member, inheritance, composition
- python_ scrapy_ Fang Tianxia
猜你喜欢

Goland 编写含有template的程序

分布式共识机制

What is the difference between vivoy73s and vivoy70s

麦格理银行借助DataStax Enterprise (DSE) 驱动数字化转型

Oschina plays on Sunday - before that, I always thought I was a

Simple use of future in Scala

来自不同行业领域的50多个对象检测数据集

1.深入Istio:Sidecar自动注入如何实现的?

python_scrapy_房天下

Experience the latest version of erofs on Ubuntu
随机推荐
C++基础知识篇:C++ 基本语法
2020-11-07:已知一个正整数数组,两个数相加等于N并且一定存在,如何找到两个数相乘最小的两个数?
Python loop distinction (while loop and for loop)
接口
5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
Abnormal + Abstract
Cloud alibabab notes come out, the whole network detailed explanation only this one hand is slow
Golang anonymous structure member, named structure member, inheritance, composition
M 端软件产品设计思虑札记 - 知乎
nvm
What is the difference between vivoy73s and vivoy70s
python学习 day1——基础学习
Unparseable date: 'mon Aug 15 11:24:39 CST 2016', time format conversion exception
Is there a big difference between i5 1135g7 and i51035g1? Which is better?
More than 50 object detection datasets from different industries
归纳一些比较好用的函数
来自不同行业领域的50多个对象检测数据集
Six key points of data science interview
Python learning Day1 -- Basic Learning
ts流中的pcr与pts计算与逆运算