ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to get pitch and yaw angle from the raw IMU data?

asked 2013-07-25 14:35:51 -0500

Astronaut gravatar image

updated 2013-07-25 14:36:19 -0500

Hello

Im using the IMU data for some orientation platform purpose. Im able to use the IMU in a ROS massagesses in the Callback like these

void imuCallback(const sensor_msgs::ImuConstPtr& msg)
{
  tf::quaternionMsgToTF(msg->orientation, quat);
  tf::Matrix3x3(quat).getRPY(r,p,y);

But I would like to check when for example some turn of the platforms occur if its exactly by that yaw and pitch.

For example I wonted to record the start time when my platform is start going up/down the ramp , like this condition

if(fabs(p-initial_pitch) >= ramp_ang)
    {
        ramp_pitch = fabs(p-initial_pitch)*57.3;    

    }

So I wont to check the IMU data if that is ok.

Any help? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-07-25 15:20:54 -0500

MD_MD gravatar image

I am not sure I completely understand your question, but I don't think this will work if you want to check if there was a change by any exact amount. If you look at the IMU data you are streaming right now you will almost certainly see some noise even when the IMU is motionless. As a consequence you are unlikely to ever find that the orientation is exactly some angle; you would have to check that the angle was between some range.

edit flag offensive delete link more

Comments

Ok. And how to check that the angle was between some range? I wont to check when my platform go up the ramp ( at some pitch angle let we say 3 deg) really occurs at that pitch (more less). Is it more clear now?

Astronaut gravatar image Astronaut  ( 2013-07-25 15:30:18 -0500 )edit

I would do something like if(pitch>2.5 && pitch<3.5){ do_something; }

MD_MD gravatar image MD_MD  ( 2013-07-25 16:42:36 -0500 )edit

No. I dont wont to change the code. I just wont to plot my pitch angle getting from IMU data.

Astronaut gravatar image Astronaut  ( 2013-07-25 16:52:00 -0500 )edit
1

You wil have to change your code in some way if you want it to behave differently. If you are asking about how to get the data from the IMU I would use an IMU filter like imu_filter_madgwick which will calculate the orientation for you.

MD_MD gravatar image MD_MD  ( 2013-07-25 17:14:39 -0500 )edit

Ok. But can I get the orientation without IMU filter like imu_filter_madgwick? I mean using the orientation data like x: 0.00555401947349 y: 0.00845728162676 z: 0.4551037848 w: 0.89038091898 Is it possible?

Astronaut gravatar image Astronaut  ( 2013-07-25 17:29:23 -0500 )edit

Yes, but for the most part IMUs don't give you the orientation directly. They give information like acceleration and momentum which you then have to process into orientation. You would have to subscribe to the topic /imu_data or /imu_data_raw and use that.

MD_MD gravatar image MD_MD  ( 2013-07-25 17:35:09 -0500 )edit

I already subscribe. So with tf::quaternionMsgToTF(msg->orientation, quat); tf::Matrix3x3(quat).getRPY(r,p,y); Im able to get the roll , pitch and yaw. But Dont know how to use the orientation raw IMU data. Understand?So how to get the pitch and yzw from the raw IMU orientation x,y,z and w?

Astronaut gravatar image Astronaut  ( 2013-07-25 17:43:27 -0500 )edit

I see what you mean now. I don't know how to do those calculations myself, I use the IMU filter I previously mentioned to do that for me. If you insist on not using that package you could look at their source code and implement what they did in your own node.

MD_MD gravatar image MD_MD  ( 2013-07-25 17:46:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-07-25 14:35:51 -0500

Seen: 2,546 times

Last updated: Jul 25 '13