Attitude Control (Copter Code Overview)

2023-05-16

Attitude Control (Copter Code Overview)

Between AC3.1.5 and AC 3.2 the attitude control logic was restructured as part of “the onion” project. The new structure is shown below.

../_images/AC_CodeOverview_ManualFlightMode.png

On every update (i.e. 400hz on Pixhawk, 100hz on APM2.x) the following happens:

  • the top level flight-mode.cpp’s “update_flight_mode()” function is called. This function checks the vehicle’s flight mode (ie. “control_mode” variable) and then calls the appropriate <flight mode>_run() function (i.e. stabilize_run for stabilize mode, rtl_run for RTL mode, etc). The <flight mode>_run() function can be found in the appropriately named control_<flight mode>.cpp file (i.e.control_stabilize.cpp, control_rtl.cpp, etc).
  • the <flight mode>_run function is responsible for converting the user’s input (found in g.rc_1.control_in, g.rc_2.control_in, etc) into a lean angle, rotation rate, climb rate, etc that is appropriate for this flight mode. For example AltHold converts the user’s roll and pitch input into lean angles (in degrees), the yaw input is converted into a rotation rate (in degrees per second) and the throttle input is converted to a climb rate (in cm/s).
  • the last thing the <flight mode>_run function must do is pass these desired angles, rates etc into Attitude Control and/or Position Control libraries (these are both held in the AC_AttitudeControlfolder).
  • The AC_AttitudeControl library provides 5 possible ways to control the attitude of the vehicle, the most common 3 are described below.
    • angle_ef_roll_pitch_rate_ef_yaw() : this accepts an “earth frame” angle for roll and pitch, and an “earth frame” rate for yaw. For example providing this function roll = -1000, pitch = -1500, yaw = 500 means lean the vehicle left to 10degrees, pitch forward to 15degrees and rotate right at 5deg/second.
    • angle_ef_roll_pitch_yaw() : this accepts “earth frame” angles for roll, pitch and yaw. similar to above except providing yaw of 500 means rotate the vehicle to 5 degrees east of north.
    • rate_bf_roll_pitch_yaw() : this accepts a “body frame” rate (in degrees/sec) for roll pitch and yaw. For example providing this function roll = -1000, pitch = -1500, yaw = 500 would lead to the vehicle rolling left at 10deg/sec, pitching forward at 15deg/sec and rotating about the vehicle’s z axis at 5 deg/sec.

After any calls to these functions are made the AC_AttitudeControl::rate_controller_run() is called. This converts the output from the methods listed above into roll, pitch and yaw inputs which are sent to the AP_Motors library via it’s set_roll, set_pitch, set_yaw and set_throttle methods. .

  • The AC_PosControl library allows 3D position control of the vehicle. Normally only the simpler Z-axis (i.e. altitude control) methods are used because more complicated 3D position flight modes (i.e. Loiter) make use of the AC_WPNav library. In any case, some commonly used methods of this library include:
    • set_alt_target_from_climb_rate() : this accepts a climb rate in cm/s and updates an absolute altitude target
    • set_pos_target() : this accepts a 3D position vector which is an offset from home in cm

If any methods in AC_PosControl are called then the flight mode code must also call theAC_PosControl::update_z_controller() method. This will run the z-axis position control PID loops and send low-level throttle level to the AP_Motors library. If any xy-axis methods are called thenAC_PosControl::update_xy_controller() must be called.

  • The AP_Motors library holds the “motor mixing” code. This code is responsible for converting the roll, pitch, yaw and throttle values received from the AC_AttitudeControl and AC_PosControl libraries into absolute motor outputs (i.e. PWM values). So the higher level libs would make use of these functions:
    • set_roll(), set_pitch(), set_yaw() : accepts roll, pitch and yaw values in the range of -4500 ~ 4500. These are not desired angles or even rates but rather just a value. For example set_roll(-4500) would mean roll left as fast as possible.
    • set_throttle() : accepts an absolute throttle value in the range of 0 ~ 1000. 0 = motors off, 1000 = full throttle.

There are different classes for each frame type (quad, Y6, traditional helicopter) but in each there is an “output_armed” function which is responsible for implementing the conversion of these roll, pitch, yaw and throttle values into pwm outputs. This conversion often includes implementing a “stability patch” which handles prioritising one axis of control over another when the input requests are outside the physical limits of the frame (i.e. max throttle and max roll is not possible with a quad because some motors must be less than others to cause a roll). At the bottom of the “output_armed” function there is a call to the hal.rcout->write() which passes the desired pwm values to the AP_HAL layer.

  • The AP_HAL libraries (hardware abstraction layer) provides a consistent interface for all boards. In particular the hal.rc_out_write() function will cause the specified PWM received from the AP_Motors class to appear on the appropriate pwm pin out for the board.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Attitude Control (Copter Code Overview) 的相关文章

  • 从github上下载的code文件夹图标上有个绿色对勾

    最近发现 xff0c 从github上下载的code文件夹图标上有个绿色对勾 xff0c 如下图 xff1a 经过问师兄和师父 xff0c 是因为这个文件夹中含有 git文件夹 xff0c 如下 xff1a 如果你的文件夹中没看到 git
  • PX4 Offboard Control with MAVROS--Takeoff(一键起飞)

    警告 xff1a 请先在仿真环境下进行测试 xff0c 能达到预期效果后在进行实际飞行测试 xff0c 以免发生意外 本篇文章只是用作学习交流 xff0c 实际飞行时如出现意外情况作者不予以负责 所需材料 1 PIXhawk或者Pixrac
  • 【VS Code】"The 'clang-format' command is not available. Please check your clang-format."报错

    文章目录 34 The 39 clang format 39 command is not available 34 报错说明一 安装插件 clang format 二 解决方案三 参考链接 34 The clang format comm
  • Visual Studio Code (vscode) 配置 C / C++ 环境

    Visual Studio Code vscode 配置 C C 43 43 环境 步平凡 博客园 在电脑安装软件管控严格的情况下 xff0c 想装VS装不了 xff0c 就装轻量版的VSCode了 以上写得很好 xff0c 照做即可 本人
  • 802.11标准deauth报文的reason code中文版

    代码 原因 0 保留 1非特定原因 2以前的身份验证不再有效 3由于发送STA离开 xff08 或已经离开 xff09 ibs或ESS而被取消身份验证 4由于不活动而解除关联 5已解除关联 xff0c 因为AP无法处理所有当前关联的STA
  • python解析DataMatrix Code二维码

    span class token comment 安装 span span class token triple quoted string string 39 39 39 sudo apt get install libdmtx0a pi
  • 【vsCode + Arduino】在Visual Studio Code编译Arduino项目

    目录 前言一 参考文档二 操作步骤2 1 安装Arduino IDE2 2 在vsCode里安装Arduino插件2 3 配置arduino的安装路径2 4 配置好后打开一个Arduino的项目文件夹进行相应的配置 三 目前已知问题 前言
  • Ubuntu 16.04下安装visual studio code

    一 坑和解决办法 很多帖子上写的方法都是使用命令方式 xff1a 1 先安装make sudo add apt repository ppa ubuntu desktop ubuntu make sudo apt get update su
  • Code Composer Studio的配置及下载事项

    SDK版本 xff1a SIMPLELINK CC13X2 26X2 SDK v5 20 0 52 适用场景 xff1a 首次将工程文件配置到本地时 xff1b 有bim工程 oad工程 协处理器程序多个部分混杂 xff1b 异常问题 xf
  • VS Code For Web 深入浅出 -- 进程间通信篇

    在上一篇中 xff0c 我们一起分析了 VS Code 整体的代码架构 xff0c 了解了 VS Code 是由前后端分离的方式开发的 且无论前端是基于 electron 还是 web xff0c 后端是本地还是云端 xff0c 其调用方式
  • 【MFC开发(17)】高级列表控件List Control

    1 介绍 ListCtrl 高级列表控件也是我们平时编程过程中很常用的一个控件 xff0c 一般涉及到报表展示 记录展示之类的 xff0c 都需要ListCtrl 高级列表控件 例如 xff1a 任务管理器啊 xff0c 文件列表啊 xff
  • 使用Visual Studio Code开发Arduino踩坑日记(持续更新)

    使用Visual Studio Code开发Arduino踩坑日记 持续更新 文章目录 使用Visual Studio Code开发Arduino踩坑日记 持续更新 1 在browse path中未找到包含文件问题描述问题分析解决思路解决过
  • 键盘常用code码对照表

    功能键code值 字母和数字code值 常用控制键code值
  • 【Struct(结构体)杂谈之六】无既是有---没有成员变量的Struct(结构体)

    没有成员变量的Struct 结构体 在开始本篇之前 想问大家一个问题 0是什么 呵呵 就是没有呗 那好 这5块钱拿去 就当抵我上次向你借的500块钱 什么 这哪和哪啊 这不一样 可是你自己说的 0就是 没有 我说不清 反正不行 你必须还我5
  • IOU

    IOU 即交并比 应用 NMS 过滤重叠框 mAP import numpt as np def get IOU pred bbox gt bbox ixmin max pred bbox 0 gt bbox 0 iymin max pre
  • java实现mysql数据库增删改查

    本文将介绍java实现数据库增删改查的操作方法定义的代码 包括statment和preparestatment两种模式 两种的区别可以参考别的文章 按需选用 例 getdata是statment的查询的方法 pgetdata是prepare
  • 短 URL 服务的设计与实现

    转载 https mp weixin qq com s DJM7KFFfgZ2AgfrrYHXSzQ 短url的好处有 短 短信和许多平台 微博 有字数限制 太长的链接加进去都没有办法写正文了 好看 比起一大堆不知所以的参数 短链接更加简洁
  • 如何实现零宕机的配置热加载

    对于高可用的服务 为了保证服务可用性 更新配置时必然不能直接停止服务 可以使用配置热加载来避免服务暂停 不需要重启服务 配置的热加载可以分为两个场景 手动更新与自动更新 手动更新 对于一些临时调试 服务数量不多的情况下 可以进行手动更新配置
  • 【PID】51单片机PID控制电机转速

    PID参考链接 PID增量控制 include Pid Init h include main h extern u16 out extern u16 CurSpeed extern u16 SpeedSet extern u16 PWMT
  • 【C++】在线IDE

    1 洛谷在线IDE https www luogu com cn ide 2 菜鸟工具 https c runoob com compile 12 3 Cloud Studio https cloudstudio net

随机推荐

  • ROVIO解析

    http jinjaysnow github io blog 2017 07 ROVIO E8 A7 A3 E6 9E 90 html 基于EKF的鲁棒视觉惯性测量Robust Visual Inertial Odometry ROVIO
  • PLC前途如何,大学生能学吗,不要指望学会PLC就能月薪15000

    我这里没有鸡汤也没有鸭汤 xff0c 都是实在大白话 xff0c 技术出身的人大概都有点固执 xff0c 但是很务实 xff0c 总是认为只要把技术掌握了学好了 xff0c 就能拿到理想的工资 但是这句话也不能说没道理 xff0c 任何事物
  • 给自动化专业的大学生的终极警钟,单片机、PLC、嵌入式等方向哪个才是香饽饽?

    从面向工资的角度来说 xff0c 假设你不升学历的话 xff0c 推荐优先选择序列如下 xff1a 1 嵌入式 xff08 ARM 43 Linux xff09 xff1a 可对接工业机器人 物联网 高端3C产品设计 xff0c 但要去补课
  • STM32F1和STM32F4这两个系列都是单片机达人的心头好,到底那个好

    STM32F1和STM32F4这两个系列都是单片机达人的心头好 xff0c 到底那个好呢 大家都知道GD32是国内开发的一款单片机 xff0c 能够说是国货之光 xff0c 据说开发的人员是来自ST公司的 xff0c GD32也是以STM3
  • 嵌入式老师傅告诉你单片机6年想转嵌入式Linux值不值得

    嵌入式老师傅告诉你单片机6年想转嵌入式Linux值不值得 一 你真的决定要转嵌入式Linux吗 xff1f 要不要从单片机转嵌入式Linux是一个影响到职业开展的严肃决策 xff0c 我不能帮你拿主见 xff0c 只能帮你列出利弊 xff0
  • STM32收入高也好找工作,所以我学嵌入式linux终究是错付了吗

    STM32收入高也好找工作 xff0c 所以我学嵌入式linux终究是错付了吗 经常有同学纠结问我 xff1a 我到底是学STM32还是学嵌入式linux 这个问题很多人都会有自己的看法 xff0c 今天我试着从多个角度 xff0c 把了解
  • linux下close无法关闭socket

    由于close之后阻塞的recv出现不能立即返回关闭 xff0c socket进入被动一方 这种情况多数是创建和关闭处于不同的线程 解决办法在调用close函数之前先调用shutdown socket SHUT RDWR 函数
  • FPGA是什么呢,通透讲解单片机和FPGA的区别

    FPGA是什么呢 xff0c 通透讲解单片机和FPGA的区别 插播一条 xff1a 我自己在今年年初录制了一套还比较系统的入门单片机教程 xff0c 想要的同学找我拿就行了免費的 xff0c 私信我就可以哦 点我头像黑色字体加我地球呺也能领
  • 摊牌了我后悔入行了,浅谈为何不该入行嵌入式

    摊牌了我后悔入行了 xff0c 浅谈为何不该入行嵌入式 插播一条 xff1a 我自己在今年年初录制了一套还比较系统的入门单片机教程 xff0c 想要的同学找我拿就行了免費的 xff08 禾厶 亻言 手戈 xff09 最近比较闲 xff0c
  • 关于嵌入式Linux做底层还是应用,要掌握什么技能

    关于嵌入式Linux做底层还是应用 xff0c 要掌握什么技能 插播一条 xff1a 我自己在今年年初录制了一套还比较系统的入门单片机教程 xff0c 想要的同学找我拿就行了免費的 xff08 禾厶 亻言 手戈 xff09 最近比较闲 xf
  • c语言必背的100代码

    c语言必背的100代码 插播一条 xff1a 自己在今年整理一套单片机单片机相关论文800余篇 论文制作思维导图 原理图 43 源代码 43 开题报告 43 正文 43 外文资料 想要的同学私信找我 我记得刚开始接触编程的时候 xff0c
  • 51单片机简介

    51单片机简介 插播一条 xff1a 文章末尾有惊喜哟 一 51单片机标识信息 通常我们所说的51单片机是指以51内核扩展出的单片机 出产51单片机的厂商很多 xff0c 51单片机的型号也很多 下表列出了一些51单片机的厂商和型号 以上提
  • 都2022年了,互联网与嵌入式怎么选?

    都2022年了 xff0c 互联网与嵌入式怎么选 xff1f 2022届应届毕业生前来作答一波 大家找工作最关心的还是薪资待遇问题 从今年的校招情况来看 xff0c 互联网中的算法岗是要高于嵌入式的 xff0c 而开发岗整体和嵌入式持平 从
  • 做工程师还是转型做产品经理?

    做工程师还是转型做产品经理 xff1f 其实在国内互联网萌芽之初 xff0c 技术 产品 设计 运营职位其实区分的不是特别明显 xff0c 往往是一人身兼多职 xff0c 但随着行业的成熟 xff0c 这些职位之间的分工才逐渐细化 xff1
  • 为什么游戏里的都是伪随机,做不出真随机?

    为什么游戏里的都是伪随机 xff0c 做不出真随机 xff1f 希望来个简单易懂的解释 xff1f 我发现像LOL这些游戏 xff0c 暴击机制都是伪随机的 xff0c 前面几下没暴击 xff0c 后面暴击几率很大概率 像王者荣耀更为明显
  • 高学历毕业生,该学单片机还是plc?

    高学历毕业生 xff0c 该学单片机还是plc xff1f 研究生阶段 xff0c 使用欧姆龙和西门子的PLC做过一些商用的项目 xff0c 但是在课题研究过程中因为偏向于控制算法的落地实现 xff08 借助SOC 43 FPGA xff0
  • 无人机飞控平台ArduPilot源码入门教程 - 首页

    原文链接 简介 ArduPilot代码库有点大 核心的ardupilot git树大概有70万行代码 对新人来说这有点吓人 这个文档打算给出一点建议 关于如何快速上手相关代码 我们假设你熟悉C 43 43 的关键概念 另外好多例子都是假设你
  • C++ 常见面试和笔试坑点总结(持续更新)

    题目一 xff1a 下面的程序是执行if还是else span class hljs keyword int span a 61 span class hljs number 2 span span class hljs keyword i
  • 速腾聚创32线雷达雷达,RVIZ显示激光点云

    1 下载驱动文件 ahren 64 ahren ld ws src git clone https github com RoboSense LiDAR ros rslidar 2 在工作空间ld ws目录下编译 ahren 64 ahre
  • Attitude Control (Copter Code Overview)

    Attitude Control Copter Code Overview Between AC3 1 5 and AC 3 2 the attitude control logic was restructured as part of