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

How to rotate a triangle to a given pose orientation

asked 2013-08-20 07:54:53 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have a pose and using the pose's position information(x,y) i generate a triangle(p1,p2,p3) where p1 is the actual pose's position. Initially i assumed the direction. Example: If p1(x,y) = (6,12) I generate P2(x,y) = (2, 16) and p3(x,y) = (10, 16). SO by default two new points to the left and right of the given pose's position.

Further i want to rotate this triangle to the pose's orientation. I am struck at this point... I am not getting how to rotate this triangle according to pose's orientation.

Any idea how to achieve this ? Basically i want to generate a view cone for a given Pose.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-21 06:49:58 -0500

hersh gravatar image

From email, I believe kk is asking this in the context of writing an RViz plugin.

If so, the answer is that you almost never need to do this. RViz uses the Ogre3D rendering library. In Ogre, everything visible is attached to an Ogre::SceneNode. SceneNodes have parents and children and form a tree. Every SceneNode has a transform relative to its parent. The transform encodes 3D position and rotation.

Therefore, when you make an Ogre::ManualObject (for instance) with a list of vertices, triangles, etc, you can put all those coordinates in a local coordinate frame. For instance, the point of your cone could be at (0,0,0) and the other corners could be at (-1, -1, 1), (-1, 1, 1), (1, 1, 1), and (1, -1, 1).

Then when you attach it to a given SceneNode, you can just set the position and orientation of the SceneNode, and that will cause the cone to be set to the pose you gave.

If you want to have a bunch of cones in different poses, but you only have a single SceneNode, you need to create child SceneNodes and then attach each cone to a single child SceneNode.

Note that SceneNode transforms are applied at each level in the tree, so if your top-level node sets a pose and your child nodes also set poses, the children will all be posed relative to the parent, not relative to the world coordinate frame.

Now, just in case this does not cover the intent of your original question, I will say that I often use this header file in the TF package: http://ros.org/doc/groovy/api/tf/html/c++/transform__datatypes_8h.html. That has a bunch of convenience functions to convert between TF data types and ros message data types. It also has the excellent tf::createQuaternionFromRPY() function, if you have roll-pitch-yaw orientation information.

The TF package has a bunch of other good stuff in it, like the tf::Transform class, which you can multiply by a tf::Vector3 instance to change coordinate frames for the vector. (Which includes rotating it).

Hope this helps.

(If the original question is really about doing this in RViz, please update the title to reflect that.)

edit flag offensive delete link more

Comments

hersh thank you for the suggestion. I want two things: Visualization and also collision detection. So along with cone visualization i need to know the exact cone points to perform collision check. From the source code and your suggestions i understand Ogre3D -continued next comment

kk gravatar image kk  ( 2013-08-21 07:25:42 -0500 )edit

Ogre 3d deals all rotations. But for collision detection i need to know the cone points, so need to manually find out the points. So should construct a cone or atleast a triangle from the given pose and orientation. So how to find the triangle points based on a given point and orientation ?

kk gravatar image kk  ( 2013-08-21 07:29:20 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-08-20 07:54:53 -0500

Seen: 1,667 times

Last updated: Aug 21 '13