APM 学习 12 --- Linux 下学习库示例

本文介绍了如何在Linux环境下利用ArduPilot的UART_test示例进行APM飞控的深入开发。首先,通过指令查看可用示例,接着以UART_test为例,详细阐述了从源码阅读、修改到编译下载的全过程,并通过串口调试助手验证代码正常运行,帮助读者掌握APM飞控的调试技巧。
摘要由CSDN通过智能技术生成

        为了方便大家深入了解飞控工作原理与编程,ArduPilot 提供了许多示例,位于 /Library 文件中,本文将以串口为例,为大家展示如何利用这些示例进一步深入开发 APM 飞控。

官方文档内容,方便大家对照查阅:https://ardupilot.org/dev/docs/learning-ardupilot-the-example-sketches.html

1,首先进入源码主目录,如何了解目前有哪里示例可以使用呢 ?通过如下指令:

./waf list | grep 'examples'

 系统将会列出可以使用的示例,随着版本的更新,示例将会越来越多。

2,我们将以 UART_test 为例,演示整个调试流程, 找到示例源码 UART_test.cpp,位于

/ardupilot/libraries/AP_HAL/examples/UART_test/UART_test.cpp

打开源代码,可以看到内容是重复输出代码编号


void loop(void)
{
    test_uart(hal.uartA, "uartA");
    test_uart(hal.uartB, "uartB");
    test_uart(hal.uartC, "uartC");
    test_uart(hal.uartD, "uartD");
    test_uart(hal.uartE, "uartE");

    // also do a raw printf() on some platforms, which prints to the
    // debug console
#if HAL_OS_POSIX_IO
    ::printf("Hello on debug console at %.3f seconds\n", (double)(AP_HAL::millis() * 0.001f));
#endif

    hal.scheduler->delay(1000);
}

3,尝试修改程序,然后编译程序并且下载

3.1,回到源码主目录

3.2,配置硬件,一般不变化不用重新配置,使用指令    ./waf configure --board px4-v2

root@ubuntu:/home/saffron/lrr/ardupilot# ./waf configure --board px4-v2
Setting top to                           : /home/saffron/lrr/ardupilot 
Setting out to                           : /home/saffron/lrr/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : px4-v2 
Checking for program 'arm-none-eabi-ar'  : /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-ar 
Using toolchain                          : arm-none-eabi 
Checking for 'g++' (C++ compiler)        : /usr/lib/ccache/arm-none-eabi-g++ 
Checking for 'gcc' (C compiler)          : /usr/l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值