ROS工具 —— rviz

1. 发送单个基本形状(cube, sphere, cylinder, arrow and so on)

http://wiki.ros.org/rviz/Tutorials/Markers%3A%20Basic%20Shapes
使用 visualization_msgs/Marker 这个msg向rviz发送物体对象。
上面链接中的代码主要实现了每分钟向rviz发送一个不同形状的物体,并销毁上一个物体。

2. 发送形状的集合(Points, Line Strips, and Line Lists)

使用visualization_msgs/Marker的成员:points
共有三种类型:1. The POINTS type places a point at each point added. 2. The LINE_STRIP type uses each point as a vertex in a connected set of lines, where point 0 is connected to point 1, 1 to 2, 2 to 3, etc. 3. The LINE_LIST type creates unconnected lines out of each pair of points, i.e. point 0 to 1, 2 to 3, etc.

3. 可交互的物体

这些物体允许用户改变它的位置,姿态,点击他们或者将menu中的属性绑定到每个物体上。
他们通过 visualization_msgs/InteractiveMarker message发给rviz。包括一个menu context和一些controller。
这些controls 定义了交互物体可视化的不同部分, 会包含一些规则的基本形状 (visualization_msgs/Marker) 并且包含不同的功能。
为了实现交互的物体,我们需要实例化InteractiveMarkerServer对象,由这个对象负责与rviz进行交互。
在这里插入图片描述
包括五种:simple_marker, basic_controls, menu, pong and cube.

4. Writing a Simple Interactive Marker Server

这里以simple_marker为例进行介绍:

http://wiki.ros.org/rviz/Tutorials/Interactive%20Markers%3A%20Writing%20a%20Simple%20Interactive%20Marker%20Server

//首先创建一个server作为与rviz的交互接口:
interactive_markers::InteractiveMarkerServer server("simple_marker");
// create an interactive marker for our server
visualization_msgs::InteractiveMarker int_marker;
// create a grey box marker
visualization_msgs::Marker box_marker;
// create a non-interactive control which contains the box
visualization_msgs::InteractiveMarkerControl box_control;
// add the control to the interactive marker
int_marker.controls.push_back( box_control );
server.insert(int_marker, &processFeedback);//processFeedback回调函数
// 'commit' changes and send to all clients
server.applyChanges();

// start the ROS main loop
ros::spin();

在这里插入图片描述

5. basic_controls

http://wiki.ros.org/rviz/Tutorials/Interactive%20Markers%3A%20Basic%20Controls
在这里插入图片描述
在这个例子中,也说明了六自由度物体的实现
在这里插入图片描述

6. Plugin_imu sample

tutorial link : http://docs.ros.org/en/kinetic/api/rviz_plugin_tutorials/html/display_plugin_tutorial.html

6.1. 代码实现

这个功能的实现主要包括以下几个文件:

src/imu_display.h
src/imu_display.cpp
src/imu_visual.h
and src/imu_visual.cpp

6.1.1. imu_display.h

每一个需要在panel中显示的插件都需要继承rviz::Display类,在这里我们定义一个ImuDisplay类来继承。
在ImuDisplay中只实现circular buffer, 可编辑的参数, 和显示子类machinery. 关于显示的相关内容定义在ImuVisual类中。
显示的思想是:当obj存在时显示在界面上,当obj不存在时从界面上抹除。

6.1.2. imu_display.cpp

6.1.3. imu_visual.h

这个文件 的内容是用来定义显示的,显示的每一帧都是对一帧sensor_msgs::Imu message的实现。

6.1.4. imu_visual.cpp

6.2. 编译自定义插件

执行命令rosmake rviz_plugin_tutorials

6.3. 导出插件

想要插件被ros包找到,它必须包含一个“plugin_description.xml” 。

6.4. 使用

将上面的包包含在ros package中,编译并导出之后,我们就可以在rviz中使用它。

rosrun rviz rviz

在这里插入图片描述

7. Plugins: New Dockable Panel

以TeleopPanel为例
A panel in RViz is a GUI widget which can be docked in the main window or floating. It does not show properties in the “Displays” panel like a Display, but it could show things in the 3D scene.
在这里插入图片描述
所有关于panel的子类继承于rviz::Panel
这个例子共包含下面四个文件:src/teleop_panel.h, src/teleop_panel.cpp, src/drive_widget.h, and src/drive_widget.cpp.

src/teleop_panel.h, src/teleop_panel.cpp的作用如下:

  1. Act as a container for GUI elements DriveWidget and QLineEdit.
  2. Publish command velocities 10 times per second (whether 0 or not).
  3. Saving and restoring internal state from a config file.

src/drive_widget.h, and src/drive_widget.cpp实现的功能如下:
DriveWidget implements a control which translates mouse Y values into linear velocities and mouse X values into angular velocities.

8. Plugins: PlantFlagTool

在这里插入图片描述
demo代码为src/plant_flag_tool.h, and src/plant_flag_tool.cpp

9. Librviz: Incorporating RViz into a Custom GUI

rviz其实相对于一个应用app更像是一个库,我们可以在自己开发的应用中调用librviz.so,这样就可以在自己的应用中调用实现rviz的功能。
就像下面这样:
在这里插入图片描述

demo代码在这两个文件中: src/main.cpp, src/myviz.h, and src/myviz.cpp.

10. 3D立体渲染

需要有一个显卡和一个可以显示120hz的显示屏

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值