当前位置: 首页 > news >正文

ArduPilot开源飞控之AP_InertialNav

ArduPilot开源飞控之AP_InertialNav

  • 1. 源由
  • 2. 调用关系
  • 3. 重要例程
    • 3.1 read_inertia
    • 3.2 update
  • 4. 封装接口
    • 4.1 get_filter_status
    • 4.2 get_position_neu_cm
    • 4.3 get_position_xy_cm
    • 4.4 get_position_z_up_cm
    • 4.5 get_velocity_neu_cms
    • 4.6 get_velocity_xy_cms
    • 4.7 get_speed_xy_cms
    • 4.8 get_velocity_z_up_cms
  • 5. 参考资料

1. 源由

AP_InternationalNav类是NavEKF的封装,提供关于导航相关的信息:

  1. 坐标位置
  2. 相对位置
  3. 运动速度
  4. 导航状态

2. 调用关系

状态更新函数调用嵌套关系。

FAST_TASK(read_inertia)└──> Copter::read_inertia└──> AP_InertialNav::update

3. 重要例程

3.1 read_inertia

  1. current_loc.lat
  2. current_loc.lng
  3. current_loc.alt
Copter::read_inertia││  // inertial altitude estimates. Use barometer climb rate during high vibrations├──> inertial_nav.update(vibration_check.high_vibes);││  // pull position from ahrs├──> Location loc;├──> ahrs.get_location(loc);├──> current_loc.lat = loc.lat;├──> current_loc.lng = loc.lng;││  // exit immediately if we do not have an altitude estimate├──> <!inertial_nav.get_filter_status().flags.vert_pos>│   └──> return;││  // current_loc.alt is alt-above-home, converted from inertial nav's alt-above-ekf-origin├──> const int32_t alt_above_origin_cm = inertial_nav.get_position_z_up_cm();├──> current_loc.set_alt_cm(alt_above_origin_cm, Location::AltFrame::ABOVE_ORIGIN);└──> <!ahrs.home_is_set() || !current_loc.change_alt_frame(Location::AltFrame::ABOVE_HOME)>│  // if home has not been set yet we treat alt-above-origin as alt-above-home└──> current_loc.set_alt_cm(alt_above_origin_cm, Location::AltFrame::ABOVE_HOME);

3.2 update

  1. _relpos_cm
  2. _velocity_cm
AP_InertialNav::update││  // get the NE position relative to the local earth frame origin├──> Vector2f posNE;├──> <_ahrs_ekf.get_relative_position_NE_origin(posNE)>│   ├──> _relpos_cm.x = posNE.x * 100; // convert from m to cm│   └──> _relpos_cm.y = posNE.y * 100; // convert from m to cm││  // get the D position relative to the local earth frame origin├──> float posD;├──> <_ahrs_ekf.get_relative_position_D_origin(posD)>│   └──> _relpos_cm.z = - posD * 100; // convert from m in NED to cm in NEU││  // get the velocity relative to the local earth frame├──> Vector3f velNED;└──> <_ahrs_ekf.get_velocity_NED(velNED)>│  // during high vibration events use vertical position change├──> <high_vibes>│   ├──> float rate_z;│   └──> <_ahrs_ekf.get_vert_pos_rate_D(rate_z)>│       └──> velNED.z = rate_z;├──> _velocity_cm = velNED * 100; // convert to cm/s└──> _velocity_cm.z = -_velocity_cm.z; // convert from NED to NEU

4. 封装接口

4.1 get_filter_status

/*** get_filter_status : returns filter status as a series of flags*/
nav_filter_status AP_InertialNav::get_filter_status() const
{nav_filter_status status;_ahrs_ekf.get_filter_status(status);return status;
}union nav_filter_status {struct {bool attitude           : 1; // 0 - true if attitude estimate is validbool horiz_vel          : 1; // 1 - true if horizontal velocity estimate is validbool vert_vel           : 1; // 2 - true if the vertical velocity estimate is validbool horiz_pos_rel      : 1; // 3 - true if the relative horizontal position estimate is validbool horiz_pos_abs      : 1; // 4 - true if the absolute horizontal position estimate is validbool vert_pos           : 1; // 5 - true if the vertical position estimate is validbool terrain_alt        : 1; // 6 - true if the terrain height estimate is validbool const_pos_mode     : 1; // 7 - true if we are in const position modebool pred_horiz_pos_rel : 1; // 8 - true if filter expects it can produce a good relative horizontal position estimate - used before takeoffbool pred_horiz_pos_abs : 1; // 9 - true if filter expects it can produce a good absolute horizontal position estimate - used before takeoffbool takeoff_detected   : 1; // 10 - true if optical flow takeoff has been detectedbool takeoff            : 1; // 11 - true if filter is compensating for baro errors during takeoffbool touchdown          : 1; // 12 - true if filter is compensating for baro errors during touchdownbool using_gps          : 1; // 13 - true if we are using GPS positionbool gps_glitching      : 1; // 14 - true if GPS glitching is affecting navigation accuracybool gps_quality_good   : 1; // 15 - true if we can use GPS for navigationbool initalized         : 1; // 16 - true if the EKF has ever been healthybool rejecting_airspeed : 1; // 17 - true if we are rejecting airspeed databool dead_reckoning     : 1; // 18 - true if we are dead reckoning (e.g. no position or velocity source)} flags;uint32_t value;
};

4.2 get_position_neu_cm

/*** get_position_neu_cm - returns the current position relative to the EKF origin in cm.** @return*/
const Vector3f &AP_InertialNav::get_position_neu_cm(void) const 
{return _relpos_cm;
}

4.3 get_position_xy_cm

/*** get_position_xy_cm - returns the current x-y position relative to the EKF origin in cm.** @return*/
const Vector2f &AP_InertialNav::get_position_xy_cm() const
{return _relpos_cm.xy();
}

4.4 get_position_z_up_cm

/*** get_position_z_up_cm - returns the current z position relative to the EKF origin, frame z-axis up, in cm.* @return*/
float AP_InertialNav::get_position_z_up_cm() const
{return _relpos_cm.z;
}

4.5 get_velocity_neu_cms

/*** get_velocity_neu_cms - returns the current velocity in cm/s** @return velocity vector:*      		.x : latitude  velocity in cm/s* 				.y : longitude velocity in cm/s* 				.z : vertical  velocity in cm/s*/
const Vector3f &AP_InertialNav::get_velocity_neu_cms() const
{return _velocity_cm;
}

4.6 get_velocity_xy_cms

/*** get_velocity_xy_cms - returns the current x-y velocity relative to the EKF origin in cm.** @return*/
const Vector2f &AP_InertialNav::get_velocity_xy_cms() const
{return _velocity_cm.xy();
}

4.7 get_speed_xy_cms

/*** get_speed_xy_cms - returns the current horizontal speed in cm/s** @returns the current horizontal speed in cm/s*/
float AP_InertialNav::get_speed_xy_cms() const
{return _velocity_cm.xy().length();
}

4.8 get_velocity_z_up_cms

/*** get_velocity_z_up_cms - returns the current z-axis velocity, frame z-axis up, in cm/s** @return z-axis velocity, frame z-axis up, in cm/s*/
float AP_InertialNav::get_velocity_z_up_cms() const
{return _velocity_cm.z;
}

5. 参考资料

【1】ArduPilot开源飞控系统之简单介绍
【2】ArduPilot之开源代码Task介绍
【3】ArduPilot飞控启动&运行过程简介
【4】ArduPilot之开源代码Library&Sketches设计
【5】ArduPilot之开源代码Sensor Drivers设计

http://www.lryc.cn/news/192789.html

相关文章:

  • DataX工具部署与使用(PostgreSQL to Oracle)
  • 【PyTorch2 之027】在 PyTorch 中的R-CNN、Fast R-CNN和 Faster R-CNN
  • C++学习——C++函数的编译、成员函数的调用、this指针详解
  • Pulsar Manager和dashboard部署和启用认证
  • K8S环境搭建
  • 常用的软件项目管理工具一览
  • 关于网络协议的若干问题(五)
  • TensorFlow入门(十七、神经元的拟合原理)
  • VSCODE配置C和C++
  • 位于同一子网下的ip在子网掩码配置错误的情况下如何进行通信(wireshrak抓包分析)
  • Dockerfile镜像实战
  • 企业如何选择安全又稳定的文件传输协议
  • Linux Kernel 4.13 RC6发布:正式版9月3日发布
  • C++学习——C++中const的新花样
  • 【Linux环境搭建】五、Linux(CentOS7)编译源码安装Subversion
  • 微信小程序入门讲解【超详细】
  • AtCoder ABC239G 最小割集
  • Simple RPC - 01 框架原理及总体架构初探
  • VScode运行C/C++
  • #智能车项目(三)串口初始化
  • 网络通信错误代码列表 HTTP 、FTP
  • 最新开源ThinkPHP6框架云梦卡社区系统源码/亲测可用(全新开发)
  • [ROS2系列] ubuntu 20.04测试rtabmap
  • 【Java学习之道】JavaFx 框架与组件介绍
  • Windows bat 脚本设计-开机自启动服务的方法、bat 调用另外的 bat 脚本 -没有java环境也能运行jar,在不安装jdk下如何运行jar包
  • zabbix触发器与动作
  • 华纳云:Nginx服务器可视化配置问题怎么解决
  • C指针与一维二维数组、数组指针与指针数组、函数指针_数组的理解使用
  • 安装运行vue-element-admin的报错问题-解决办法
  • 高数笔记03:几何、物理应用