PX4开源软件框架简明简介

Posted lida2003

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PX4开源软件框架简明简介相关的知识,希望对你有一定的参考价值。

PX4开源软件框架简明简介

通过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:响应的及时性

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软件构架由两层构成:

  • 飞行控制栈
  • 中间件

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
  • 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软件的具体实现。

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

  1. PX4开源工程结构简明介绍
  2. bla…bla…

5. 参考资料

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

以上是关于PX4开源软件框架简明简介的主要内容,如果未能解决你的问题,请参考以下文章

PX4模块设计之一:SITL & HITL模拟框架

PX4模块设计之三:自定义uORB消息

PX4开源工程结构简明介绍

PX4开发环境搭建--模拟器编译

软件构架,架构和框架的区别

wfb-ng 开源工程结构&代码框架简明介绍