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

Revision history [back]

click to hide/show revision 1
initial version

It works now!!. I was visualizing it wrongly. The trick is to take the rotation coefficients and convert it into quaternions, which is what RVIZ understands.

Here is the modified code snippet which does that:

        tf::Vector3 axis_vector(coefficients->values[3], coefficients->values[4], coefficients->values[5]);
        tf::Vector3 up_vector(1.0, 0.0, 0.0);
        tf::Vector3 right_vector = axis_vector.cross(up_vector);//
        right_vector.normalized();//
        tf::Quaternion q(right_vector, -1.0*acos(axis_vector.dot(up_vector)));//
        q.normalize();//
        geometry_msgs::Quaternion line_orientation;
        tf::quaternionTFToMsg(q, line_orientation);

Screenshot from 2015-03-05 13:09:42.png Screenshot from 2015-03-05 13:09:48.png