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

And if I use their package. How to do that? How did you used the IMU filter? Cause the documentation is not so good.

Astronaut gravatar image Astronaut  ( 2013-07-25 17:50:20 -0500 )edit

Follow the instructions on the imu_tools page to install and once you have done that rosrun imu_tools imu_filter_madgwick after your have started your IMU. It will publish a topic called /imu/data and this will contain orientation.

MD_MD gravatar image MD_MD  ( 2013-07-25 18:09:19 -0500 )edit

Strange . I installed and compile it with rosmake imu_tools. When I tried to rosrun imu_tools imu_filter_madgwick i got error massage stack/package imu_tools not found. Whats wrong??

Astronaut gravatar image Astronaut  ( 2013-07-25 18:29:27 -0500 )edit

rosmake imu_tools works good and compiled without errors. I have this. Built 54 packages with 0 failures. So why rosrun imu_tools imu_filter_madgwick is not working?

Astronaut gravatar image Astronaut  ( 2013-07-25 18:34:22 -0500 )edit

I misremembered the name of the node, although it is in thier documentation if you look. It should be rosrun imu_filter_madgwick imu_filter_node. Let us know if that worked.

MD_MD gravatar image MD_MD  ( 2013-07-25 18:44:35 -0500 )edit

Ok. Now its works. But strange. I got this massage INFO] [1374818078.308309568]: Starting ImuFilter [ INFO] [1374818078.313142482]: Using dt computed from message headers [ INFO] [1374818078.313186901]: Imu filter gain set to 0.100000 [ INFO] [1374818078.313201876]: Gyro drift bias set to 0.000000

Astronaut gravatar image Astronaut  ( 2013-07-25 19:55:34 -0500 )edit

Whats wrong?

Astronaut gravatar image Astronaut  ( 2013-07-25 19:55:47 -0500 )edit

I don't see anything wrong, those message are normal. Did you try rostopic echo /imu/data? That should show you calculated orientations form the /imu/data_raw channel. You can use the orientations there to get pitch/yaw/roll.

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

I tried.. Not working ..I got rostopic echo /imu/data WARNING: no messages received and simulated time is active. Is /clock being published?

Astronaut gravatar image Astronaut  ( 2013-07-25 20:56:17 -0500 )edit

Do I need to remap??Cause my Im topic in bag file is called /raw_imu_throttle

Astronaut gravatar image Astronaut  ( 2013-07-25 20:57:25 -0500 )edit

I am not familiar with the /raw_imu_throttle topic or its message, so I can't say if it will work for you to remap it. I thought you were working from a "regular" imu that published /imu/data_raw. It might work if you remap the topic you have to /imu/data_raw, but I'm not sure

MD_MD gravatar image MD_MD  ( 2013-07-25 21:06:35 -0500 )edit

I tried to remap but not working

Astronaut gravatar image Astronaut  ( 2013-07-25 21:27:34 -0500 )edit

Straight remapping may not work if the message formats are different. I am not sure how to help you beyond this because I am not familiar with /raw_imu_throttle messages.

MD_MD gravatar image MD_MD  ( 2013-07-26 02:57:10 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 2,551 times

Last updated: Jul 25 '13