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() |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!