Ask Your Question

How to cancel out roll and pitch in IMU?

asked 2019-01-21 07:14:20 -0500

stevemartin gravatar image

updated 2019-01-21 07:14:57 -0500

I bought a quite decent IMU called Bosch BN055. It is a 9-DOF IMU. The thing is, I have a differential drive robot and runs on a flat surface, which means I do not need roll and pitch, only YAW.

I am using robot_localization to fuse odometry vx,vy and IMU roll, pitch and yaw. My robot sometimes creates a vibration which causes my IMU to drift and making my robot to spin and roll.

I have tried to fuse robot_localization with only YAW values but after some time, ROS will throw an error stating that the combined quaternion value should equal to 1 and I get it, as I making roll and pitch to be 0, when IMU thinks it has been rotated in those directions, the YAW values become different.

How can I cope with that?

edit retag flag offensive close merge delete


do you convert yaw in quarternian by yourself or using tf?(if you convert by yourself can you share your code)

Hamid Didari gravatar image Hamid Didari  ( 2019-01-21 07:42:42 -0500 )edit

@hamid I am using library which you can find here: LINK

stevemartin gravatar image stevemartin  ( 2019-01-21 07:56:08 -0500 )edit

that code doesn't convert eurl angle to quarternian if i realize correctly you set imu_msg.orientation.x and imu_msg.orientation.y to zero and publish the msg?am i right?

Hamid Didari gravatar image Hamid Didari  ( 2019-01-21 08:09:12 -0500 )edit

@hamid the libary publishes imu msg to /imu. Yes, I did that before but after sometime that will give me an error as quaternion should add up to 1

stevemartin gravatar image stevemartin  ( 2019-01-21 08:50:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-21 09:00:20 -0500

Hamid Didari gravatar image

updated 2019-01-21 09:08:28 -0500

if you want to use only yaw , first you have to convert quarternian to eurl angle and then convert yaw in quarternian then publish msg . you can use something like this code:

  float yaw;
  tf::Quaternion robot_imu;
  yaw_ = tf::getYaw(robot_imu);
  tf::Quaternion yaw(tf::createQuaternionFromYaw(yaw_));

you can't simply set x and y to zero.

edit flag offensive delete link more


@hamid okay that makes sense, so in yaw format, I would just cancel out roll and pitch and keep only way and convert back to Q

stevemartin gravatar image stevemartin  ( 2019-01-22 03:54:59 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2019-01-21 07:14:20 -0500

Seen: 172 times

Last updated: Jan 21 '19