PX4开源软件框架简明简介
- 1. PX4系统构架
- 1.1 飞控 + 地面站/RC控制
- 1.2 飞控 + 伴飞电脑 + 地面站(集成RC控制)
- 2. PX4软件构架
- 2.1 设计概念
- 2.2 软件构架
- 2.1 中间件
- 2.2 飞控代码
- 3. PX4运行环境
- 3.1 PX4模块运行方式
- 3.2 PX任务启动方式
- 4. 总结 & 后续补充文章汇总列表
- 5. 参考资料
通过Git上的工程目录结构,简单的研读了关于PX4开源工程的情况,详见PX4开源工程结构简明介绍。
鉴于PX4是一份复杂的系统,而复杂事物是非常难于被理解的。也凸显了抽象问题,简化问题的重要性。
通过这种化繁为简方法论,从清晰简洁的设计框架来理解,不仅仅是一种学习方法,也是一种工程设计方法。
注:其实这个工程技术设计岗位职责划分是息息相关的,换句话说不同位置需要从不同的角度来思考,从而将产品更为高质量,高效率的设计出来。可以参考很早之前做人岗匹配时候的资料:团队理念和设计人员级别、职责。
下面我们学习下PX4是怎么设计的!!!
1. PX4系统构架
PX4系统是由软硬件构成,通常可以简单的分为两种典型的构架:飞控和飞控+伴飞电脑。
1.1 飞控 + 地面站/RC控制
该构架上半部分是地面站和RC控制部分;下半部分是飞控。PX4开源工程主要提供的是飞控部分的代码。
1.2 飞控 + 伴飞电脑 + 地面站(集成RC控制)
该构架上半部分是云端应用和地面站(含手动控制)部分;下半部分是飞控和伴飞电脑。PX4开源工程主要提供的是飞控部分的代码。类似避障的代码需要在伴飞电脑上运行,比如:Obstacle Detection and Avoidance。
2. PX4软件构架
2.1 设计概念
PX4软件设计遵循reactive设计理念:Published on September 16 2014. (v2.0)
- Responsive
- Resilient
- Elastic
- Message Driven
注:上面谈及的四点,个人感觉有点接近L5或者是L4应该考虑的问题。而L5更多需要从组织层面(战略需求)考虑,通常国内从一线能一直做到这个位置的人比较少,因为他涉及到政策、规划、战略,以及国内复杂人事关系。但是从纯技术的角度,无法满足短平快项目要求。所以国内,个人认为能做到L3或者L4已经非常不错了。
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: 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: 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软件构架由两层构成:
- 飞行控制栈
- 中间件
2.1 中间件
中间件主要由嵌入式传感设备驱动,控制驱动,以及消息通信接口组成。除此之外,还引入了模拟层做各种模型模拟及仿真。
├──> 硬件驱动&适配
│ ├──> 飞控板硬件适配
│ ├──> 操作系统硬件适配
│ ├──> 传感&控制驱动适配
├──> 消息通信
│ ├──> uORB消息机制
│ ├──> MAVLink消息机制
│ ├──> RTPS/DDS消息机制
└──> 模拟器
├──> jMAVSim模拟
├──> Gazebo模拟
├──> Ignition Gazebo模拟
├──> FlightGear模拟
├──> JSBSim模拟
├──> AirSim模拟
├──> Multi-Vehicle模拟
├──> Failsafes模拟
├──> FHITL模拟
└──> SIH模拟
2.2 飞控代码
飞行控制栈是自主无人机的制导、导航和控制算法的集合。它包括固定翼、多旋翼和垂直起降机身的控制器以及姿态和位置估算。
3. PX4运行环境
3.1 PX4模块运行方式
采用两种方式运行:
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",
SCHED_DEFAULT,
SCHED_PRIORITY_DEFAULT + 40,
3600,
commander_thread_main,
(char * const *)&argv[0]
);
4. 总结 & 后续补充文章汇总列表
根据对PX4软件构架和PX4运行环境,以及前面PX4开源工程结构简明介绍,我们可以得知模块主要以任务或者任务内工作队列的方式进行工作,后面主要通过每个模块的分析来了解PX4软件的具体实现。
- PX4开源工程结构简明介绍
- PX4开发环境搭建–模拟器编译及QGroundControl & RC遥控模拟配置
- TX12 + ExpressLRS 915MHz RC控制链路配置及问题汇总
- PX4模块设计之一:SITL & HITL模拟框架
- PX4模块设计之二:uORB消息代理
- PX4模块设计之三:自定义uORB消息
- PX4模块设计之四:MAVLink简介
- PX4模块设计之五:自定义MAVLink消息
- PX4模块设计之六:PX4-Fast RTPS(DDS)简介
- PX4模块设计之七:Ubuntu 20.04搭建Gazebo模拟器
- PX4模块设计之八:Ubuntu 20.04搭建FlightGear模拟器
- PX4模块设计之九:PX4飞行模式简介
- PX4模块设计之十:PX4启动过程
- PX4模块设计之十一:Built-In框架
- PX4模块设计之十二:High Resolution Timer设计
- PX4模块设计之十三:WorkQueue设计
- PX4模块设计之十四:Event设计
- PX4模块设计之十五:PX4 Log设计
- PX4模块设计之十六:Hardfault模块
- PX4模块设计之十七:ModuleBase模块
- PX4模块设计之十八:Logger模块
- PX4模块设计之十九:Replay模块
- PX4模块设计之二十:PX4应用平台初始化
- PX4模块设计之二十一:uORB消息管理模块
- PX4模块设计之二十二:FlightModeManager模块
- PX4模块设计之二十三:自定义FlightTask
- PX4模块设计之二十四:内部ADC模块
- PX4模块设计之二十五:DShot模块
- PX4模块设计之二十六:BatteryStatus模块
- PX4模块设计之二十七:LandDetector模块
- PX4模块设计之二十八:RCInput模块
- PX4模块设计之二十九:RCUpdate模块
- PX4模块设计之三十:Hysteresis类
- PX4模块设计之三十一:ManualControl模块
- PX4模块设计之三十二:AttitudeEstimatorQ模块
- PX4模块设计之三十三:Sensors模块
- PX4模块设计之三十四:ControlAllocator模块
- PX4模块设计之三十五:MulticopterAttitudeControl模块
- PX4模块设计之三十六:MulticopterPositionControl模块
- PX4模块设计之三十七:MulticopterRateControl模块
- PX4模块设计之三十八:Navigator模块
- PX4模块设计之三十九:Commander模块
- PX4模块设计之四十:FrskyTelemetry模块
- PX4模块设计之四十一:I2C/SPI Bus Instance基础知识
- PX4模块设计之四十二:ATXXXX模块
- PX4模块设计之四十三:icm20689模块
- PX4模块设计之四十四: bmp280模块
- PX4模块设计之四十五:param模块
- PX4模块设计之四十六:dataman模块
- bla…bla…
后续文章补充中。。。TBD(列表会慢慢补充)
5. 参考资料
【1】PX4 System Architecture
【2】PX4 Flight Stack Architecture
【3】PX4 Middleware
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)