ros|TF工具获取IMU数据

void IMUCallback(sensor_msgs::Imu msg){
    if(msg.orientation_covariance[0]<0)//若协方差矩阵第一个值为-1,表示数据不存在
           return; 
    //用TF工具将四元数转化为欧拉角
    tf::Quaternion quaternion(
    msg.orientation.x,
    msg.orientation.y,
    msg.orientation.z,
    msg.orientation.w,
    );
    double roll,pitch,yaw;
    tf::Matrix3x3(quaternion).getRPY(roll,pitch,yaw);
    /*弧度转为角度
    roll=roll*180/M_PI;
    */
}

 

posted @ 2024-03-08 17:43  SandaiYoung  阅读(34)  评论(0编辑  收藏  举报