Ask Your Question
0

Getting an error that my tf has been ignored

asked 2019-01-09 03:44:59 -0500

stevemartin gravatar image

I have Bosch BN055 9-axis accelerometer and I have installed this package to integrate with ROS: LINK

However, when I run the whole launch file with odometry (odometry gets the IMU values from /imu topic, will put the code at the end), I get this error:

Error:   TF_DENORMALIZED_QUATERNION: Ignoring transform for child_frame_id "base_footprint" from authority "unknown_publisher" because of an invalid quaternion in the transform (0.000000 0.000000 0.008824 -0.994081)

And here is the code where odometry gets the IMU orientation values (callback function):

void Odometry::ImuCb(const sensor_msgs::Imu::ConstPtr& data)
{
    orient_z = data->orientation.z;
    orient_w = data->orientation.w;

}

And here where it puts into tf message:

geometry_msgs::Quaternion odom_quat ;



    odom_quat.x = 0.0;
    odom_quat.y = 0.0;
    odom_quat.z = 0.0;

    odom_quat.z = this->orient_z;
    odom_quat.w = this->orient_w;

    geometry_msgs::TransformStamped odom_trans;
    odom_trans.header.stamp = now;
    odom_trans.header.frame_id = "odom";
    odom_trans.child_frame_id = "base_footprint";

        odom_trans.transform.translation.x = x_final;
        odom_trans.transform.translation.y = y_final;
        odom_trans.transform.translation.z = 0.0;
        odom_trans.transform.rotation = odom_quat;

        odom_broadcaster.sendTransform(odom_trans);
edit retag flag offensive close merge delete

Comments

The magnitude of the quaternion should be one for it to be valid, the magnitude of the one shown is 0.9882748975, hence it is not valid.

jayess gravatar imagejayess ( 2019-01-09 03:57:41 -0500 )edit

@jayess Can it be -1?

stevemartin gravatar imagestevemartin ( 2019-01-09 04:01:40 -0500 )edit

It's part of the definition of a quaternion. Please see the quaternion tutorial on the wiki. Magnitudes are not negative, so, no it should not be -1

jayess gravatar imagejayess ( 2019-01-09 04:02:53 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-01-09 05:04:22 -0500

Quaternions are 4 element unit vectors, for some reason the code you've shown is only copying two of those four elements. Hence why the magnitude is smaller than it should be.

If you update the code so it copies all the elements of the quaternion (x y z and w) to the transform then hopefully this should fix your problem.

Let us know how you get on.

edit flag offensive delete link more

Comments

Yes, I figured this out and the problem disappeared :) Can you also look at my newest question? LINK

stevemartin gravatar imagestevemartin ( 2019-01-09 05:13:07 -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

2 followers

Stats

Asked: 2019-01-09 03:44:59 -0500

Seen: 82 times

Last updated: Jan 09