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

IMU driver REP-103 and REP-145

asked 2021-05-21 10:27:23 -0500

elgarbe gravatar image

Hi, I'm working on a robot localization project. I'm using an IMU (gyro+accel) a magnetometer (HMC5883) and a GPS. I've read REP103 and REP145 in order to publish IMU's data. I'm a little confused about magnetometer. My mag is mounted with X axis forward, Y left and Z up. In this orientation I get follow measurements (southern hemisphere):

Pointing North: X = + Max, Y = 0, Z = positive

Pointing Est: X = 0, Y = +Max, Z = positive

Pointing South: X = - Max, Y = 0, Z = positive

Pointing Est: X = 0, Y = -Max, Z = positive

So, it's reporting in ENU coordinate frame, right?

Then REP103 says: "By the right hand rule, the yaw component of orientation increases as the child frame rotates counter-clockwise, and for geographic poses, yaw is zero when pointing east."

So, it seems that atan2(mag_y, mag_x) is the way to do this:

Pointing east -> atan2(+, 0) = 0 pointing north -> atan2(0, +) = 90

So, going counter clockwise (East to North) the yaw angle increase.

Is my analysis right? because I'm not getting right output from RL....

Thank

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-24 11:26:36 -0500

shonigmann gravatar image

updated 2021-05-24 13:06:33 -0500

Based on the measurements you provided, it sounds like the imu reports values in North-West-Up (NWU) - max x is north, max y is when the robot points east (so the y axis is pointing north at -90 deg, or west at 0 deg), and as confirmed by your positive measurements on the southern hemisphere, z is up.

You can use the HMC5883's datasheet to verify by looking for the "dot" on the top of the chip (assuming no firmware changes that would change the chips operation from the default): image description It should be on the bottom right corner of your robot (as you confirmed in the comments below).

Now you mentioned REP103 which specifies the ENU frame. That means you would probably have to transform your imu data from NWU to ENU somewhere in the data pipeline to match ROS's expectations for whatever localization algorithm you're using. This is an easy enough transformation:

x_enu <=> -y_nwu

y_enu <=> x_nwu

z_enu <=> z_nwu

Or if you are fond of rotation matrices,

image description

If all you want is heading and you are only reading x and y values, then you can rearrange the x and y components depending on your data's reference frame:

heading_enu = atan2(mag_y_enu, mag_x_enu) = atan2(mag_x_nwu, -mag_y_nwu)

edit flag offensive delete link more

Comments

1

I'm not sure why do you think the sensor is up-side-down ("Z would be down" you said). I'm on south hemisphere and Z measurement is positive (like earth magnetic field vector). My sensor is mounted with the "dot" (pin 1 indicator) on the back-right of the robots (looking from behind). So, X axis point forward, Y axis point left and Z axis point Up.

elgarbe gravatar image elgarbe  ( 2021-05-24 12:32:50 -0500 )edit

good catch, that's my mistake, I let myself get confused - pointing (x) East means y is pointing north and is normally west when the robot is pointing north, so the sensor is using the North-West-Up convention, not North-East-Down; I'll edit my answer accordingly.

shonigmann gravatar image shonigmann  ( 2021-05-24 12:50:59 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-05-21 10:27:23 -0500

Seen: 350 times

Last updated: May 24 '21