pixhawk/px4如何获取及使用传感器数据

113 篇文章 175 订阅


第一步:读取传感器数据

上一篇博文已经介绍了如何给pixhawk/px4创建一个应用程序,现在我们在上一个应用程序的基础上使用传感器数据。

应用程序为了实现一些有用的功能,需要订阅输入和发布输出(比如电机或舵机输出的命令)。注意在这里,PX4平台真正的硬件抽象的概念在这里体现---当硬件平台或者传感器升级更新,你完全不需要和传感器驱动打交道,也不需要更新你的应用程序或者更新传感器驱动程序。

PX4中,应用程序间发送信息的独立通道叫做“topics”,在本教程中,我们关心的话题是“多传感器间的uORB消息机制”(sensor_combinedtopic)。这些消息机制使得整个系统能够同步传感器数据。

订阅一个消息十分快速简洁:

  1. #include<uORB/topics/sensor_combined.h>  
  2.   
  3. ..  
  4.   
  5. int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));  
#include<uORB/topics/sensor_combined.h>

..

int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));

sensor_sub_fd”是一个消息句柄,能够十分有效处理新数据的到来之前的延迟等待。当前线程会休眠,直到新的传感器数据到来时,被调度器唤醒,并且在等待时不需要占用任何的CPU时间。为了实现这个功能,我们使用poll()函数POSIX系统调用。

在消息读取中加入“poll()”机制,完整程序如下

  1. /**************************************************************************** 
  2.  * 
  3.  *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. 
  4.  * 
  5.  * Redistribution and use in source and binary forms, with or without 
  6.  * modification, are permitted provided that the following conditions 
  7.  * are met: 
  8.  * 
  9.  * 1. Redistributions of source code must retain the above copyright 
  10.  *    notice, this list of conditions and the following disclaimer. 
  11.  * 2. Redistributions in binary form must reproduce the above copyright 
  12.  *    notice, this list of conditions and the following disclaimer in 
  13.  *    the documentation and/or other materials provided with the 
  14.  *    distribution. 
  15.  * 3. Neither the name PX4 nor the names of its contributors may be 
  16.  *    used to endorse or promote products derived from this software 
  17.  *    without specific prior written permission. 
  18.  * 
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  20.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  21.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  22.  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  23.  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  24.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
  25.  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
  26.  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
  27.  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  28.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  29.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  30.  * POSSIBILITY OF SUCH DAMAGE. 
  31.  * 
  32.  ****************************************************************************/  
  33.   
  34. /** 
  35.  * @file px4_simple_app.c 
  36.  * Minimal application example for PX4 autopilot 
  37.  * 
  38.  * @author Example User <mail@example.com> 
  39.  */  
  40.   
  41. #include <px4_config.h>  
  42. #include <px4_tasks.h>  
  43. #include <px4_posix.h>  
  44. #include <unistd.h>  
  45. #include <stdio.h>  
  46. #include <poll.h>  
  47. #include <string.h>  
  48.   
  49. #include <uORB/uORB.h>  
  50. #include <uORB/topics/sensor_combined.h>  
  51. #include <uORB/topics/vehicle_attitude.h>  
  52.   
  53. __EXPORT int px4_simple_app_main(int argc, char *argv[]);  
  54.   
  55. int px4_simple_app_main(int argc, char *argv[])  
  56. {  
  57.     /* subscribe to sensor_combined topic */  
  58.     int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));  
  59.     orb_set_interval(sensor_sub_fd, 1000);  
  60.   
  61.   
  62.   
  63.     /* one could wait for multiple topics with this technique, just using one here */  
  64.     px4_pollfd_struct_t fds[] = {  
  65.         { .fd = sensor_sub_fd,   .events = POLLIN },  
  66.         /* there could be more file descriptors here, in the form like: 
  67.          * { .fd = other_sub_fd,   .events = POLLIN }, 
  68.          */  
  69.     };  
  70.   
  71.     int error_counter = 0;  
  72.   
  73.     for (int i = 0; i < 5; i++) {  
  74.         /* wait for sensor update of 1 file descriptor for 1000 ms (1 second) */  
  75.         int poll_ret = px4_poll(fds, 1, 1000);  
  76.   
  77.         /* handle the poll result */  
  78.         if (poll_ret == 0) {  
  79.             /* this means none of our providers is giving us data */  
  80.             PX4_ERR("[px4_simple_app] Got no data within a second");  
  81.   
  82.         } else if (poll_ret < 0) {  
  83.             /* this is seriously bad - should be an emergency */  
  84.             if (error_counter < 10 || error_counter % 50 == 0) {  
  85.                 /* use a counter to prevent flooding (and slowing us down) */  
  86.                 PX4_ERR("[px4_simple_app] ERROR return value from poll(): %d"  
  87.                     , poll_ret);  
  88.             }  
  89.   
  90.             error_counter++;  
  91.   
  92.         } else {  
  93.   
  94.             if (fds[0].revents & POLLIN) {  
  95.                 /* obtained data for the first file descriptor */  
  96.                 struct sensor_combined_s raw;  
  97.                 /* copy sensors raw data into local buffer */  
  98.                 orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);  
  99.                 PX4_WARN("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f",  
  100.                      (double)raw.accelerometer_m_s2[0],  
  101.                      (double)raw.accelerometer_m_s2[1],  
  102.                      (double)raw.accelerometer_m_s2[2]);  
  103.   
  104.             }  
  105.   
  106.         }  
  107.     }  
  108.         PX4_INFO("exiting");  
  109.     return 0;  
  110. }  
/****************************************************************************
 *
 *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file px4_simple_app.c
 * Minimal application example for PX4 autopilot
 *
 * @author Example User <mail@example.com>
 */

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

#include <uORB/uORB.h>
#include <uORB/topics/sensor_combined.h>
#include <uORB/topics/vehicle_attitude.h>

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

int px4_simple_app_main(int argc, char *argv[])
{
	/* subscribe to sensor_combined topic */
	int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));
	orb_set_interval(sensor_sub_fd, 1000);



	/* one could wait for multiple topics with this technique, just using one here */
	px4_pollfd_struct_t fds[] = {
		{ .fd = sensor_sub_fd,   .events = POLLIN },
		/* there could be more file descriptors here, in the form like:
		 * { .fd = other_sub_fd,   .events = POLLIN },
		 */
	};

	int error_counter = 0;

	for (int i = 0; i < 5; i++) {
		/* wait for sensor update of 1 file descriptor for 1000 ms (1 second) */
		int poll_ret = px4_poll(fds, 1, 1000);

		/* handle the poll result */
		if (poll_ret == 0) {
			/* this means none of our providers is giving us data */
			PX4_ERR("[px4_simple_app] Got no data within a second");

		} else if (poll_ret < 0) {
			/* this is seriously bad - should be an emergency */
			if (error_counter < 10 || error_counter % 50 == 0) {
				/* use a counter to prevent flooding (and slowing us down) */
				PX4_ERR("[px4_simple_app] ERROR return value from poll(): %d"
					, poll_ret);
			}

			error_counter++;

		} else {

			if (fds[0].revents & POLLIN) {
				/* obtained data for the first file descriptor */
				struct sensor_combined_s raw;
				/* copy sensors raw data into local buffer */
				orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);
				PX4_WARN("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f",
					 (double)raw.accelerometer_m_s2[0],
					 (double)raw.accelerometer_m_s2[1],
					 (double)raw.accelerometer_m_s2[2]);

			}

		}
	}
        PX4_INFO("exiting");
	return 0;
}


编译应用程序:

 
make
注意,make命令要在Firware目录下执行,因为Makfile文件在该目录下,结果如下图所示。
 

第二步:测试uORB消息读取机制

最后一步,运行你的应用程序,并且切换到后台应用。注意这需要把程序重新编译上传到飞控板,拔掉sd卡,然后连接nsh控制台,运行以下命令。

  1. px4_simple_app &  
px4_simple_app &

你的应用程序会向串口输出当前传感器的值:

  [px4_simple_app]
Accelerometer:   0.0483          0.0821          0.0332
  [px4_simple_app]
Accelerometer:   0.0486          0.0820          0.0336
  [px4_simple_app]
Accelerometer:   0.0487          0.0819          0.0327
  [px4_simple_app]
Accelerometer:   0.0482          0.0818          0.0323
  [px4_simple_app]
Accelerometer:   0.0482          0.0827          0.0331
 
[px4_simple_app]
Accelerometer:   0.0489          0.0804          0.0328
我测试的结果如下图所示
 

它会在输出5次数据后退出。接下来会介绍如何编写一个能通过命令行控制的后台应用。

第三步:打印数据

   为了能获取到计算后的数据,下一步就是“打印”这些结果。如果我们知道某一个消息是使用mavlink协议转发给地面控制站的,我们可以通过这个消息去查看结果。例如我们通过这个方法来获得高度信息的消息。

接口非常简单--初始化消息的结构体,然后广播这条消息:

#include
<uORB/topics/vehicle_attitude.h>
..
/*
advertise attitude topic */
struct
vehicle_attitude_s att;
memset(&att,
0, sizeof(att));
orb_advert_t
att_pub_fd = orb_advertise(ORB_ID(vehicle_attitude), &att);

在主循环中,当消息准备好时,打印这条消息。

orb_publish(ORB_ID(vehicle_attitude),
att_pub_fd, &att);

修改后的完整的示例代码如下:

  1. /**************************************************************************** 
  2.  * 
  3.  *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. 
  4.  * 
  5.  * Redistribution and use in source and binary forms, with or without 
  6.  * modification, are permitted provided that the following conditions 
  7.  * are met: 
  8.  * 
  9.  * 1. Redistributions of source code must retain the above copyright 
  10.  *    notice, this list of conditions and the following disclaimer. 
  11.  * 2. Redistributions in binary form must reproduce the above copyright 
  12.  *    notice, this list of conditions and the following disclaimer in 
  13.  *    the documentation and/or other materials provided with the 
  14.  *    distribution. 
  15.  * 3. Neither the name PX4 nor the names of its contributors may be 
  16.  *    used to endorse or promote products derived from this software 
  17.  *    without specific prior written permission. 
  18.  * 
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  20.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  21.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  22.  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  23.  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  24.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
  25.  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
  26.  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
  27.  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  28.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  29.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  30.  * POSSIBILITY OF SUCH DAMAGE. 
  31.  * 
  32.  ****************************************************************************/  
  33.   
  34. /** 
  35.  * @file px4_simple_app.c 
  36.  * Minimal application example for PX4 autopilot 
  37.  * 
  38.  * @author Example User <mail@example.com> 
  39.  */  
  40.   
  41. #include <px4_config.h>  
  42. #include <px4_tasks.h>  
  43. #include <px4_posix.h>  
  44. #include <unistd.h>  
  45. #include <stdio.h>  
  46. #include <poll.h>  
  47. #include <string.h>  
  48.   
  49. #include <uORB/uORB.h>  
  50. #include <uORB/topics/sensor_combined.h>  
  51. #include <uORB/topics/vehicle_attitude.h>  
  52.   
  53. __EXPORT int px4_simple_app_main(int argc, char *argv[]);  
  54.   
  55. int px4_simple_app_main(int argc, char *argv[])  
  56. {  
  57.     /* subscribe to sensor_combined topic */  
  58.     int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));  
  59.     orb_set_interval(sensor_sub_fd, 1000);  
  60.   
  61.     /* advertise attitude topic */  
  62.     struct vehicle_attitude_s att;  
  63.     memset(&att, 0, sizeof(att));  
  64.     orb_advert_t att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att);  
  65.   
  66.     /* one could wait for multiple topics with this technique, just using one here */  
  67.     px4_pollfd_struct_t fds[] = {  
  68.         { .fd = sensor_sub_fd,   .events = POLLIN },  
  69.         /* there could be more file descriptors here, in the form like: 
  70.          * { .fd = other_sub_fd,   .events = POLLIN }, 
  71.          */  
  72.     };  
  73.   
  74.     int error_counter = 0;  
  75.   
  76.     for (int i = 0; i < 5; i++) {  
  77.         /* wait for sensor update of 1 file descriptor for 1000 ms (1 second) */  
  78.         int poll_ret = px4_poll(fds, 1, 1000);  
  79.   
  80.         /* handle the poll result */  
  81.         if (poll_ret == 0) {  
  82.             /* this means none of our providers is giving us data */  
  83.             PX4_ERR("[px4_simple_app] Got no data within a second");  
  84.   
  85.         } else if (poll_ret < 0) {  
  86.             /* this is seriously bad - should be an emergency */  
  87.             if (error_counter < 10 || error_counter % 50 == 0) {  
  88.                 /* use a counter to prevent flooding (and slowing us down) */  
  89.                 PX4_ERR("[px4_simple_app] ERROR return value from poll(): %d"  
  90.                     , poll_ret);  
  91.             }  
  92.   
  93.             error_counter++;  
  94.   
  95.         } else {  
  96.   
  97.             if (fds[0].revents & POLLIN) {  
  98.                 /* obtained data for the first file descriptor */  
  99.                 struct sensor_combined_s raw;  
  100.                 /* copy sensors raw data into local buffer */  
  101.                 orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);  
  102.                 PX4_WARN("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f",  
  103.                      (double)raw.accelerometer_m_s2[0],  
  104.                      (double)raw.accelerometer_m_s2[1],  
  105.                      (double)raw.accelerometer_m_s2[2]);  
  106.   
  107.                 /* set att and publish this information for other apps */  
  108.                 att.roll = raw.accelerometer_m_s2[0];  
  109.                 att.pitch = raw.accelerometer_m_s2[1];  
  110.                 att.yaw = raw.accelerometer_m_s2[2];  
  111.                 orb_publish(ORB_ID(vehicle_attitude), att_pub, &att);  
  112.             }  
  113.   
  114.             /* there could be more file descriptors here, in the form like: 
  115.              * if (fds[1..n].revents & POLLIN) {} 
  116.              */  
  117.         }  
  118.     }  
  119.   
  120.     PX4_INFO("exiting");  
  121.   
  122.     return 0;  
  123. }  
/****************************************************************************
 *
 *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file px4_simple_app.c
 * Minimal application example for PX4 autopilot
 *
 * @author Example User <mail@example.com>
 */

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

#include <uORB/uORB.h>
#include <uORB/topics/sensor_combined.h>
#include <uORB/topics/vehicle_attitude.h>

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

int px4_simple_app_main(int argc, char *argv[])
{
	/* subscribe to sensor_combined topic */
	int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));
	orb_set_interval(sensor_sub_fd, 1000);

	/* advertise attitude topic */
	struct vehicle_attitude_s att;
	memset(&att, 0, sizeof(att));
	orb_advert_t att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att);

	/* one could wait for multiple topics with this technique, just using one here */
	px4_pollfd_struct_t fds[] = {
		{ .fd = sensor_sub_fd,   .events = POLLIN },
		/* there could be more file descriptors here, in the form like:
		 * { .fd = other_sub_fd,   .events = POLLIN },
		 */
	};

	int error_counter = 0;

	for (int i = 0; i < 5; i++) {
		/* wait for sensor update of 1 file descriptor for 1000 ms (1 second) */
		int poll_ret = px4_poll(fds, 1, 1000);

		/* handle the poll result */
		if (poll_ret == 0) {
			/* this means none of our providers is giving us data */
			PX4_ERR("[px4_simple_app] Got no data within a second");

		} else if (poll_ret < 0) {
			/* this is seriously bad - should be an emergency */
			if (error_counter < 10 || error_counter % 50 == 0) {
				/* use a counter to prevent flooding (and slowing us down) */
				PX4_ERR("[px4_simple_app] ERROR return value from poll(): %d"
					, poll_ret);
			}

			error_counter++;

		} else {

			if (fds[0].revents & POLLIN) {
				/* obtained data for the first file descriptor */
				struct sensor_combined_s raw;
				/* copy sensors raw data into local buffer */
				orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);
				PX4_WARN("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f",
					 (double)raw.accelerometer_m_s2[0],
					 (double)raw.accelerometer_m_s2[1],
					 (double)raw.accelerometer_m_s2[2]);

				/* set att and publish this information for other apps */
				att.roll = raw.accelerometer_m_s2[0];
				att.pitch = raw.accelerometer_m_s2[1];
				att.yaw = raw.accelerometer_m_s2[2];
				orb_publish(ORB_ID(vehicle_attitude), att_pub, &att);
			}

			/* there could be more file descriptors here, in the form like:
			 * if (fds[1..n].revents & POLLIN) {}
			 */
		}
	}

	PX4_INFO("exiting");

	return 0;
}


第四步:运行整个示例

在nsh终端运行你的应用程序:

px4_simple_app

 如果打开地面站QGroundControl,你就能通过实时绘图(Tools-> Analyze)来获得实时的传感器数据。

注意事项:

1.打开nsh前需要拔掉sd卡.

2.连接nsh时不要地面站qgc运行.

3.连接地面站时需要插上sd卡.

4.运行编译命令是要在含有Makefile的.../Firware/目录下进行.

参考资料

First App Tutorial (Hello Sky)

版权声明:本文为博主原创文章,转载请注明出处libing403的csdn博客http://blog.csdn.net/libing403?viewmode=contents

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值