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

Answered my own question by looking at the code :P

No it's not possible at the moment to do this from a script/launch file, rqt_rviz initializes the RViz frame with no configuration file argument at all. However, if you're willing to modify the rqt_rviz C++ code, it's a trivial matter of adding a filename (or better yet a ros parameter) as an argument to _widget->initialize() in RViz::initPlugin. Likewise the menu bar can be removed by deleting the call to _widget->setMenuBar().

void RViz::initPlugin(qt_gui_cpp::PluginContext& context)
{
  context_ = &context;

  // prevent output of Ogre stuff to console
  Ogre::LogManager* log_manager = Ogre::LogManager::getSingletonPtr();
  if (!log_manager)
  {
    log_manager = new Ogre::LogManager();
  }
  QString filename = QString("rqt_rviz_ogre") + (context.serialNumber() > 1 ? QString::number(context.serialNumber()) : QString("")) + QString(".log");
  log_ = log_manager->createLog(filename.toStdString().c_str(), false, false);

  widget_ = new rviz::VisualizationFrame();

  // create own menu bar to disable native menu bars on Unity and Mac
  QMenuBar* menu_bar = new QMenuBar();
  menu_bar->setNativeMenuBar(false);
  widget_->setMenuBar(menu_bar);

  widget_->initialize();

  ...

Answered my own question by looking at the code :P

No it's not possible at the moment to do this from a script/launch file, rqt_rviz initializes the RViz frame with no configuration file argument at all. However, if you're willing to modify the rqt_rviz C++ code, it's a trivial matter of adding a filename (or better yet a ros parameter) as an argument to _widget->initialize() in RViz::initPlugin. Likewise the menu bar can be removed by deleting the call to _widget->setMenuBar().

void RViz::initPlugin(qt_gui_cpp::PluginContext& context)
{
  context_ = &context;

  // prevent output of Ogre stuff to console
  Ogre::LogManager* log_manager = Ogre::LogManager::getSingletonPtr();
  if (!log_manager)
  {
    log_manager = new Ogre::LogManager();
  }
  QString filename = QString("rqt_rviz_ogre") + (context.serialNumber() > 1 ? QString::number(context.serialNumber()) : QString("")) + QString(".log");
  log_ = log_manager->createLog(filename.toStdString().c_str(), false, false);

  widget_ = new rviz::VisualizationFrame();

  // create own menu bar to disable native menu bars on Unity and Mac
  QMenuBar* menu_bar = new QMenuBar();
  menu_bar->setNativeMenuBar(false);
  widget_->setMenuBar(menu_bar);

  widget_->initialize();
//widget_->setMenuBar(menu_bar);

  widget_->initialize("my_config.rviz");

  ...