Laser rotates with odom

asked 2019-02-12 04:58:06 -0500

stevemartin gravatar image

I can't figure out this strange thing that I am getting with TF.

I am using a different localization to AMCL and that localization publishes Map to Base TF. If I will use that and make a seperate TF from Map to Odom with this kind of TF tree:

image description I get this good TF where laser beams do not move with the robot (fixed frame: Laser):

LINK to video

Now when I disable the Map to Base TF and write my own TF from Map to Odom using the TF provided by the localizer (which again is Map to Base):

(msg is the TransformStamped message of TF between Map and Base):

tf2::Transform tf_map_odom;

    tf_map_odom.setOrigin(tf2::Vector3(
        msg->transform.translation.x,
        msg->transform.translation.y, 0));

    tf2::Quaternion q(msg->transform.rotation.x,
        msg->transform.rotation.y,
        msg->transform.rotation.z,
        msg->transform.rotation.w);

    //tf::quaternionMsgToTF(this->_odom.pose.pose.orientation, qq);
    tf2::Quaternion qq(this->_odom.pose.pose.orientation.x,
        _odom.pose.pose.orientation.y,
        _odom.pose.pose.orientation.z,
        _odom.pose.pose.orientation.w);
    q = q * qq.inverse();

    tf_map_odom.setRotation(q);

    //const tf2::Stamped<tf2::Transform> tf_stamped_map_odom(tf_map_odom, msg->header.stamp, "map");

    //this->_map_to_odom = toMsg(tf_stamped_map_odom);

    this->_map_to_odom.header.stamp = msg->header.stamp;
    this->_map_to_odom.header.frame_id = "map";
    this->_map_to_odom.child_frame_id = "odom";
    this->_map_to_odom.transform.translation.x = tf_map_odom.getOrigin().getX();
    this->_map_to_odom.transform.translation.y = tf_map_odom.getOrigin().getY();
    this->_map_to_odom.transform.translation.z = tf_map_odom.getOrigin().getZ();

    this->_map_to_odom.transform.rotation.x = tf_map_odom.getRotation().getX();
    this->_map_to_odom.transform.rotation.y = tf_map_odom.getRotation().getY();
    this->_map_to_odom.transform.rotation.z = tf_map_odom.getRotation().getZ();
    this->_map_to_odom.transform.rotation.w = tf_map_odom.getRotation().getW();


    _tfb.sendTransform(this->_map_to_odom);

I get this behaviour (where Laser beams move together with Robot):

LINK to the video

and this TF:

image description

What am I doing wrong?

edit retag flag offensive close merge delete

Comments

Could i be the laser data not updating frequently enough? The second tree is not correct as the base link frame should be a child to odom.

basb1 gravatar image basb1  ( 2019-02-12 07:28:27 -0500 )edit

@stevemartin as you are very active right now and seem to have one specific problem with your setup, could be please explain how the following (unanswered) questions by you relate to each other? They seem all be about (roughly) the same topic...

The respective questions are:

mgruhler gravatar image mgruhler  ( 2019-02-12 09:07:29 -0500 )edit
mgruhler gravatar image mgruhler  ( 2019-02-12 09:09:07 -0500 )edit

@mgruhler Why do you think so? I am asking as more information is coming through

stevemartin gravatar image stevemartin  ( 2019-02-12 10:02:31 -0500 )edit

@basb1 I do not think that is a case. If that would have been a case, the second tree (which is incorrect) would not work and laser beams will also rotate

stevemartin gravatar image stevemartin  ( 2019-02-12 10:04:20 -0500 )edit

@stevemartin well, this question and #q315067 seem to be related to the same problem, if they are not even exact duplicates. About your (now edited) comment "why do I even have to explain anything to you": you are asking for help, people try to help you, they are asking questions. So that is why :)

mgruhler gravatar image mgruhler  ( 2019-02-13 01:02:41 -0500 )edit
1

Trying to piece together the pieces of a puzzle helps in really figuring out, what your problem is. If you don't bother answering those questions, I'm not sure how fast you are going to get an answer, if at all.

Maybe have again a look at the Support Guidelines.

mgruhler gravatar image mgruhler  ( 2019-02-13 01:05:12 -0500 )edit

@mgruhler Oh sorry, English is not my first language and I have edited because I figured out that it sound a bit rude but in my language we can actually say that

stevemartin gravatar image stevemartin  ( 2019-02-13 02:01:26 -0500 )edit