• header: 消息头,包含序列号、时间戳和坐标系等信息。
  • orientation: IMU 的当前朝向,用四元数表示,包括 $x, y, z$ 和 $w$ 四个值。
  • orientation_covariance: 朝向协方差矩阵,包含 $9$ 个元素,描述 IMU 测量的朝向误差。
  • angular_velocity: IMU 的角速度,包含 $x, y, z$ 三个分量。
  • angular_velocity_covariance: 角速度协方差矩阵,包含 $9$ 个元素,描述 IMU 测量的角速度误差。
  • linear_acceleration: IMU 的线性加速度,包含 $x, y, z$ 三个分量。
  • linear_acceleration_covariance: 线性加速度协方差矩阵,包含 $9$ 个元素,描述 IMU 测量的线性加速度误差。

 

使用话题获得imu的欧拉角

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Imu
from tf.transformations import euler_from_quaternion
 
def imu_callback(msg):
    # 从 IMU 数据中获取四元数
    orientation_q = msg.orientation
 
    # 将四元数转换为欧拉角
    (roll, pitch, yaw) = euler_from_quaternion([orientation_q.x, orientation_q.y, orientation_q.z, orientation_q.w])
 
    # 输出欧拉角信息
    print('Roll: %.2f, Pitch: %.2f, Yaw: %.2f' % (roll, pitch, yaw))
 
if __name__ == '__main__':
    # 创建 ROS 节点和订阅 IMU 话题
    rospy.init_node('imu_subscriber')
    rospy.Subscriber('/imu_topic', Imu, imu_callback)
 
    # 循环等待回调函数
    rospy.spin()

 

posted on   黑逍逍  阅读(466)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!



点击右上角即可分享
微信分享提示