Robotics StackExchange | Archived questions

rviz orbit viewcontroller lookat function

Hi,

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 )); 
   calculatePitchYawFromPosition(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?

Thanks!

Asked by 2ROS0 on 2015-03-03 22:37:17 UTC

Comments

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?

Asked by gvdhoorn on 2015-03-04 03:27:34 UTC

Answers