Ask Your Question
1

I need convert quaternion to euler

asked 2015-03-05 02:30:17 -0500

Porti77 gravatar image

I have this code but not catkin make.

#include "ros/ros.h"
#include "std_msgs/String.h"
#include "tf/transform_datatypes.h"

void chatterCallback(const nav_msgs::Odometry::ConstPtr& msg)
{
    tf::Quaternion q= msg-> pose.pose.orientation();
}
int main(int argc, char **argv)
{
    tf::Matrix3x3 m(q);
    double roll, pitch, yaw;
    m.getRPY(roll, pitch, yaw);
    std::cout << "Roll: " << roll << ", Pitch: " << pitch << ", Yaw: " << yaw << std::endl;
  ros::init(argc, argv, "quaternionToEuler");

  ros::NodeHandle n;

  ros::Subscriber sub = n.subscribe("odometry/filtered", 1000, chatterCallback);

  ros::spin();

  return 0;
}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

answered 2015-03-05 03:06:40 -0500

ahendrix gravatar image
  • If you have a compiler error, it's usually a good idea to include the compiler error in your question
  • You should probably put your code for converting a quaternion to euler angles in your callback
  • This is a VERY newbie C++ mistake. Go get a C++ textbook and read about variable scope
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-05 02:30:17 -0500

Seen: 3,121 times

Last updated: Mar 05 '15