PX4应用实例1:HelloWorld!

本文档详细介绍了如何在PX4中创建一个名为HelloWorld的应用实例。首先在Firmware/src/examples/helloworld目录下创建helloworld.c文件,实现简单的输出功能。接着,配置CMakeLists.txt以将模块添加到PX4系统。然后,修改cmake配置文件,将helloworld.c路径添加进去。完成这些步骤后,通过执行编译和上传命令进行编译和部署。最后,在TeraTerm中设置串口通信,确保波特率正确,并在nsh命令行中运行helloworld指令,成功输出Hello World。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 创建文件helloworld.c

利用eclipse,在Firmware/src/examples下新建一个文件夹,命名为helloworld,里面创建一个helloworld.c,该程序是在输入helloworld命令的时候输出Hello World:

#include <px4_config.h>
#include <px4_tasks.h>
#include <px4_posix.h>
#include <unistd.h>
#include <stdio.h>
#include <poll.h>
#include <string.h>


__EXPORT int helloworld_main(int argc, char *argv[]);

int helloworld_main(int argc,char *argv[])
{
        PX4_INFO("Hello World!");
        return OK;
}

2. 创建CMakeLists.txt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值