Ask Your Question

how to transform local position to global?

asked 2016-03-03 12:56:18 -0600

Knowledge gravatar image

I want to create to nodes and make them communicate on the same topic of type position,

This tutorial helped me how to create two nodes and make them communicate on a topic. Using turtlesim i can detect the turtle position but how can i convert that position from local to global reference frame? The tutorial only shows how to make nodes and topics and use turtlesim_node as first node and turtle_teleop_key as other, turtle1/pose as the topic, but i can't get how this node can convert the coordinates that is x,y and theta and change them into global reference frame?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-20 00:46:31 -0600

sunpochin gravatar image

page 17: Rotation, Translation The matrix of rotation and then translation is often used so it may be worth to remember it.

the codes will look like this:

    double rotatedX = ptLocal.x * cos(ThetaRadian) 
      - ptLocal.y * sin(ThetaRadian);
    double rotatedY = ptLocal.x * sin(ThetaRadian) 
      + ptLocal.y * cos(ThetaRadian);

    rotate_translate_x = rotatedX
        + info_.GetGlobalPose2D().x;
    rotate_translate_y = rotatedY
        + info_.GetGlobalPose2D().y;
edit flag offensive delete link more

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


Asked: 2016-03-03 12:56:18 -0600

Seen: 1,075 times

Last updated: Mar 03 '16