rviz创建插件

这个博客不错:

http://www.guyuehome.com/945

OS探索总结(三十四)——rviz plugin

rviz是ROS官方的一款3D可视化工具,几乎我们需要用到的所有机器人相关数据都可以在rviz中展现,当然由于机器人系统的需求不同,很多时候rviz中已有的一些功能仍然无法满足我们的需求,这个时候rviz的plugin机制就派上用场了。上一篇我们探索了插件的概念和基本实现,这一篇通过rviz中的插件实现,来进行巩固加深。

rviz作为一种可扩展化的视图工具,可以使用这种插件机制来扩展丰富的功能,进行二次开发,我们在rviz中常常使用的激光数据可视化显示、图像数据可视化显示,其实都是官方提供的插件。所以,我们完全可以在rviz的基础上,打造属于我们自己的机器人人机界面。

 

总结下实现步骤:

 

在rviz中创建插件

1)在工作空间下创建package

$ catkin_create_pkg rviz_api_commander roscpp rviz std_msgs

这个功能包的依赖于rviz,因为rviz是基于Qt开发的,所以省去了对Qt的依赖。

2)实现窗体代码

一般窗体类可以派生于  rviz::Panelrviz::Displayrviz::Tool, or rviz::ViewController

3)注册插件

在窗口cpp代码中注册插件

#include <pluginlib/class_list_macros.h>

PLUGINLIB_EXPORT_CLASS(rviz_api_commander::ApiPanel,rviz::Panel)

4)将插件加入ROS系统

这里需要添加和修改功能包根目录下的两个xml文件

plugin_description.xml:

<library path="lib/librviz_api_commander">

<class name="rviz_api_commander/ApiPanel"

type="rviz_api_commander::ApiPanel"

base_class_type="rviz::Panel">

<description>

A panel widget allowing simple diff-drive style robot base control.

</description>

</class>

</library>

可以看到,这个xml文件主要描述了plugin的动态库路径、实现类、基类、描述等信息。

Package.xml:

<?xml version="1.0"?>

<package>

<name>rviz_api_commander</name>

<version>0.0.0</version>

<description>The rviz_api_commander package</description>

 

<!-- One maintainer tag required, multiple allowed, one person per tag --> 

<!-- Example: -->

<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->

<maintainer email="lentin@todo.todo">lentin</maintainer>

 

<!-- One license tag required, multiple allowed, one license per tag -->

<!-- Commonly used license strings: -->

<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->

<license>TODO</license>

 

<!-- Url tags are optional, but mutiple are allowed, one per tag -->

<!-- Optional attribute type can be: website, bugtracker, or repository -->

<!-- Example: -->

<!-- <url type="website">http://wiki.ros.org/rviz_teleop_commander</url> -->

 

<!-- Author tags are optional, mutiple are allowed, one per tag -->

<!-- Authors do not have to be maintianers, but could be -->

<!-- Example: -->

<!-- <author email="jane.doe@example.com">Jane Doe</author> -->

 

<!-- The *_depend tags are used to specify dependencies -->

<!-- Dependencies can be catkin packages or system dependencies -->

<!-- Examples: -->

<!-- Use build_depend for packages you need at compile time: -->

<!-- <build_depend>message_generation</build_depend> -->

<!-- Use buildtool_depend for build tool packages: -->

<!-- <buildtool_depend>catkin</buildtool_depend> -->

<!-- Use run_depend for packages you need at runtime: -->

<!-- <run_depend>message_runtime</run_depend> -->

<!-- Use test_depend for packages you need only for testing: -->

<!-- <test_depend>gtest</test_depend> -->

<buildtool_depend>catkin</buildtool_depend>

<build_depend>roscpp</build_depend>

<build_depend>rviz</build_depend>

<build_depend>std_msgs</build_depend>

<run_depend>roscpp</run_depend>

<run_depend>rviz</run_depend>

<run_depend>std_msgs</run_depend>

<export>

<rviz plugin="${prefix}/plugin_description.xml"/>

</export>

</package>

5)在workspace下运行catkin_make

编译单个包:rosmake rviz_api_commander

 

6)运行 rosrun rviz rviz

7)如果有异常要source下

在工作空间目录执行:source devel/setup.bash

 

 

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值