ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ROS librviz库

2022-06-25 17:37:15  阅读:173  来源: 互联网

标签:librviz rviz pointCloud2 subProp manager setValue ROS name


1、可视化管理类:rviz::VisualizationManager

  The VisualizationManager class is the central manager class of rviz, holding all the Displays, Tools, ViewControllers, and other managers.

  It keeps the current view controller for the main render window. It has a timer which calls update() on all the displays. It creates and holds pointers to the other manager objects: SelectionManager, FrameManager, the PropertyManager s, and Ogre::SceneManager.

  /**
   * \brief Constructor
   * Creates managers and sets up global properties.
   * @param render_panel a pointer to the main render panel widget of the app.
   * @param wm a pointer to the window manager (which is really just a
   *        VisualizationFrame, the top-level container widget of rviz).
   */
  explicit VisualizationManager(RenderPanel* render_panel, WindowManagerInterface* wm = nullptr);

  在使用librviz时一般需要创建一个VisualizationManager对象,创建时给它指定渲染窗口RenderPanel,如下为在一个Qt运用的主窗口中嵌入librviz渲染窗口的示例:

// 创建渲染窗口,并将其添加到Qt主窗口布局中

render_panel_ = new rviz::RenderPanel();
QVBoxLayout* main_layout = new QVBoxLayout;
main_layout->addLayout( controls_layout );
main_layout->addWidget( render_panel_ );
setLayout( main_layout );

// 创建可视化管理对象

manager_ = new rviz::VisualizationManager( render_panel_ );

// 为渲染窗口关联场景相机及渲染上下文
render_panel_->initialize( manager_->getSceneManager(), manager_ );

// 初始化操作(必须,)
manager_->initialize();

// 启动刷新定时器,定时刷新librviz中的显示窗口
manager_->startUpdate();

  用于管理Display的接口,Display就是rviz中左侧面板中可以显示的网格、坐标轴、话题等可视化元素

  // 用于管理Display的接口,Display就是rviz中左侧面板中可以显示的网格、坐标轴、话题等可视化元素
  /**
   * \brief Create and add a display to this panel, by class lookup name
   * @param class_lookup_name "lookup name" of the Display subclass, for pluginlib.
   *        Should be of the form "packagename/displaynameofclass", like "rviz/Image".
   * @param name The name of this display instance shown on the GUI, like "Left arm camera".
   * @param enabled Whether to start enabled
   * @return A pointer to the new display.
   */
  Display* createDisplay(const QString& class_lookup_name, const QString& name, bool enabled);

  /**
   * \brief Add a display to be managed by this panel
   * @param display The display to be added
   */
  void addDisplay(Display* display, bool enabled);

  /**
   * \brief Remove and delete all displays
   */
  void removeAllDisplays();

  示例:添加点云话题显示

m_pointCloud2 = m_rvizManager->createDisplay("rviz/PointCloud2","pointCloud2", true);
ROS_ASSERT(m_pointCloud2 != nullptr);
m_pointCloud2->subProp("Topic")->setValue("/pcd_points");
m_pointCloud2->subProp("Unreliable")->setValue("false");
m_pointCloud2->subProp("Selectable")->setValue("true");
m_pointCloud2->subProp("Style")->setValue("Flat Squares");
m_pointCloud2->subProp("Size (m)")->setValue("0.1");
m_pointCloud2->subProp("Alpha")->setValue("1");
m_pointCloud2->subProp("Decay Time")->setValue("0");
m_pointCloud2->subProp("Position Transformer")->setValue("XYZ");//
m_pointCloud2->subProp("Color Transformer")->setValue("Intensity");
m_pointCloud2->subProp("Queue Size")->setValue("10");
m_pointCloud2->subProp("Use rainbow")->setValue("true");
m_pointCloud2->subProp("Invert Rainbow")->setValue("false");
m_pointCloud2->subProp("Autocompute Intensity Bounds")->setValue("true");
// m_pointCloud2->subProp("Min Intensity")->setValue("1");
// m_pointCloud2->subProp("Max Intensity")->setValue("255");
m_rvizManager->setFixedFrame("hx_map");

  rviz/PointCloud2是rviz提供的默认插件,其所有的属性设置均显示在左侧面板:

  参考坐标系设置获取接口:

  /** @brief Return the fixed frame name.
   * @sa setFixedFrame() */
  QString getFixedFrame() const override;

  /** @brief Set the coordinate frame we should be transforming all fixed data into.
   * @param frame The name of the frame -- must match the frame name broadcast to libTF
   * @sa getFixedFrame() */
  void setFixedFrame(const QString& frame);

  rviz配置保存与加载

  /** @brief Load the properties of each Display and most editable rviz data.
   *
   * This is what is called when loading a "*.rviz" file.
   *
   * @param config The Config object to read from.  Expected to be a Config::Map type.
   * @sa save()
   */
  void load(const Config& config);

  /**
   * \brief Save the properties of each Display and most editable rviz
   *        data.
   *
   * This is what is called when saving a "*.vcg" file.
   * \param config The object to write to.
   * \sa loadDisplayConfig()
   */
  void save(Config config) const;

  还有其他接口暂未用到,具体可查看头文件:rviz/visualization_manager.h

 

 

 

标签:librviz,rviz,pointCloud2,subProp,manager,setValue,ROS,name
来源: https://www.cnblogs.com/djh5520/p/16392410.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有