当前位置:网站首页>APM电机输出逻辑(Motors类详解)
APM电机输出逻辑(Motors类详解)
2022-07-29 20:37:00 【公子_羽】
一、概述
电机类是控制类与PWM输出之间的桥梁。向上屏蔽了机架类型,动力类型;向下输出了控制类输出的控制值(归一化-1~1之间的数值)。
二、类图分析
见图(1)左下角部分,AP_Motors是其他所有电机类的父类。多旋翼的话是AP_MotorsMulticopter类继承AP_Motors;变浆距类飞行器是AP_MotorsHeli继承AP_Motors。这通过编译命令控制(./waf copter 生成前一个;./waf heli生成后一个)。再后一层的子类通过地面站的参数控制,取决于所选的机架类型。
电机控制的类图
图(1)
见图(1)右上角部分,AC_AttitudeControl类包含AP_Motors电机类的引用,在被AC_AttitudeControl_Multi继承,最后包含于Copter中。因此Copter中的*attitude_control指针所指向的区域包含AP_Motors部分的代码。同时,Copter类也包含*Motors的指针。
在Copter::init_ardupilot()函数中调用allocate_motors()函数。

图(2)
如图(2)所示,在初始化的时候,根据motor_frame_class参数,实例化具体的Copter::motors指针。再将Copter::motors指针作为参数,传给attitude_control类初始化。因此attitude_control类中的motors就是Copter::motors。
三、电机输出分析
在Copter::fast_loop()函数中以400Hz频率调用motors_output().
下图是APM飞控电机输出的调用顺序图(以直升机输出为例)。向下箭头表示调用关系。

hal.rcout->push()函数输出PWM.
hal.rcout->write(uint8_t chan,uint16_t period_us):该函数将period_us脉宽的pwm写入chan通道。chan从0开始计数,0表示1通道。
边栏推荐
- Second Best PyTorch Beginner Course; Thesis Writing Guide; Using µGo to Develop a Mini Compiler; Super Efficient Use of Transformer's Extension Library; Frontier Papers | ShowMeAI News Daily
- The difference between uri and url is simple to understand (what is the difference between uri and url)
- 高通WLAN框架学习(31)-- Power save
- Baidu internship students late night fun: originally giant is this kind of life
- 一线技术人应该关注的四种思维能力
- Oracle问题: ORA-01882: 未找到时区
- conda virtual environment | install and list problems
- MySQL Data Query - Union Query
- The younger brother asked: Is the work of a programmer a day’s work of code?
- 940. 不同的子序列 II
猜你喜欢

VSCode配置终端为系统命令行

高通WLAN框架学习(31)-- Power save

Cobaltstrike and BurpSuite desktop shortcut configuration

博世集团启动量子数字孪生计划

In 2022, you still can't "low code"?Data science can also play with Low-Code!

无文件落地免杀的初尝试思考(上)

Fully automated machine learning modeling!The effect hangs the primary alchemist!

GET_ENTITYSET Method Implementation Guide for SAP ABAP OData Service Data Provider Class

如何进入董事会:给CIO的十条建议
![LeetCode 593 Valid Squares [Math] HERODING's Road to LeetCode](/img/c2/34624c9c7693ba40d0b3724c0db611.png)
LeetCode 593 Valid Squares [Math] HERODING's Road to LeetCode
随机推荐
WeChat Mini Program 30 Customizing Templates and Obtaining User Login Credentials
JS实现百叶窗特效
:style中颜色使用函数动态获取赋值
378. The Kth Smallest Element in an Ordered Matrix
博世集团启动量子数字孪生计划
The younger brother asked: Is the work of a programmer a day’s work of code?
进程间六种通信方式
全自动化机器学习建模!效果吊打初级炼丹师!
Cobaltstrike和BurpSuite桌面快捷配置
Where is Naive Bayes "naive"?
7 行代码搞崩溃 B 站,原因令人唏嘘!
诺氟沙星-DNA复合物|半乳糖化脂质体-聚阳离子-DNA复合物|注意事项
【Nacos】nacos1.x 单机、内置数据库模式修改密码
一线技术人应该关注的四种思维能力
Setinel 原理简介
Samba server configuration (when a server is required)
.NET 6.0中使用Identity框架实现JWT身份认证与授权
如何优雅的自定义 ThreadPoolExecutor 线程池
五个供应商销售谈判策略的识别以及应对它们的方法
TCP协议详解