px4中mixer_multirotor.cpp混控程序解读

2023-05-16

目录

 一、函数说明

二、具体步骤

1.简单混控无边界,无边界输出,不混合偏航

2.限幅

3.加入比例缩放和偏航,使输出范围限制在[0,1]

4、 融合怠速处理

 


 一、函数说明

混控函数在MIX函数

MultirotorMixer::mix(float *outputs, unsigned space)

查看注释

/* Summary of mixing strategy:

    1) mix roll, pitch and thrust without yaw.

    2) if some outputs violate range [0,1] then try to shift all outputs to minimize violation ->

        increase or decrease total thrust (boost). The total increase or decrease of thrust is limited

        (max_thrust_diff). If after the shift some outputs still violate the bounds then scale roll & pitch.

        In case there is violation at the lower and upper bound then try to shift such that violation is equal

        on both sides.

    3) mix in yaw and scale if it leads to limit violation.

    4) scale all outputs to range [idle_speed,1]*/

二、具体步骤

可以知道混控具体分为四步

1.简单混控无边界,无边界输出,不混合偏航

for (unsigned i = 0; i < _rotor_count; i++) {

        float out = roll * _rotors[i].roll_scale +

             pitch * _rotors[i].pitch_scale +

             thrust * _rotors[i].thrust_scale;  

//  其中rotor[i]这个矩阵就是机型的混控模型矩阵,是由程序编译时生成的mixer_multirotor_normalized.generated.里面可以看到不同机型混控矩阵

   /* 计算最大最小值 */

        if (out < min_out) {

            min_out = out;

        }

        if (out > max_out) {

            max_out = out;

        }

        outputs[i] = out;

    }

2.限幅

如果某些输出超出范围[0,1],则尝试移动所有输出以将超出最大最小值的增加或减少总推力(增压)。推力的总增加或减少是有限的。

   最大最小之差小于1,可以通过偏移解决。加油油门增加幅度大于|min|,可以通过增加油门的方式解决,boost = -min_out;如果油门增加幅度太小,需要把roll和pitch的比列缩放后再计算

float boost = 0.0f;        // value added to demanded thrust (can also be negative)所需推力的附加值(也可以是负值)

    float roll_pitch_scale = 1.0f;  // scale for demanded roll and pitch所需滚动和俯仰的比例

    float delta_out_max = max_out - min_out; // distance between the two extrema两个极端之间的距离

if (delta_out_max <= 1.0f) {

        if (min_out < 0.0f) {

            boost = -min_out;

        } else if (max_out > 1.0f) {

            boost = -(max_out - 1.0f);

        }

    } else {

        roll_pitch_scale = 1.0f / (delta_out_max);

        boost = 1.0f - ((max_out - thrust) * roll_pitch_scale + thrust);

//这个boost就是将输出区间缩放到[0,1]的偏移量,可以带入下面的输出公式中验证出来,这是个很牛逼的归一化公式

    }

3.加入比例缩放和偏航,使输出范围限制在[0,1]

//再次混合,但现在加入推力增益,缩放滚动/俯仰,也增加偏航。

    for (unsigned i = 0; i < _rotor_count; i++) {

        float out = (roll * _rotors[i].roll_scale +

             pitch * _rotors[i].pitch_scale) * roll_pitch_scale +

             yaw * _rotors[i].yaw_scale +

             (thrust + boost) * _rotors[i].thrust_scale;

        //如果偏航超出限制,则进行缩放。减小下溢出

        if (out < 0.0f) {

            if (fabsf(_rotors[i].yaw_scale) <= FLT_EPSILON) {

                yaw = 0.0f;

            } else {

                yaw = -((roll * _rotors[i].roll_scale + pitch * _rotors[i].pitch_scale) *

                    roll_pitch_scale + thrust + boost) / _rotors[i].yaw_scale;

            }

        } else if (out > 1.0f) {

            //允许减小推力以获得一些偏航响应

            float prop_reduction = fminf(0.15f, out - 1.0f);

            //保持请求的最大减少量

            thrust_reduction = fmaxf(thrust_reduction, prop_reduction);

            if (fabsf(_rotors[i].yaw_scale) <= FLT_EPSILON) {

                yaw = 0.0f;

            } else {

                yaw = (1.0f - ((roll * _rotors[i].roll_scale + pitch * _rotors[i].pitch_scale) *

                     roll_pitch_scale + (thrust - thrust_reduction) + boost)) / _rotors[i].yaw_scale;

            }

        }

    }

4、 融合怠速处理

    //应用总推力减小,一个支柱的最大值

    thrust -= thrust_reduction;

    //将偏航和缩放输出添加到范围空闲速度…1

    for (unsigned i = 0; i < _rotor_count; i++) {

        outputs[i] = (roll * _rotors[i].roll_scale +

             pitch * _rotors[i].pitch_scale) * roll_pitch_scale +

             yaw * _rotors[i].yaw_scale +

             (thrust + boost) * _rotors[i].thrust_scale;

   outputs[i] = math::constrain(_idle_speed + (outputs[i] * (1.0f - _idle_speed)), _idle_speed, 1.0f);

}

最后输出时候进行了一下滤波检查

/* slew rate limiting and saturation checking 转换速率限制和饱和检查*/

    for (unsigned i = 0; i < _rotor_count; i++) {

        bool clipping_high = false;

        bool clipping_low = false;

        // check for saturation against static limits根据静态极限检查饱和度

        if (outputs[i] > 0.99f) {

            clipping_high = true;

        } else if (outputs[i] < _idle_speed + 0.01f) {

            clipping_low = true;

        }

       根据转换速率限制检查饱和度

        if (_delta_out_max > 0.0f) {

            float delta_out = outputs[i] - _outputs_prev[i];

            if (delta_out > _delta_out_max) {

                outputs[i] = _outputs_prev[i] + _delta_out_max;

                clipping_high = true;

            } else if (delta_out < -_delta_out_max) {

                outputs[i] = _outputs_prev[i] - _delta_out_max;

                clipping_low = true;

            }

        }

        _outputs_prev[i] = outputs[i];

}

算法就这些,很清晰,几个简单的公式就可以将控制平稳输出,适用于多种机型,是很牛比的,在研究代码期间我也领悟了很多,二次开发一定要多查资料,搞清算法程序框架

谢谢大佬的文章,让我收益良多https://blog.csdn.net/qq_27016651/article/details/81123204

 
 

 

 

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

px4中mixer_multirotor.cpp混控程序解读 的相关文章

随机推荐

  • 联想SR590服务器管理界面配置

    1 连接登录远程管理界面 将笔记本和服务器的管理口用网线连接 xff0c 配置笔记本的ip地址 xff0c 改成192 168 70 XXX xff0c 255 255 255 0 xff0c 如下图 xff1a 改完ip地址ping一下服
  • Qt鼠标点击不响应QMouseEvent事件的解决办法

    最近在写程序在和同事合完代码后发现一个问题 项目是使用qt开发一个程序 有一个功能是要实现地图的标记功能 我需要在一个label控件上显示地图 然后再选中标记按钮后点击地图 会在鼠标点击的位置放置一个标记的图标并储存备注信息 那么实现这个功
  • 匿名飞控程序整理

    主程序框图如下 xff0c 接下来我会将各个模块全部单独整理出来 xff0c 一是分享 xff0c 也是给自己留个便于查阅 主函数main c int main void flag start ok 61 All Init 进行所有设备的初
  • ORB_SLAM2 运行TUM RGBD数据集过程记录

    一 编译代码 这里是用ubuntu20 04 opencv4安装orbslam2的一点记录 报错信息经过搜索找到了对应的解决办法 xff0c 在这里做一个笔记 报错1 xff1a FATAL ERROR 34 OpenCV gt 2 4 3
  • 匿名飞控设备初始化All_Init()函数代码整理

    目录 初始化All Init 1 Para Data Init 参数初始化 2 Remote Control Init 遥控器输入类型 3 PWM Out Init 电调输出的初始化 4 spi 2初始化 xff0c 用于读取飞控板上所有传
  • 匿名飞控线程初始化和调度是怎么实现的

    目录 一 线程初始化 先看下Scheduler Setup xff08 xff09 函数 xff0c 二 任务调度器 函数在文件Ano Scheduler c中 xff0c Scheduler Setup xff08 xff09 初始化后
  • QGC编译报错error C2220: 警告被视为错误 最佳解决方法

    前面搜了一下 xff0c 试过各种方法依然报错 xff0c 先整理别人的解决方法 目录 一 重新保存文件 二 xff0c 更改编码方式 三 最终解决方案 xff1a 修改配置文件 一 重新保存文件 注意这里的配置 Wx WX 二 xff0c
  • 整理px4飞控校准机制和qgc校准机制

    用qgc执行 px4飞控传感器校准时 的步骤确实很麻烦 xff0c 磁罗盘需要转6个面 xff0c 加速度计也需要6个面 大疆无人机的校准很简单 xff0c 加速度计需要静置一会 xff0c 磁罗盘校准也就转一个面就行了 xff0c 就算学
  • mavros操作飞机时方向位置改为机体坐标系下指令

    前面试了很多 xff0c 看官网里的说明 用 mavros setpoint raw local 34 里的frame id改为 34 base link 34 不行 又直接发mavros msgs PositionTarget 修改里面的
  • px4室内飞行通过SLAM发送位置消息

    先按照官方的教程设置好飞控参数 http docs px4 io master zh computer vision visual inertial odometry html 下载源码学习 xff1a https github com A
  • MCUXpresso调试FreeRTOS时显示多线程

    多线程程序调试起来确实麻烦 xff0c 在调试过程中默认只能看到当前线程 按照以下配置即可在程序暂停时查看多线程的状态 xff1a 在debug配置中选中下图所示 xff1a 配置完成后再调试程序即可显示多线程
  • px4 编译生成msg消息机制及将其移植方法

    目录 一 在px4中添加新的Topic 二 px4生成msg生成的结构体优势 三 msg生成工具及移植方法 一 在px4中添加新的Topic 在px4中是通过uorb进行消息的传递 xff0c 通过根目录下的msg文件可以添加自定义的消息
  • px4传感器数据sensor模块整理

    涉及传感器数据的流程 xff0c 大致整理如下图 传感器的数据从drivers中调用lib中dirvers对应的对象更新数据并发布出去 xff0c sensor模块通过订阅原始数据和校准参数 xff0c 对数据滤波并更正 xff0c 然后再
  • C#实现程序一次打开两个窗口,两个窗口分别放置在两个屏幕

    这是本人在编程中碰到的一个问题 xff0c 寻找了其他案例 xff0c 都只是同时打开两窗口 xff0c 但不能实现在拥有两块显示屏时候 xff0c 分别将两个不同的窗口显示在两个单独的屏幕 源代码https download csdn n
  • 探寻C#事件本质

    我最先在学习C 事件的时候 xff0c 阅读了许多书籍 xff0c 但总是不能对事件建立起一个比较清晰的概念 xff0c 对其内部机制和原理也是似是而非 xff0c 因为这些书籍在描述事件的时候总是夹杂许多其他不能理解的抽象术语 xff0c
  • C#chart绘折线图动态添加数据

    C 入门基础 xff0c 实现chart控件动态添加数据 源程序https download csdn net download qq 42237381 10742048 目录 一 效果示意 二 原理说明 三 代码参考 一 效果示意 最终程
  • C#Winform程序制作仿真地平仪,磁罗盘飞行仪表盘

    因为项目需要做一个电子飞行仪表盘包括地平仪和磁罗盘 xff0c 网上找了很久 xff0c 没有找到一个合适的控件 xff0c 就学习了一些图形处理的开源代码做一个简陋的仪表盘来使用 xff0c 希望对其他人有帮助 xff0c 如果有好的建议
  • pixhawk学习

    原文转载至https blog csdn net u013181595 article details 80976610 1硬件架构分析 Pixhawk是一款基于ARM芯片的32位开源飞控 xff0c 由ETH的computer visio
  • 由浅入深对卡尔曼滤波的学习

    原文来自http shequ dimianzhan com articles 337 extended kalman filter course from shallow to deep 搬运过来好好学习 本篇译文翻译自 The Exten
  • px4中mixer_multirotor.cpp混控程序解读

    目录 一 函数说明 二 具体步骤 1 简单混控无边界 无边界输出 不混合偏航 2 限幅 3 加入比例缩放和偏航 使输出范围限制在 0 1 4 融合怠速处理 一 函数说明 混控函数在MIX函数 MultirotorMixer mix floa