Ask Your Question
0

IMU Message Error

asked 2016-03-27 05:27:16 -0500

MarkyMark2012 gravatar image

Hi All,

I thought I would try and generate and IMU message for the gyro that's on my robot to feed into the laser_scan_matcher (To be honest as it's quite slow to update I'm not sure if it'll be of much use).

Anyway the LSM is complaining with an error "MSG to TF: Quaternion Not Properly Normalized" so I guess I have message the message up.

The gyro only measures rotation so that end I have set the co-matrix's zeroth element to -1 for the angular_velocity_covariance and linear_acceleration_covarianc parts. (as per http://docs.ros.org/api/sensor_msgs/html/msg/Imu.html)

The message I'm outputting is (338 degres):

header: 
  seq: 3734
  stamp: 
    secs: 1459073468
    nsecs: 76810552
  frame_id: imu_msg
orientation: 
  x: 5.89921283722
  y: 0.0
  z: 0.0
  w: 0.0
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
angular_velocity: 
  x: 0.0
  y: 0.0
  z: 0.0
angular_velocity_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
linear_acceleration: 
 x: 0.0
 y: 0.0
 z: 0.0
linear_acceleration_covariance: [-1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---

What do I need to correct?

Many thanks

Mark

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2016-03-27 06:51:05 -0500

NEngelhard gravatar image

updated 2016-03-27 06:52:11 -0500

Your problem is that the "Quaternion [is] Not Properly Normalized". A Quaternion (your rotation) must have a norm of 1

 x**2+y**2+z**2+w**2==1

which is obviously not true for your quaternion. You can use these functions to create a valid quaternion from RPY: http://wiki.ros.org/tf/Overview/Data%...

edit flag offensive delete link more

Comments

Thanks - what do I call to get the normalized component parts back - i.e so I can set:

tf::Quaternion q  = tf::createQuaternionFromRPY(degree_to_radian(pRobotData->GyroOrientation),0, 0);

imu_msg.orientation.x = q.x;
imu_msg.orientation.y = q.y;
imu_msg.orientation.z = q.z; etc...
MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-27 11:29:58 -0500 )edit

That looks ok. What kind of robot do you have? I would have expected that you'd measure the yaw angle.

NEngelhard gravatar image NEngelhard  ( 2016-03-27 12:23:49 -0500 )edit

This was the compilation error:

rror: cannot convert ‘tf::QuadWord::x’ from type ‘const tfScalar& (tf::QuadWord::)() const {aka const double& (tf::QuadWord::)() const}’ to type ‘geometry_msgs::Quaternion_<std::allocator<void> >::_x_type {aka double}’ imu_msg.orientation.x = q.x;

MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-27 12:47:19 -0500 )edit

The imu message is defined as:

sensor_msgs::Imu imu_msg;

MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-27 12:47:36 -0500 )edit

If you read the message carefully, you could find the "aka const double& (tf::QuadWord::)() const". (Note the '()' ). q.x is a function that returns the x component, so you have to write imu_msg.orientation.x = q.x(); (Check L74 in http://docs.ros.org/jade/api/tf/html/...

NEngelhard gravatar image NEngelhard  ( 2016-03-27 14:02:00 -0500 )edit
1

Good point :) Thanks for your help!

MarkyMark2012 gravatar image MarkyMark2012  ( 2016-03-27 16:48:43 -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

1 follower

Stats

Asked: 2016-03-27 05:27:16 -0500

Seen: 1,395 times

Last updated: Mar 27 '16