PX4开源软件框架简明简介

通过Git上的工程目录结构,简单的研读了关于PX4开源工程的情况,详见PX4开源工程结构简明介绍

鉴于PX4是一份复杂的系统,而复杂事物是非常难于被理解的。也凸显了抽象问题,简化问题的重要性。

通过这种化繁为简方法论,从清晰简洁的设计框架来理解,不仅仅是一种学习方法,也是一种工程设计方法。

注:其实这个工程技术设计岗位职责划分是息息相关的,换句话说不同位置需要从不同的角度来思考,从而将产品更为高质量,高效率的设计出来。可以参考很早之前做人岗匹配时候的资料:团队理念和设计人员级别、职责

下面我们学习下PX4是怎么设计的!!!

1. PX4系统构架

PX4系统是由软硬件构成,通常可以简单的分为两种典型的构架:飞控和飞控+伴飞电脑。

1.1 飞控 + 地面站/RC控制

该构架上半部分是地面站和RC控制部分;下半部分是飞控。PX4开源工程主要提供的是飞控部分的代码。

Flight Control (Only)

1.2 飞控 + 伴飞电脑 + 地面站(集成RC控制)

该构架上半部分是云端应用和地面站(含手动控制)部分;下半部分是飞控和伴飞电脑。PX4开源工程主要提供的是飞控部分的代码。类似避障的代码需要在伴飞电脑上运行,比如:Obstacle Detection and Avoidance

FC & Companior Computer

2. PX4软件构架

2.1 设计概念

PX4软件设计遵循reactive设计理念:Published on September 16 2014. (v2.0)

  • Responsive
  • Resilient
  • Elastic
  • Message Driven

reactive principle

注:上面谈及的四点,个人感觉有点接近L5或者是L4应该考虑的问题。而L5更多需要从组织层面(战略需求)考虑,通常国内从一线能一直做到这个位置的人比较少,因为他涉及到政策、规划、战略,以及国内复杂人事关系。但是从纯技术的角度,无法满足短平快项目要求。所以国内,个人认为能做到L3或者L4已经非常不错了。

  • Responsive:响应的及时性

Responsive: The system responds in a timely manner if at all possible. Responsiveness is the cornerstone of usability and utility, but more than that, responsiveness means that problems may be detected quickly and dealt with effectively. Responsive systems focus on providing rapid and consistent response times, establishing reliable upper bounds so they deliver a consistent quality of service. This consistent behaviour in turn simplifies error handling, builds end user confidence, and encourages further interaction.

  • Resilient:自愈的及时性

Resilient: The system stays responsive in the face of failure. This applies not only to highly-available, mission-critical systems — any system that is not resilient will be unresponsive after a failure. Resilience is achieved by replication, containment, isolation and delegation. Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.

  • Elastic:弹性、可扩展性

Elastic: The system stays responsive under varying workload. Reactive Systems can react to changes in the input rate by increasing or decreasing the resources allocated to service these inputs. This implies designs that have no contention points or central bottlenecks, resulting in the ability to shard or replicate components and distribute inputs among them. Reactive Systems support predictive, as well as Reactive, scaling algorithms by providing relevant live performance measures. They achieve elasticity in a cost-effective way on commodity hardware and software platforms.

  • Message Driven: 消息驱动(常规解耦方法之一)

Message Driven: Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation and location transparency. This boundary also provides the means to delegate failures as messages. Employing explicit message-passing enables load management, elasticity, and flow control by shaping and monitoring the message queues in the system and applying back-pressure when necessary. Location transparent messaging as a means of communication makes it possible for the management of failure to work with the same constructs and semantics across a cluster or within a single host. Non-blocking communication allows recipients to only consume resources while active, leading to less system overhead.

2.2 软件构架

PX4软件构架由两层构成:

  • 飞行控制栈
  • 中间件
    High-Level Software Architecture

2.1 中间件

中间件主要由嵌入式传感设备驱动,控制驱动,以及消息通信接口组成。除此之外,还引入了模拟层做各种模型模拟及仿真。

 ├──> 硬件驱动&适配
 │   ├──> 飞控板硬件适配
 │   ├──> 操作系统硬件适配
 │   ├──> 传感&控制驱动适配
 ├──> 消息通信
 │   ├──> uORB消息机制
 │   ├──> MAVLink消息机制
 │   ├──> RTPS/DDS消息机制
 └──> 模拟器
     ├──> jMAVSim模拟
     ├──> Gazebo模拟
     ├──> Ignition Gazebo模拟
     ├──> FlightGear模拟
     ├──> JSBSim模拟
     ├──> AirSim模拟
     ├──> Multi-Vehicle模拟
     ├──> Failsafes模拟
     ├──> FHITL模拟
     └──> SIH模拟

2.2 飞控代码

飞行控制栈是自主无人机的制导、导航和控制算法的集合。它包括固定翼、多旋翼和垂直起降机身的控制器以及姿态和位置估算。

Flight Control Stack

3. PX4运行环境

3.1 PX4模块运行方式

采用两种方式运行:

  • Tasks
  • Work queue tasks

Tasks: The module runs in its own task with its own stack and process priority.

Work queue tasks: The module runs on a shared work queue, sharing the same stack and work queue thread priority as other modules on the queue.

3.2 PX任务启动方式

px4_task_spawn_cmd() 用来启动任务:

independent_task = px4_task_spawn_cmd(
    "commander",                    // Process name
    SCHED_DEFAULT,                  // Scheduling type (RR or FIFO)
    SCHED_PRIORITY_DEFAULT + 40,    // Scheduling priority
    3600,                           // Stack size of the new task or thread
    commander_thread_main,          // Task (or thread) main function
    (char * const *)&argv[0]        // Void pointer to pass to the new task
                                    // (here the commandline arguments).
    );

4. 总结 & 后续补充文章汇总列表

根据对PX4软件构架和PX4运行环境,以及前面PX4开源工程结构简明介绍,我们可以得知模块主要以任务或者任务内工作队列的方式进行工作,后面主要通过每个模块的分析来了解PX4软件的具体实现。

  1. PX4开源工程结构简明介绍
  2. PX4开发环境搭建–模拟器编译及QGroundControl & RC遥控模拟配置
  3. TX12 + ExpressLRS 915MHz RC控制链路配置及问题汇总
  4. PX4模块设计之一:SITL & HITL模拟框架
  5. PX4模块设计之二:uORB消息代理
  6. PX4模块设计之三:自定义uORB消息
  7. PX4模块设计之四:MAVLink简介
  8. PX4模块设计之五:自定义MAVLink消息
  9. PX4模块设计之六:PX4-Fast RTPS(DDS)简介
  10. PX4模块设计之七:Ubuntu 20.04搭建Gazebo模拟器
  11. PX4模块设计之八:Ubuntu 20.04搭建FlightGear模拟器
  12. PX4模块设计之九:PX4飞行模式简介
  13. PX4模块设计之十:PX4启动过程
  14. PX4模块设计之十一:Built-In框架
  15. PX4模块设计之十二:High Resolution Timer设计
  16. PX4模块设计之十三:WorkQueue设计
  17. PX4模块设计之十四:Event设计
  18. PX4模块设计之十五:PX4 Log设计
  19. PX4模块设计之十六:Hardfault模块
  20. PX4模块设计之十七:ModuleBase模块
  21. PX4模块设计之十八:Logger模块
  22. PX4模块设计之十九:Replay模块
  23. PX4模块设计之二十:PX4应用平台初始化
  24. PX4模块设计之二十一:uORB消息管理模块
  25. PX4模块设计之二十二:FlightModeManager模块
  26. PX4模块设计之二十三:自定义FlightTask
  27. PX4模块设计之二十四:内部ADC模块
  28. PX4模块设计之二十五:DShot模块
  29. PX4模块设计之二十六:BatteryStatus模块
  30. PX4模块设计之二十七:LandDetector模块
  31. PX4模块设计之二十八:RCInput模块
  32. PX4模块设计之二十九:RCUpdate模块
  33. PX4模块设计之三十:Hysteresis类
  34. PX4模块设计之三十一:ManualControl模块
  35. PX4模块设计之三十二:AttitudeEstimatorQ模块
  36. PX4模块设计之三十三:Sensors模块
  37. PX4模块设计之三十四:ControlAllocator模块
  38. PX4模块设计之三十五:MulticopterAttitudeControl模块
  39. PX4模块设计之三十六:MulticopterPositionControl模块
  40. PX4模块设计之三十七:MulticopterRateControl模块
  41. PX4模块设计之三十八:Navigator模块
  42. PX4模块设计之三十九:Commander模块
  43. PX4模块设计之四十:FrskyTelemetry模块
  44. PX4模块设计之四十一:I2C/SPI Bus Instance基础知识
  45. PX4模块设计之四十二:ATXXXX模块
  46. PX4模块设计之四十三:icm20689模块
  47. PX4模块设计之四十四: bmp280模块
  48. PX4模块设计之四十五:param模块
  49. PX4模块设计之四十六:dataman模块
  50. bla…bla…

后续文章补充中。。。TBD(列表会慢慢补充)

5. 参考资料

【1】PX4 System Architecture
【2】PX4 Flight Stack Architecture
【3】PX4 Middleware

  • 15
    点赞
  • 130
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值