# Zeroing Out Orientation and Linear Acceleration of IMU

Hi, I am trying to figure out how to zero out the orientation and linear acceleration of my IMU, so that when I launch it, the x and y values begin at 0, rather than at some value like orientation of 0.126.

Anything would help, but my code for using my IMU is here for reference: https://github.com/brianzhan/husky_ro...

Below is a sample of the message when I launch my um6.launch script, where orientation and linear acceleration don't begin at 0. It is necessary for me get it to 0 to fuse it with my wheel odometry data and other tasks:

header:
seq: 456
stamp:
secs: 1463184035
nsecs: 667352940
orientation:
x: 0.0279296576
y: 0.1263548452
z: -0.9905964737
w: 0.0441436295
orientation_covariance: [0.01596195437014103, -0.0012914746766909957, -0.0005610909429378808, -0.0012914201943203807, 0.012185076251626015, 0.00017108242900576442, -0.0005610864027403295, 0.0001710832875687629, 0.011863413266837597]
angular_velocity:
x: 0.00319579559884
y: -0.00106526519961
z: -0.00106526519961
angular_velocity_covariance: [2.5e-05, 0.0, 0.0, 0.0, 2.5e-05, 0.0, 0.0, 0.0, 2.5e-05]
linear_acceleration:
x: -0.03952058
y: 0.4311336
z: -10.28073997
linear_acceleration_covariance: [0.0036, 0.0, 0.0, 0.0, 0.0036, 0.0, 0.0, 0.0, 0.0036]

edit retag close merge delete

Sort by ยป oldest newest most voted

I also faced this problem as IMU always gives non-zero values for angular velocity (and hence orientation) and linear acceleration even when it is not moving. I didn't find any built-in filter inside ros which could do this task of zeroing out the values when it is stationary. So, I ended up building my own simple filter in which I zero-ed out the values based on a threshold value. This threshold value was found through manual observations on imu.

more

Thanks a lot! May I ask, what you changed to zero out the values? I'm not sure what part of the code to alter

( 2016-05-15 20:54:44 -0500 )edit

Find out the part of your code where it is publishing the imu message, and put a condition there that if the x,y,z value is less than 'threshold', then put zero values in the imu message instead of the original values.

( 2016-05-16 02:34:31 -0500 )edit

I used rtimulib for my imu so I put this condition in the while loop which you can find at the end of this file https://github.com/romainreignier/rti...

( 2016-05-16 02:35:09 -0500 )edit

Thank you so much!

( 2016-05-17 01:35:43 -0500 )edit

I actually couldn't figure out where/how the while or if condition there checks for threshold of zeros values in the code you linked?

( 2016-05-17 01:48:39 -0500 )edit

The link I provided contains the original code. I put an If condition inside the while loop just before the line imu_pub.publish(imu_msg). Following is the If condition.

( 2016-05-17 03:07:41 -0500 )edit

If (imu_msg.angular_velocity.z <= 0.009) { imu_msg.angular_velocity.x = 0; imu_msg.angular_velocity.y = 0; imu_msg.angular_velocity.z = 0; imu_msg.linear_acceleration.x = 0; imu_msg.linear_acceleration.y = 0; imu_msg.linear_acceleration.z = 0; }

( 2016-05-17 03:09:19 -0500 )edit

Got it, thank you so much for the help!

( 2016-05-17 15:17:53 -0500 )edit