分享

imu_test

 海漩涡 2017-10-09
#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;
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多