ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi @jotwe,
I know this is a late response but I was developing a custom rviz plugin and I came up with the very same problem you face in your question.
After some research I discover several things that may help anyone that encounter this problem. So here we go:
When you use the setPosition(...)
function of the Ogre::Camera
object returned with controller_->getCamera()
the position information of the Camera instance does change, however the problem here is that the ViewController
of Rviz override this information when calling the update method of ViewController
object, that can be found here and must be override for any Child Class implementing a View... like Orbit, FPS etc. So, the explanation is simply that, Ogre::Camera
is changed but restore by the ViewController
whose View properties remain intact (Distance, Position X, Position Y, etc.).
Thus, in order to programatically change the camera postion and direction there is something you can do: Since most of the update()
method takes first the position of the Ogre::Camera
with camera_->getCameraPosition()
what can be done is just calling the set setPosition(...)
method from Ogre::Camera
and then the lookAt(...)
method from the controller_
. Whit that, the update method will get the stablished position changing the camera pose and then the controller will use the lookAt(...)
method to change its direction.
Like this:
Extracted from a plugin that heritage from a rviz panel. vis_manager_
is VisualizationManager
object.
vis_manager_->getViewManager()->getCurrent()->getCamera()->setPosition(x_pos, y_pos, z_pos);
vis_manager_->getViewManager()->getCurrent()->lookAt(x_look, y_look, z_look);
Hope that helps, Cheers.