rviz orbit viewcontroller lookat function

asked 2015-03-03 21:37:17 -0600

2ROS0 gravatar image

updated 2015-03-03 21:52:18 -0600


I'm having trouble with the lookat function in the orbit view controller in rviz:

void OrbitViewController::lookAt( const Ogre::Vector3& point )
   Ogre::Vector3 camera_position = camera_->getPosition();
   focal_point_property_->setVector( target_scene_node_->getOrientation().Inverse() * (point - target_scene_node_->getPosition()) );
   distance_property_->setFloat( focal_point_property_->getVector().distance( camera_position )); 

From what I understand, it looks at the camera_ position, then finds the focal_point_property based on the point to lookat which is fine.

However, it then sets the distance_property_ to the distance between that focal point and the camera position and I don't get why that particular formula is picked. In my case, when I call the lookat function, the view although pointing in the right direction is sometimes zoomed way way out (>10^6). I have to keep scrolling in before I can see anything.

And so just changing distance_property_ should fix it but since it is a protected member, I don't have any way of setting it and the closest public function available is reset() which sets the focal point to 0 which is not what I want. Any ideas on how to go about it?


edit retag flag offensive close merge delete


Could you describe what you are really after? Just to make sure this isn't an X-Y problem. Are you trying to control the RViz camera viewpoint programmatically?

gvdhoorn gravatar image gvdhoorn  ( 2015-03-04 02:27:34 -0600 )edit