ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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.)