当前位置:网站首页>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
边栏推荐
- Python learning Day1 -- Basic Learning
- Mate 40 series launch with Huawei sports health service to bring healthy digital life
- sed之查找替换
- How can a technician take over a complex system?
- C++在C的基础上改进了哪些细节
- ubuntu实时显示cpu、内存占用率
- 到底选openstack还是vmware?
- 分布式共识机制
- More than 50 object detection datasets from different industries
- Qt混合Python开发技术:Python介绍、混合过程和Demo
猜你喜欢
Cloud Alibabab笔记问世,全网详解仅此一份手慢无
Fgagt: flow guided adaptive graph tracking
vivoy73s和荣耀30青春版的区别
将“光头”识别为“足球”,AI 摄像头如何犯的错?
How can a technician take over a complex system?
Oschina plays on Sunday - before that, I always thought I was a
1. In depth istio: how is sidecar auto injection realized?
Template linked list learning
Is there a big difference between i5 1135g7 and i51035g1? Which is better?
python学习 day1——基础学习
随机推荐
November 07, 2020: given an array of positive integers, the sum of two numbers equals N and must exist. How to find the two numbers with the smallest multiplication?
[summary series] technical system of Internet server: high performance database index
How can a technician take over a complex system?
The software in your host has terminated an established connection. resolvent
C语言I博客作业03
Application of bidirectional LSTM in outlier detection of time series
What is the difference between vivoy73s and vivoy70s
在Ubuntu上体验最新版本EROFS
python 循环区分(while循环和for循环)
Judging whether paths intersect or not by leetcode
laravel8更新之速率限制改进
vivoY73s和vivoY70s的区别 vivoY73s和vivoY70s哪个值得入手
阅读心得:FGAGT: Flow-Guided Adaptive Graph Tracking
Golang anonymous structure member, named structure member, inheritance, composition
盘点那些你没想到的云计算应用场景(上)
Qt混合Python开发技术:Python介绍、混合过程和Demo
SQL Server 2008R2 18456错误解决方案
Qt混合Python开发技术:Python介绍、混合过程和Demo
搜索引擎的日常挑战_4_外部异构资源 - 知乎
M 端软件产品设计思虑札记 - 知乎