Home | Tutorials | Wiki | Issues
Ask Your Question
1

How can I turn off the Space Navigator's control of the camera?

asked 2016-08-23 11:32:33 -0600

I'm using a plugin to control models with the Space Navigator (spacenav 6 DOF) 3D mouse. It works, but the controller is controlling both the object (through the spnav external library) and the camera at the same time. I'm looking for a way to turn off the camera control and just use the regular mouse for that. If necessary, it looks like i could recompile Gazebo from source after commenting out the relevant lines in gazebo/gui/CMakeLists.txt, but it would be easier to use ~/.gazebo/gui.ini, or an API call, or something.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-10-26 10:19:57 -0600

Illuminatur gravatar image

There is a much easier way: Just adapt the configuration in ~/.gazebo/gui.ini

[spacenav]
deadband_x = 0.1
deadband_y = 0.1
deadband_z = 0.1
deadband_rx = 0.1
deadband_ry = 0.1
deadband_rz = 0.1
topic=~/spacenav/remapped_joy_topic_to_something_not_used

Just change the topic to something you are going to listen in your own plugin and it will not interfere with the gui, which listens to ~/spacenav/joy

Best regards!

edit flag offensive delete link more
1

answered 2016-08-23 15:17:22 -0600

Alright, I found out how. You apparently have to create a plugin to do this; I didn't find a way to do it from the model plugin in which I use the Space Navigator. But it works if you create a visual plugin and refer to it in a <plugin> element within a <visual> element in the SDF file. Here's the plugin code I used:

#include <gazebo/gazebo.hh>
#include <gazebo/common/common.hh>
#include <gazebo/rendering/rendering.hh>

namespace gazebo
{ class MyVisualPlugin : public VisualPlugin
  { public: 
      void Load( rendering::VisualPtr _visual, sdf::ElementPtr /*_sdf*/)
      { // Turn off the SpaceNavigator's default camera control
        rendering::UserCameraPtr cam = _visual->GetScene()->GetUserCamera( 0 );
        cam->SetJoyPoseControl( false );
        cam->SetJoyTwistControl( false );
      }
  };

  // Register this plugin with the simulator
  GZ_REGISTER_VISUAL_PLUGIN( MyVisualPlugin )
};
edit flag offensive delete link more

Comments

+1 for the workaround. I feel like there should be an easier way of doing this, either through SDF or the GUI.

chapulina gravatar imagechapulina ( 2016-08-23 15:21:44 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-23 11:32:33 -0600

Seen: 953 times

Last updated: Oct 26 '16