Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 670

Create an RViz dockable panel w/ catkin and Qt5

$
0
0
Hi everyone, These past days, I'm trying to write an RViz dockable panel following the tutorial [here](http://docs.ros.org/indigo/api/rviz_plugin_tutorials/html/panel_plugin_tutorial.html).
My goal is basically to display – for now – an empty panel (the strict minimum, for a beginning).
The problem is that all the tutorial is writing with both rosbuild and Qt4, while I would like to use catkin and Qt5. Each time I'm trying to compile, I keep having this error message :
[ERROR] [1426085794.672184440]: PluginlibFactory: The plugin for class 'plugin_panel/Hi' failed to load.  Error: Failed to load library /home/mdufour/catkin_ws_test/devel/lib/libplugin_panel.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/mdufour/catkin_ws_test/devel/lib/libplugin_panel.so: undefined symbol: _ZTVN8my_panel11PluginPanelE)
My package directory looks like this :
plugin_panel/
|__ CMakeLists.txt
|__ package.xml
|__ plugin_description.xml
|__ src/
    |__ plugin_panel.cpp
All the code is in the `.cpp` file, for simplification.
Here's my `CMakeLists.txt` :
cmake_minimum_required(VERSION 2.8.11)

project(plugin_panel)

find_package(Qt4 REQUIRED)
find_package(catkin REQUIRED)

include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})

add_library(${PROJECT_NAME} src/plugin_panel.cpp)

target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
This is my `.cpp` (very basic!) :
#include <QWidget>
#include <QHBoxLayout>
#include <QLabel>

#include <rviz/panel.h>

namespace my_panel
{
    class PluginPanel: public rviz::Panel
    {
        Q_OBJECT

    public:
        PluginPanel(QWidget* parent = 0):
            rviz::Panel(parent)
            {
                QHBoxLayout* topic_layout = new QHBoxLayout;
                topic_layout->addWidget(new QLabel("Hi!"));
            }
    };
}

#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS(my_panel::PluginPanel, rviz::Panel)
The `package.xml` (overloaded for sure) :
<?xml version="1.0"?><package><name>plugin_panel</name><version>0.0.0</version><description>
        An additional (yet empty) panel in RViz.</description><maintainer email="none@none.none">Matthieu</maintainer><license>BSD</license><buildtool_depend>catkin</buildtool_depend><build_depend>roscpp</build_depend><build_depend>roslib</build_depend><build_depend>rviz</build_depend><build_depend>pluginlib</build_depend><build_depend>class_loader</build_depend><run_depend>roscpp</run_depend><run_depend>roslib</run_depend><run_depend>rviz</run_depend><run_depend>pluginlib</run_depend><run_depend>class_loader</run_depend><export><rviz plugin="${prefix}/plugin_description.xml"/></export><package>
And finally the `plugin_description.xml` :
<library path="lib/libplugin_panel"><class name="plugin_panel/Hi"
           type="my_panel::PluginPanel"
           base_class_type="rviz::Panel"><description>
            An empty panel.</description></class></library>
Phew! Sorry, that was heavy… I'm certainly missing something in one of those files, but I can't figure out what.

Thanks for your answers.

Viewing all articles
Browse latest Browse all 670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>