[pixhawk笔记]6-uORB流程及关键函数解析

2023-05-16

本文中将结合代码、文档及注释,给出uORB执行流程及关键函数的解析,由于uORB的机制实现较为复杂,所以本文主要学习如何使用uORB的接口来实现通信。回到上一篇笔记中的代码:

#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[])
{
    PX4_INFO("Hello Sky!");
    int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));
        orb_set_interval(sensor_sub_fd,200);/* limit the update rate to 5 Hz */

    struct vehicle_attitude_s att;
    memset(&att,0,sizeof(att));
    orb_advert_t att_pub = orb_advertise(ORB_ID(vehicle_attitude),&att);

    px4_pollfd_struct_t fds[] = {
        {.fd = sensor_sub_fd, .events = POLLIN},
    };        

    int error_counter = 0;

    for(int i=0;i<5;i++){
        int poll_ret = px4_poll(fds,1,1000);

        if(poll_ret == 0){
            PX4_ERR("Got no data within a second");
        }else if(poll_ret<0){
            if(error_counter<10 || error_counter % 50 == 0){
                PX4_ERR("ERROR return value from poll():%d",poll_ret);
            }

            error_counter++;
        }else{
            if(fds[0].revents & POLLIN){
                struct sensor_combined_s raw;
                orb_copy(ORB_ID(sensor_combined),sensor_sub_fd,&raw);
                PX4_INFO("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]);

                att.rollspeed = raw.accelerometer_m_s2[0];
                att.pitchspeed = raw.accelerometer_m_s2[1];
                att.yawspeed = raw.accelerometer_m_s2[2];

                orb_publish(ORB_ID(vehicle_attitude),att_pub,&att);
            }
        }
    }
    PX4_INFO("exiting");
    return OK;
}
  • 订阅
    可以看出,订阅一个并获取一个主题的信息主要流程及其中关键函数如下:
  • 
    #include <uORB/topics/sensor_combined.h>
    ..
    int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));  

  该语句先包含一个主题头文件,该文件内容如下:

/****************************************************************************
 *
 *   Copyright (C) 2013-2016 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.
 *
 ****************************************************************************/

/* Auto-generated by genmsg_cpp from file /home/spy/src/Firmware/msg/sensor_combined.msg */


#pragma once

#include <stdint.h>
#ifdef __cplusplus
#include <cstring>
#else
#include <string.h>
#endif

#include <uORB/uORB.h>


#ifndef __cplusplus
#define RELATIVE_TIMESTAMP_INVALID 2147483647

#endif


#ifdef __cplusplus
struct __EXPORT sensor_combined_s {
#else
struct sensor_combined_s {
#endif
    uint64_t timestamp; // required for logger
    float gyro_rad[3];
    uint32_t gyro_integral_dt;
    int32_t accelerometer_timestamp_relative;
    float accelerometer_m_s2[3];
    uint32_t accelerometer_integral_dt;
    int32_t magnetometer_timestamp_relative;
    float magnetometer_ga[3];
    int32_t baro_timestamp_relative;
    float baro_alt_meter;
    float baro_temp_celcius;

#ifdef __cplusplus
    static constexpr int32_t RELATIVE_TIMESTAMP_INVALID = 2147483647;

#endif
};

/* register this as object request broker structure */
ORB_DECLARE(sensor_combined);

可以看出,该文件定义了一个sensor_combined的结构体,该结构体中包含了陀螺仪、加速度计、磁罗盘和气压计的数据。并使用ORB_DECLARE()宏声明一个sensor_combined的主题。该文件由genmsg.cpp由/msg/sensor_combined.msg中的内容生成,该msg文件内容如下:

#
# Sensor readings in SI-unit form.
#
# These fields are scaled and offset-compensated where possible and do not
# change with board revisions and sensor updates.
#

int32 RELATIVE_TIMESTAMP_INVALID = 2147483647 # (0x7fffffff) If one of the relative timestamps is set to this value, it means the associated sensor values are invalid


# gyro timstamp is equal to the timestamp of the message
float32[3] gyro_rad			# average angular rate measured in the XYZ body frame in rad/s over the last gyro sampling period
uint32 gyro_integral_dt		# gyro measurement sampling period in us

int32 accelerometer_timestamp_relative	# timestamp + accelerometer_timestamp_relative = Accelerometer timestamp
float32[3] accelerometer_m_s2		# average value acceleration measured in the XYZ body frame in m/s/s over the last accelerometer sampling period
uint32 accelerometer_integral_dt	# accelerometer measurement sampling period in us

int32 magnetometer_timestamp_relative	# timestamp + magnetometer_timestamp_relative = Magnetometer timestamp
float32[3] magnetometer_ga		# Magnetic field in NED body frame, in Gauss

int32 baro_timestamp_relative		# timestamp + baro_timestamp_relative = Barometer timestamp
float32 baro_alt_meter			# Altitude, already temp. comp.
float32 baro_temp_celcius		# Temperature in degrees celsius

可以看出,在.msg文件中主要定义了一些成员变量项,自动生成的.h文件使用这些成员变量生成了结构体, 并使用ORB_DECLARE()宏声明了这些主题,ORB_DECLARE()代码如下:读者也可以按该方法加入自定义的.msg文件,并编写对应的CMakeLists.txt,来生成消息,通过uORB来交换数据。

/**
 * Declare (prototype) the uORB metadata for a topic (used by code generators).
 *
 * @param _name		The name of the topic.
 */
#if defined(__cplusplus)
# define ORB_DECLARE(_name)		extern "C" const struct orb_metadata __orb_##_name __EXPORT
#else
# define ORB_DECLARE(_name)		extern const struct orb_metadata __orb_##_name __EXPORT
#endif

可以看出,ORB_DECLARE()宏实际上定义了一些orb_metadata 的结构体变量,变量名为__orb_prototype_name。
订阅时指定了ORB_ID,ORB_ID宏如下:

/**
 * Generates a pointer to the uORB metadata structure for
 * a given topic.
 *
 * The topic must have been declared previously in scope
 * with ORB_DECLARE().
 *
 * @param _name		The name of the topic.
 */
#define ORB_ID(_name)		&__orb_##_name

     其实是取了ORB_DECLARE()宏生成__orb_prototype_name结构体的地址。orb_subscribe的原型如下:

	/**
	 * Subscribe to a topic.
	 *
	 * The returned value is a file descriptor that can be passed to poll()
	 * in order to wait for updates to a topic, as well as topic_read,
	 * orb_check and orb_stat.
	 *
	 * Subscription will succeed even if the topic has not been advertised;
	 * in this case the topic will have a timestamp of zero, it will never
	 * signal a poll() event, checking will always return false and it cannot
	 * be copied. When the topic is subsequently advertised, poll, check,
	 * stat and copy calls will react to the initial publication that is
	 * performed as part of the advertisement.
	 *
	 * Subscription will fail if the topic is not known to the system, i.e.
	 * there is nothing in the system that has declared the topic and thus it
	 * can never be published.
	 *
	 * Internally this will call orb_subscribe_multi with instance 0.
	 *
	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
	 *      for the topic.
	 * @return    ERROR on error, otherwise returns a handle
	 *      that can be used to read and update the topic.
	 */
	int  orb_subscribe(const struct orb_metadata *meta) ;

可看出,其接受参数就是一个orb_metadata的常值指针,从注释看,其返回一个int类型的fd,表示文件描述符,该描述符作为一个句柄,可以用来读取并更新数据,如果订阅失败,则返回ERROR。
还有个orb_subscribe_multi函数可以用于订阅主题有多个实例的情况:

	/**
	 * Subscribe to a multi-instance of a topic.
	 *
	 * The returned value is a file descriptor that can be passed to poll()
	 * in order to wait for updates to a topic, as well as topic_read,
	 * orb_check and orb_stat.
	 *
	 * Subscription will succeed even if the topic has not been advertised;
	 * in this case the topic will have a timestamp of zero, it will never
	 * signal a poll() event, checking will always return false and it cannot
	 * be copied. When the topic is subsequently advertised, poll, check,
	 * stat and copy calls will react to the initial publication that is
	 * performed as part of the advertisement.
	 *
	 * Subscription will fail if the topic is not known to the system, i.e.
	 * there is nothing in the system that has declared the topic and thus it
	 * can never be published.
	 *
	 * If a publisher publishes multiple instances the subscriber should
	 * subscribe to each instance with orb_subscribe_multi
	 * (@see orb_advertise_multi()).
	 *
	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
	 *      for the topic.
	 * @param instance  The instance of the topic. Instance 0 matches the
	 *      topic of the orb_subscribe() call, higher indices
	 *      are for topics created with orb_advertise_multi().
	 * @return    ERROR on error, otherwise returns a handle
	 *      that can be used to read and update the topic.
	 *      If the topic in question is not known (due to an
	 *      ORB_DEFINE_OPTIONAL with no corresponding ORB_DECLARE)
	 *      this function will return -1 and set errno to ENOENT.
	 */
	int  orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance) ;

    该函数可以通过instance参数来指定实例索引。

订阅了之后可以获取该主题的数据,获取主题数据有如下几个函数可用:

      • px4_poll

本文开头的代码中即用的该函数,该函数其实是调用的nuttx系统的poll函数,该函数原型如下:

/****************************************************************************
 * Name: poll
 *
 * Description:
 *   poll() waits for one of a set of file descriptors to become ready to
 *   perform I/O.  If none of the events requested (and no error) has
 *   occurred for any of  the  file  descriptors,  then  poll() blocks until
 *   one of the events occurs.
 *
 * Inputs:
 *   fds  - List of structures describing file descriptors to be monitored
 *   nfds - The number of entries in the list
 *   timeout - Specifies an upper limit on the time for which poll() will
 *     block in milliseconds.  A negative value of timeout means an infinite
 *     timeout.
 *
 * Return:
 *   On success, the number of structures that have non-zero revents fields.
 *   A value of 0 indicates that the call timed out and no file descriptors
 *   were ready.  On error, -1 is returned, and errno is set appropriately:
 *
 *   EBADF  - An invalid file descriptor was given in one of the sets.
 *   EFAULT - The fds address is invalid
 *   EINTR  - A signal occurred before any requested event.
 *   EINVAL - The nfds value exceeds a system limit.
 *   ENOMEM - There was no space to allocate internal data structures.
 *   ENOSYS - One or more of the drivers supporting the file descriptor
 *     does not support the poll method.
 *
 ****************************************************************************/

int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)

可以看出,该函数用于阻塞等待文件描述符更新,等待时间为timeout毫秒。该函数返回值大于0表示等到数据更新,0表示没有等到数据更新,小于0则表示发生错误。(返回值的详细情况参见注释)。

      • orb_check
        该函数原型及注释如下:
        	/**
        	 * Check whether a topic has been published to since the last orb_copy.
        	 *
        	 * This check can be used to determine whether to copy the topic when
        	 * not using poll(), or to avoid the overhead of calling poll() when the
        	 * topic is likely to have updated.
        	 *
        	 * Updates are tracked on a per-handle basis; this call will continue to
        	 * return true until orb_copy is called using the same handle. This interface
        	 * should be preferred over calling orb_stat due to the race window between
        	 * stat and copy that can lead to missed updates.
        	 *
        	 * @param handle  A handle returned from orb_subscribe.
        	 * @param updated Set to true if the topic has been updated since the
        	 *      last time it was copied using this handle.
        	 * @return    OK if the check was successful, ERROR otherwise with
        	 *      errno set accordingly.
        	 */
        	int  orb_check(int handle, bool *updated) ;
        

        该函数也是用于检查主题是否有更新,与px4_poll不同的是没有阻塞等待,如果从上次orb_copy函数执行之后,主题发生了更新,则将第二个参数设置为true,否则为false。若函数正确执行,返回OK,否则返回ERROR。相比于px4_poll,该函数不会阻塞等待,所以不会造成系统过载。

      • orb_stat

        	/**
        	 * Return the last time that the topic was updated. If a queue is used, it returns
        	 * the timestamp of the latest element in the queue.
        	 *
        	 * @param handle  A handle returned from orb_subscribe.
        	 * @param time    Returns the absolute time that the topic was updated, or zero if it has
        	 *      never been updated. Time is measured in microseconds.
        	 * @return    OK on success, ERROR otherwise with errno set accordingly.
        	 */
        	int  orb_stat(int handle, uint64_t *time) ;
        

        该函数用于获得指定的主题上一次更新的绝对时间,为毫秒数。返回值为OK表示成功执行,ERROR为有错误发生,具体错误可以查看errno。从orb_check的注释中可以看出,该函数有缺陷,因为在orb_stat和orb_copy之间的时间窗口有可能发生更新,而根据返回的毫秒数来确定可能会错过该更新。

         使用以上三个函数可以确定主题是否发生更新,如有更新发生,则可以使用orb_copy来从主题中获得更新数据:

      • orb_copy
        该函数原型如下:
        	/**
        	 * Fetch data from a topic.
        	 *
        	 * This is the only operation that will reset the internal marker that
        	 * indicates that a topic has been updated for a subscriber. Once poll
        	 * or check return indicating that an updaet is available, this call
        	 * must be used to update the subscription.
        	 *
        	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
        	 *      for the topic.
        	 * @param handle  A handle returned from orb_subscribe.
        	 * @param buffer  Pointer to the buffer receiving the data, or NULL
        	 *      if the caller wants to clear the updated flag without
        	 *      using the data.
        	 * @return    OK on success, ERROR otherwise with errno set accordingly.
        	 */
        	int  orb_copy(const struct orb_metadata *meta, int handle, void *buffer) ;
        

        代码中调用时形式如下:

         struct sensor_combined_s raw;
         orb_copy(ORB_ID(sensor_combined),sensor_sub_fd,&raw);
        

        第一个参数为ORB_ID获取的主题ID(orb_metadata的指针),第二个参数为文件描述符,可用订阅时返回值,第三个参数为更新数据的缓存地址,可以为一个主题对应结构体类型的地址。
        此外,在订阅时还有其他函数:

      • orb_set_interval(sensor_sub_fd,200);该函数用于设置主题更新速率。

  • 发布
    发布主题主要使用两个函数:
      • orb_advertise(ORB_ID(vehicle_attitude),&att);
        该函数原型及注释如下:
        	// ==== uORB interface methods ====
        	/**
        	 * Advertise as the publisher of a topic.
        	 *
        	 * This performs the initial advertisement of a topic; it creates the topic
        	 * node in /obj if required and publishes the initial data.
        	 *
        	 * Any number of advertisers may publish to a topic; publications are atomic
        	 * but co-ordination between publishers is not provided by the ORB.
        	 *
        	 * Internally this will call orb_advertise_multi with an instance of 0 and
        	 * default priority.
        	 *
        	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
        	 *      for the topic.
        	 * @param data    A pointer to the initial data to be published.
        	 *      For topics updated by interrupt handlers, the advertisement
        	 *      must be performed from non-interrupt context.
        	 * @param queue_size  Maximum number of buffered elements. If this is 1, no queuing is
        	 *      used.
        	 * @return    nullptr on error, otherwise returns an object pointer
        	 *      that can be used to publish to the topic.
        	 *      If the topic in question is not known (due to an
        	 *      ORB_DEFINE with no corresponding ORB_DECLARE)
        	 *      this function will return nullptr and set errno to ENOENT.
        	 */
        	orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data, unsigned int queue_size = 1)
        	{
        		return orb_advertise_multi(meta, data, nullptr, ORB_PRIO_DEFAULT, queue_size);
        	}
        

        该函数用来广播一个主题发布者,返回一个对象指针,该对象可用来发布主题,若出现错误,则返回空指针。
        该函数接收参数为有三个:第一个ORB_ID,表示要发布的主题ID;第二个为结构体指针,指向要发布的数据结构体;第三个为队列大小,默认为1,表示没有消息队列。
        通过查看代码,发现其实该函数调用了orb_advertise_multi函数,使用空指针0作为主题的实例索引,表示只广播主题的第一个实例,并使用默认优先级来广播。
        也可以使用orb_advertise_multi函数。其原型和注释如下:

        /**
        	 * Advertise as the publisher of a topic.
        	 *
        	 * This performs the initial advertisement of a topic; it creates the topic
        	 * node in /obj if required and publishes the initial data.
        	 *
        	 * Any number of advertisers may publish to a topic; publications are atomic
        	 * but co-ordination between publishers is not provided by the ORB.
        	 *
        	 * The multi can be used to create multiple independent instances of the same topic
        	 * (each instance has its own buffer).
        	 * This is useful for multiple publishers who publish the same topic. The subscriber
        	 * then subscribes to all instances and chooses which source he wants to use.
        	 *
        	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
        	 *      for the topic.
        	 * @param data    A pointer to the initial data to be published.
        	 *      For topics updated by interrupt handlers, the advertisement
        	 *      must be performed from non-interrupt context.
        	 * @param instance  Pointer to an integer which will yield the instance ID (0-based)
        	 *      of the publication. This is an output parameter and will be set to the newly
        	 *      created instance, ie. 0 for the first advertiser, 1 for the next and so on.
        	 * @param priority  The priority of the instance. If a subscriber subscribes multiple
        	 *      instances, the priority allows the subscriber to prioritize the best
        	 *      data source as long as its available. The subscriber is responsible to check
        	 *      and handle different priorities (@see orb_priority()).
        	 * @param queue_size  Maximum number of buffered elements. If this is 1, no queuing is
        	 *      used.
        	 * @return    ERROR on error, otherwise returns a handle
        	 *      that can be used to publish to the topic.
        	 *      If the topic in question is not known (due to an
        	 *      ORB_DEFINE with no corresponding ORB_DECLARE)
        	 *      this function will return -1 and set errno to ENOENT.
        	 */
        	orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance,
        					 int priority, unsigned int queue_size = 1) ;
        

        该函数可以指定int*类型的instance参数,可以在一个主题存在多个实例时使用。

      • orb_publish(ORB_ID(vehicle_attitude),att_pub,&att);
        该函数用于在广播主题之后发布主题,使用广播时返回的主题句柄。函数原型及注释如下:

        	/**
        	 * Publish new data to a topic.
        	 *
        	 * The data is atomically published to the topic and any waiting subscribers
        	 * will be notified.  Subscribers that are not waiting can check the topic
        	 * for updates using orb_check and/or orb_stat.
        	 *
        	 * @param meta    The uORB metadata (usually from the ORB_ID() macro)
        	 *      for the topic.
        	 * @handle    The handle returned from orb_advertise.
        	 * @param data    A pointer to the data to be published.
        	 * @return    OK on success, ERROR otherwise with errno set accordingly.
        	 */
        	int  orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data) ;
        

        该函数用于发布主题,发布之后会通知所有订阅者主题已更新(例如使用px4_poll进行阻塞等待的订阅者),而orb_check需要手动检查是否已更新。

         

转载于:https://www.cnblogs.com/spyplus/p/pixhawk_note_uORB_functions.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

[pixhawk笔记]6-uORB流程及关键函数解析 的相关文章

  • pixhawk配置垂直起降无人机

    我使用的版本里面没有找到 43 型尾座式垂直起降无人机 就先用x型无人机了 查看代码 发现在init d目录下id号为13003 待续
  • Pixhawk无人机飞行模式详解 (PX4源码)

    我帮大家把飞行模式控制量与特点总结一下 xff0c 方便看代码 xff0c 如下所示 xff1a 辅助模式 Position Mode 位置模式 xff08 定点模式 xff09 横滚俯仰控制角度 xff0c 油门控制上下速度 xff0c
  • pixhawk无人机避障

    本人最近用树莓派结合PX4做无人机避障 xff0c 使用激光雷达 xff0c 有没有一起的小伙伴 xff0c 我们一起交流 xff01 私信我 xff0c
  • pixhawk似乎也是用的四环串级

    pixhawk似乎也是用的四环串级 https blog csdn net sinat 16643223 article details 106973618 阿木社区的pixhawk的课里 https bbs amovlab com plu
  • 自己组装pixhawk的一些感受

    现在你叫我设置遥控器我会了 xff0c 我也清楚电调怎么接线的了 xff0c 也清楚怎么供电的了 xff0c 其实飞控的接线就四个电调的接线 xff0c 加上接收机的接线其他都是一些传感器的接线罢了 xff0c 我现在回过头看无名的无人机就
  • 关于pixhawk硬件IMU和compass那点事儿

    文章目录 前言一 IMU和compass是什么 xff1f 二 导航坐标系与机体坐标系三 安装IMU xff0c compasss四 hwdef中设置IMU xff0c compass朝向总结 前言 继上一篇讲解了pixhawk的硬件组成
  • apm、pixhawk、pixhack飞控航拍后pos数据提取流程

    apm pixhawk pixhack飞控pos数据提取流程 下载日志 打开log分析 区域omap地图验证 验证之前将log文件使用mission planner进行kml验证 筛选相机pos坐标 xff08 选择CAM xff09 很重
  • Pixhawk学习7——位置解算

    Pixhawk的位置解算分为两部分 xff0c 第一部分主要为传感器的数据获取 xff0c 而该部分最主要的就是GPS数据的提取 第二部分为与惯性器件之间的组合导航 组合导航的好处我就不用多说了 Pixhawk代码中目前主要有两处组合导航的
  • pixhawk commander.cpp的飞行模式切换解读

    commander cpp逻辑性太强了 xff0c 涉及整个系统的运作 xff0c 所以分别拆分成小块看 另此篇blog大部分是参考 xff08 Pixhawk原生固件解读 xff09 飞行模式 xff0c 控制模式的思路 xff0c 笔者
  • pixhawk PX4FMU和PX4IO最底层启动过程分析

    首先 xff0c 大体了解PX4IO 与PX4FMU各自的任务 PX4IO STM32F100 为PIXHAWK 中专用于处理输入输出的部分 输入为支持的各类遥控器 PPM SPKT DSM SBUS 输出为电调的PWM 驱动信号 它与PX
  • pixhawk: px4代码初学分析:追溯电机控制--pwm输出

    追溯电机控制 pwm输出 正常工作状态下pwm输出过程简述 xff1a 其他状态下pwm输出 xff1a 正常工作状态下pwm输出过程简述 xff1a 姿态解算部分得出姿态控制量通过px4io cpp把姿态控制量发送给IOIO串口读取姿态控
  • Pixhawk-信息流浅解析

    根深方能叶茂 在等待的日子里 xff0c 刻苦读书 xff0c 谦卑做人 xff0c 养得深根 xff0c 日后才能枝叶茂盛 Better 根爷 之前我们已经谈到系统框架 xff0c 之前谈到了定制自己功能的两部 xff1a 添加模块和修改
  • pixhawk串口读取传感器数据

    1 Pixhawk板上串口说明 xff1a 测试 使用Pixhawk板上TELEM2接口的USART2 xff0c 对应的Nuttx UART设备文件尾 dev ttyS2 xff1a 2 读取数据测试 步骤 xff1a 在Firmware
  • Nuttx下移植uorb笔记

    Nuttx下移植uorb笔记 之前接触过ros下的消息机制 xff08 生产者 消费者 xff09 模型 xff0c 第一感觉是灵活好用 xff0c 但是在资源有限的嵌入式环境里面 xff0c 邮箱 消息 显得就有点不那么灵活 xff0c
  • 树莓派结合PIXHAWK飞控实现四轴双目视觉避障

    树莓派结合Pixhawk飞控实现四轴双目视觉避障 灰信网 xff08 软件开发博客聚合 xff09 无人机双目视觉避障的实现 本文将介绍如何使用树莓派结合PIX飞控实现无人机双目视觉避障的功能 主要硬件 我们以双目摄像头 43 树莓派 43
  • DroneKit教程(二):控制Pixhawk示例

    DroneKit教程 xff08 二 xff09 xff1a 控制Pixhawk示例 本篇提供了一个简单的示例 xff0c 配以详细的注释说明不同语句的功能 xff0c 希望能给各位一个总体的框架和印象 该示例文件改写自DroneKit的官
  • PX4模块设计之三:自定义uORB消息

    PX4模块设计之三 xff1a 自定义uORB消息 1 新增自定义uORB消息步骤2 应用ext hello world消息示例3 编译执行结果4 参考资料 基于PX4开源软件框架简明简介和PX4模块设计之二 xff1a uORB消息代理
  • PX4模块设计之二十一:uORB消息管理模块

    PX4模块设计之二十一 xff1a uORB消息管理模块 1 uORB模块构建模式2 uORB消息管理函数2 1 状态查询2 2 资源利用2 3 模块启动2 4 模块停止3 uORB消息接口3 1 消息主题注册3 2 消息主题去注册3 3
  • uORB和MAVLink通讯例程

    uORB uORB 是一种异步 publish subscribe 的消息传递 API xff0c 用于进程或者线程间通信 IPC 添加新的Topic xff08 主题 xff09 在msg 目录下创建一个新的 msg文件 xff0c 并将
  • 步骤五:PIXHAWK遥控器的使用

    采用福斯i6s遥控 1 连接飞控 打开遥控器 xff0c 接收机插上飞控 xff0c 再插上送的短接线 xff0c 进行匹配对码RX 2 遥控器长按两秒锁 xff0c system output mode Output mode按照图片这样

随机推荐

  • Minix下的汇编2

    似乎minix平台并没有带一个真正的汇编编译器 xff0c 看看makefile xff0c 几乎都是清一色的用cc来编译汇编代码的 而且 xff0c 即使是一个最简单功能的汇编程序 xff0c 也少不了一个 main 标签 在minix的
  • 原来在/var/spool/mail中

    fetchmail会把从mail server收到的邮件投递到 var spool mail 中去 而mutt也会自动地到 var spool mail里取信 xff0c 解码 xff0c 并显示 但 xff0c fetchmail的速度不
  • 汉字编码标准与识别(一)代码页(Code Page)初识

    BBS水木清华站 精华区 发信人 yanglc 魂归燕园 别理我 xff0c 烦着呢 信区 Linux 标 题 汉字编码标准与识别 一 发信站 BBS 水木清华站 Sat Apr 29 17 19 05 2000 http www linu
  • 让xpdf支持中文(C++primer中文版)

    首先到http www linuxfans org nuke modules php name 61 Site Downloads amp op 61 geninfo amp did 61 2385下载一个打了补丁的xpdf 安装 xff0
  • Xpdf-3 for MDK

    http www linuxfans org nuke modules php name 61 Site Downloads amp op 61 geninfo amp did 61 2385 Xpdf 3 for MDK 类别 其它软件
  • 不同公司的牛

    本文转自 C 43 43 Builder 研究 http www ccrun com other go asp i 61 264 amp d 61 sgz5id 传统公司 xff1a 你有两头母牛 你卖掉一头 xff0c 买了一头公牛 你的
  • 从词法分析开始

    刚开始时 xff0c 用lex的确是很方便 xff0c 但是这样却不能将词法分析的思想实践出来 最好的方法还是自己写一个lex 当然龙书上写得很详细了 xff0c 但是写得再详细 xff0c 把它实现出来还是很难的 我的计划是 xff1a
  • Python 获取当前路径几种方法

    Python 获取当前路径的几种方法 绝对路径 1 os path 方法 span class token comment coding utf 8 span span class token comment usr bin python
  • [pixhawk笔记]2-飞行模式

    本文翻译自px4官方开发文档 xff1a https dev px4 io en concept flight modes html xff0c 有不对之处 xff0c 敬请指正 pixhawk的飞行模式如下 xff1a MANUAL xf
  • 扩展卡尔曼滤波详解

    Extened Kalman Filter 简单介绍 卡尔曼滤波详解讲解的基本的卡尔曼滤波算法是通过一个线性随机差分方程来估计当前状态 xff0c 但是如果状态估计关系以及测量关系使非线性的怎么办 xff0c 而且在实际使用中大部分的问题都
  • 关于PX4中的高度若干问题

    飞行的高度是如何测量的 xff1f 地面的高度和海平面的高度差别很大 xff0c 飞控又是如何有效判别进行降落的 xff1f 这是我脑子里的疑问 搜索的一圈发现很少有人讨论这方面的问题 xff0c 于是本次我就直接看一下源代码 xff0c
  • 基于4G网卡和树莓派zero实现低延时数字图传(250-300ms左右)

    方案本身并不复杂 xff0c 都是采用成熟的产品 xff0c 只需要几个命令行就能解决问题 0 准备工作 硬件 xff1a 树莓派zero 4G网卡 linux台式机 笔记本 虚拟机 软件 xff1a raspivid netcat nc
  • 树莓派zero w 使用AV接口连接电视机

    树莓派zero本身板子上有一个mini HDMI xff0c 但是我看到好像板子上还有一个小接口 xff0c 上面写着TV xff0c 感觉应该可以输出AV信号 xff0c 于是网上搜索了一番 xff0c 果然可以 首先 xff0c 手工做
  • OpenHD改造实现廉价高清数字图传(树莓派+PC)—(一)概述

    一 缘由 数字图传网上有开源的解决方案 xff0c 最为出名的应该就是OpenHD了 如果按照官方网站的内容 xff0c 构建起来也不是很复杂 xff0c 直接可以烧录两个TF卡就能完成 但是 xff0c 你需要用到两个树莓派板卡 xff0
  • OpenHD改造实现廉价高清数字图传(树莓派+PC)—(二)Wifibroadcast Wifi广播通信

    上一篇文章重点介绍了数字图传的整体构建思路 xff0c 以及主要的软件模块和最终效果 接下来几篇文章将针对其中的几个主要关键技术点进行阐述 一方面是为了将这些知识点做一个整理记录 xff0c 方便后续查阅 xff0c 另一方面也是将学习到知
  • OpenHD改造实现廉价高清数字图传(树莓派+PC )—(四)OSD数据传输和画面显示

    前面三篇文章分别讲了整体情况 xff0c wifibroadcast xff0c 以及OpenVG的移植等 OpenHD改造实现廉价高清数字图传 xff08 树莓派zero 43 ubuntu PC xff09 xff08 一 xff09
  • OpenHD改造实现廉价高清数字图传(树莓派+PC)—(五)gstreamer视频采集、传输和显示

    图传的一个重要功能就是可以看视频 主要是采集树莓派zero摄像头的数据 xff0c 经过编码打包 xff0c 通过wifibroadcast发送到地面端的PC上 xff0c 然后再通过解码显示出来 这里用到了视频采集和编解码相关的软件 在树
  • OpenHD改造实现廉价高清数字图传(树莓派+PC)—(六)OSD和视频画面整合显示

    这个OpenHD改造移植系列的最后一篇文章 xff0c 这篇文章主要讲如何讲前面说到的全部内容串接起来 xff0c 讲OSD画面显示和视频画面整合到一起 xff0c 形成完整的图传地面显示 xff0c 真正实现PC上直接接收显示图传视频和数
  • OpenHD改造实现廉价高清数字图传-OrangePi i96移植篇

    前面说到 xff0c 天空端的树莓派zero也涨价的厉害 xff0c 以及500多块了 xff0c 实在是贵的离谱啊 xff0c 所以还是要找国产化替代 先从最便宜的OrangePi i96开始吧 xff0c 毕竟只有39元的价格 xff0
  • [pixhawk笔记]6-uORB流程及关键函数解析

    本文中将结合代码 文档及注释 xff0c 给出uORB执行流程及关键函数的解析 xff0c 由于uORB的机制实现较为复杂 xff0c 所以本文主要学习如何使用uORB的接口来实现通信 回到上一篇笔记中的代码 xff1a include l