前言

图 1 IMU 与姿态检测

惯性测量单元是测量物体三轴姿态角(或角速率)以及加速度的装置。一般的,一个IMU包含了三个单轴的加速度计和三个单轴的陀螺,加速度计检测物体在载体坐标系统独立三轴的加速度信号,而陀螺检测载体相对于导航坐标系的角速度信号,测量物体在三维空间中的角速度和加速度,并以此解算出物体的姿态。在导航中有着很重要的应用价值。

pitch、yaw、roll三个角的区别

pitch是围绕Y轴旋转,也叫做俯仰角。

yaw是围绕Z轴旋转,也叫偏航角。

roll是围绕X轴旋转,也叫翻滚角。


消息类型定义

类型:sensor_msgs/Imu.msg

# This is a message to hold data from an IMU (Inertial Measurement Unit)
#
# Accelerations should be in m/s^2 (not in g's), and rotational velocity should be in rad/sec
#
# If the covariance of the measurement is known, it should be filled in (if all you know is the
# variance of each measurement, e.g. from the datasheet, just put those along the diagonal)
# A covariance matrix of all zeros will be interpreted as "covariance unknown", and to use the
# data a covariance will have to be assumed or gotten from some other source
#
# If you have no estimate for one of the data elements (e.g. your IMU doesn't produce an orientation
# estimate), please set element 0 of the associated covariance matrix to -1
# If you are interpreting this message, please check for a value of -1 in the first element of each
# covariance matrix, and disregard the associated estimate.Header headergeometry_msgs/Quaternion orientation
float64[9] orientation_covariance # Row major about x, y, z axesgeometry_msgs/Vector3 angular_velocity
float64[9] angular_velocity_covariance # Row major about x, y, z axesgeometry_msgs/Vector3 linear_acceleration
float64[9] linear_acceleration_covariance # Row major x, y z 

加载方式:

from sensor_msgs.msg import Imu

解释

文档描述了Imu的消息结构,其中姿态(orientation)类型为四元数(geometry_msgs/Quaternion);角速度(angular_velocity)和线加速度(linear_acceleration)的类型为三维向量(geometry_msgs/Vector3)。

四元数(Quaternion)转欧拉角(Euler-Angles)

四元数是一种姿态的表达方式,与欧拉角相比,它规避了“万向节锁”的问题。《四元素、欧拉角及方向余弦矩阵的相互转化公式》讲解了四元数与欧拉角的相互转换。这个视频形象地介绍了万向节锁的问题。

转换程序:

#!/usr/bin/env python
# license removed for brevityimport rospy
from sensor_msgs.msg import Imu
import mathdef imu_cb(imu_data):# Read the quaternion of the robot IMUx = imu_data.orientation.xy = imu_data.orientation.yz = imu_data.orientation.zw = imu_data.orientation.w# Read the angular velocity of the robot IMUw_x = imu_data.angular_velocity.xw_y = imu_data.angular_velocity.yw_z = imu_data.angular_velocity.z# Read the linear acceleration of the robot IMUa_x = imu_data.linear_acceleration.xa_y = imu_data.linear_acceleration.ya_z = imu_data.linear_acceleration.z# Convert Quaternions to Euler-Anglesrpy_angle = [0, 0, 0]rpy_angle[0] = math.atan2(2 * (w * x + y * z), 1 - 2 * (x**2 + y**2))rpy_angle[1] = math.asin(2 * (w * y - z * x))rpy_angle[2] = math.atan2(2 * (w * z + x * y), 1 - 2 * (y**2 + z**2))returnif __name__ == '__main__':rospy.init_node('imu_node', anonymous=True)rospy.Subscriber("/pigot/imu", Imu, imu_cb)rospy.spin()

值得注意的是:

在很多场合我们使用实际的IMU获得sensor_msgs/Imu.msg中的orientation明明是四元数(Quaternion),却直接赋值的是欧拉角,即imu_data.orientation.x、imu_data.orientation.y、imu_data.orientation.z直接为角度值,找了一些资料,发现好像都可以,也就是说ROS内部会自行转换。

资料

  • 小明工坊:【ROS-Gazebo】IMU插件使用与数据采集——以四足机器人pigot为例
  • Imu 格式消息官方文档
  • 四元数与欧拉角(RPY角)的相互转换

ROS【IMU】姿态检测与解算相关推荐

  1. 【灵动MM32-姿态角解算】移植MPU6050-DMP库实现姿态角PRY解算

    MM32使用DMP库处理MPU6050数据.姿态解算 实现途径: ①MM32F3277G9P单片机 ②MPU6050模块 ③智能车逐飞MM32开源库 ④正点原子dmp开源库 开源库链接: 逐飞科技MM ...

  2. python 数据处理 姿态角数据解算

    对于姿态角解算,目前我所知道的只有两种,一种是DMP库解算出姿态角.一种是算法进行姿态解算: 本次说的是姿态解算,采集的是六轴的原始数据,用python进行姿态解算:废话不多说,看程序,有注解的.. ...

  3. 单目相机三维姿态解算

    单目相机三维姿态解算 Abstract:This passage mainly describes how to solve pose(Yaw,Pitch,Roll)with signal camer ...

  4. 树莓派IIC通讯获取BMI08x IMU数据进行姿态解算,并通过UART/TCP在rviz上显示

    截至2021年,树莓派出的最新款应该是Raspberry Pi 400,设计得跟键盘一样,很难想象到这是个树莓派,尤其是它的标语写的很好"你的下一个电脑,何必是电脑",不言而喻.反 ...

  5. 卡尔曼滤波五个公式_基于ROS的卡尔曼滤波姿态解算

    前段时间由于项目关系需要实现基于卡尔曼滤波的姿态解算,也就是说融合加速度计.陀螺仪及磁罗盘进行AHRS姿态解算,得到机器人的姿态角. 本文的学习需要有一定的卡尔曼滤波器基础,可以参考白巧克力亦唯心的卡 ...

  6. 四元数AHRS姿态解算和IMU姿态解算分析

    ref:https://blog.csdn.net/xiaoxie613520/article/details/78227170 AHRS是自动航向基准系统(Automatic Heading Ref ...

  7. IMU:姿态解算算法集合

    文章目录 一.IMU原理 二.源码 一.IMU原理 二.源码 源文件: #include "IMU.h" #include "math.h"#define Kp ...

  8. imu matlab,IMU姿态解算matlab

    [实例简介] IMU姿态解算matlabIMU姿态解算matlabIMU姿态解算matlab [实例截图] [核心代码] GaitTrackingWithx-IMU └── Gait Tracking ...

  9. imu初始对准的姿态角解算注意事项

    众所周知,在b系下的一个向量要投影到n系,需要其在b系下的坐标,乘上方向余弦矩阵Cnb.根据此原理,通过分别找到两个坐标系下对应的的三个不平行矢量,即可求解出该矩阵.在武大牛小骥的ppt中介绍了姿态阵 ...

最新文章

  1. Spring MVC 单元调试和访问
  2. 大数据druid查询不支持分页_Klin、Druid、ClickHouse核心技术对比
  3. 应用程序启动器选项卡以及页面内容的设置
  4. python document_python 处理document文档 保留原样式
  5. pom.xml dependency依赖的研究
  6. 在Apache Hadoop(多节点群集)中运行Map-Reduce作业
  7. 7月送书中奖名单,快看!
  8. bzoj 3994 约数个数和 —— 反演+数论分块
  9. AAAI论文Joint Extraction of Entities and Overlapping Relations Using Position-Attentive Sequence阅读笔记
  10. 实现自动登录:Filter 实现思路和方式
  11. Windows下Nginx源码编译指南
  12. Matlab:Matlab 软件学习之GUI图像用户界面简介(工具栏/菜单栏/对话框)、GUI界面设计案例应用(设计二级菜单栏)之详细攻略
  13. STM32接入机智云--实现数据上传和命令下发
  14. Deepin系统配置开机自启动
  15. 招标流程及注意事项_2016招投标流程及注意事项.ppt
  16. 二进制学习-反跟踪技术
  17. 川的第一份博客——内容定义
  18. 腾讯云服务器用户名在哪里看,腾讯云服务器如何查看账号操作日志信息
  19. sinon.js的spy、stub和mock
  20. C++ 背包问题——多重背包

热门文章

  1. 11.22IG客户情绪报告: 黄金、原油、澳元、日元、欧元、英镑
  2. 将insert语句转化为select语句,进行校验,验证是否插入成功
  3. 计算机键盘被锁怎么解,电脑键盘锁了怎么解锁 电脑键盘解锁方法【详解】
  4. 跨境电商亚马逊卖家最需要关注的四个维度的数据
  5. laravel-excel使用2(老猫包子店的故事)
  6. 蓝牙学习五(广播包分析wireshark)
  7. 好东西——计算机原理学习(序)
  8. 第14周C++兄弟营团队学习情况记录表
  9. 三天时间, 无线破解从入门到放弃
  10. Directional Adversarial Training for Recommender Systems