打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
imu_test
#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <turtlesim/Pose.h>
#include <iostream>
#include <signal.h>
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sanbot_msgs/ctrlMesg.h"
#include "std_srvs/Empty.h"
#include <actionlib/client/simple_action_client.h>
#include <move_base_msgs/MoveBaseAction.h>
#include "nav_msgs/Path.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>  
#include <fstream>  
#include <string>
#include <stdlib.h>
#include "actionlib_msgs/GoalStatusArray.h"
#include <boost/thread.hpp>
#include <geometry_msgs/PoseStamped.h>
#include <sensor_msgs/Imu.h>


class imuTest{
public:

imuTest()
{
ros::NodeHandle n;
// 订阅move_base状态
status_sub_ = n.subscribe<sensor_msgs::Imu>("imu_data", 1, &imuTest::Q_to_E, this);

// 不断检测topic数据
ros::spin();
}
double angleTurn(double angle)
{
double degrees = angle * 180.0 / M_PI; // conversion to degrees
if( degrees < 0 ) 
degrees += 360.0; // convert negative to positive angles
return degrees;
}

void Q_to_E(sensor_msgs::Imu imu)
{
double yaw,pitch,roll;
tf::Matrix3x3(tf::Quaternion(imu.orientation.x,imu.orientation.y,imu.orientation.z,imu.orientation.w)).getRPY(roll,pitch,yaw);
printf("\nQ_to_E:--- roll:[%f] pitch:[%f] yaw:[%f]\n", angleTurn(roll), angleTurn(pitch), angleTurn(yaw));
}
private:
ros::Subscriber status_sub_;
};

int main(int argc, char *argv[])
{
ros::init(argc, argv, "imu_test_node");
imuTest IT;
return 0;
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
LCM的安装与使用
里程计
开源无人机集群.1(ROS介绍)
ROS探索总结(十九)~(二十四)(转)
ROS tf基础使用知识
(ros/navigation/gmapping)导航/建地图
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服