ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

RVIZ2 plugin fails to load

asked 2021-09-09 07:06:54 -0500

phlipdiek gravatar image

Hello,

I am currently developing a rviz2 panel. Somehow I can not manage to load a minimalist version of a panel. Pluginlib seems to be able to find the library but I always encounter the following error:

[ERROR] [1631188327.522072850] [rviz2]: PluginlibFactory: The plugin for class 'autde_tello_panel/AutdeTello' failed to load. Error: Failed to load library /home/philly/projects/drone_poc/ros2_ws/install/autde_tello_panel/lib/libautde_tello_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 LoadLibrary error: /home/philly/projects/drone_poc/ros2_ws/install/autde_tello_panel/lib/libautde_tello_panel.so: undefined symbol: _ZTVN17autde_tello_panel15AutdeTelloPanelE, at /tmp/binarydeb/ros-foxy-rcutils-1.1.3/src/shared_library.c:84

I have checked the macro and the xml hundreds of times but it is still not working.

The header: autde_tello_panel.h:

#ifndef AUTDETELLOPANEL_H
#define AUTDETELLOPANEL_H

#include <QMainWindow>
#include "rviz_common/panel.hpp"

namespace rviz_common
{
namespace properties
{
class PropertyTreeWidget;
}
}

namespace autde_tello_panel
{

class AutdeTelloPanel : public rviz_common::Panel // QMainWindow
{
    Q_OBJECT

public:
    explicit AutdeTelloPanel(QWidget *parent = nullptr);

    void onInitialize() override;

private:
    rviz_common::properties::PropertyTreeWidget * tree_widget_;
};

} // namespace autde_tello_panel

#endif // AUTDETELLOPANEL_H

The source file: autde_tello_panel.cpp:

#include "autde_tello_panel/autde_tello_panel.h"

#include "rviz_common/properties/property_tree_widget.hpp"
#include "rviz_common/interaction/selection_manager.hpp"
#include "rviz_common/visualization_manager.hpp"

#include <QVBoxLayout>

namespace autde_tello_panel
{

AutdeTelloPanel::AutdeTelloPanel(QWidget *parent)
    : rviz_common::Panel(parent)
{
    auto layout = new QVBoxLayout();
    layout->setContentsMargins(0, 0, 0, 0);
    tree_widget_ = new rviz_common::properties::PropertyTreeWidget();
    layout->addWidget(tree_widget_);
    setLayout(layout);
}

void AutdeTelloPanel::onInitialize()
{
  tree_widget_->setModel(getDisplayContext()->getSelectionManager()->getPropertyModel());
}

}  // namespace autde_tello_panel


#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(autde_tello_panel::AutdeTelloPanel, rviz_common::Panel)

plugin_description.xml

<library path="libautde_tello_panel">
  <class name="autde_tello_panel/AutdeTello"
         type="autde_tello_panel::AutdeTelloPanel"
         base_class_type="rviz_common::Panel">
    <description>
      autde_tello_panel
    </description>
  </class>
</library>

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)

project(autde_tello_panel LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(Qt5 COMPONENTS Widgets Core Gui REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rviz_common REQUIRED)
find_package(pluginlib REQUIRED)


add_library(autde_tello_panel SHARED
  src/autde_tello_panel.cpp
)

target_include_directories(autde_tello_panel PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  ${Qt5Widgets_INCLUDE_DIRS}
)

target_link_libraries(autde_tello_panel PUBLIC ${QT_LIBRARIES})

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(autde_tello_panel PRIVATE "RVIZ_DEFAULT_PLUGINS_BUILDING_LIBRARY")

# prevent pluginlib from using boost
target_compile_definitions(autde_tello_panel PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(rviz_common src/plugin_description.xml)

ament_target_dependencies(autde_tello_panel PUBLIC
  rclcpp 
  rviz_common
)

ament_export_include_directories(include)
ament_export_targets(autde_tello_panel HAS_LIBRARY_TARGET)
ament_export_dependencies(
  rviz_common
  rclcpp
)

install(
  TARGETS autde_tello_panel
  EXPORT autde_tello_panel
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
  INCLUDES DESTINATION include
)

install(
  DIRECTORY include/
  DESTINATION include
)

ament_package()

package.xml:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>autde_tello_panel</name>
  <version>0.0.0</version>
  <description>Panel for rviz2</description>
  <maintainer email="p.d">p.d</maintainer>
  <license>all rights reserved</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <build_depend>qtbase5-dev</build_depend>
  <build_depend>qt5-qmake</build_depend>
  <exec_depend>libqt5-core</exec_depend>

  <depend>rclcpp</depend>
  <depend>rviz_common</depend>
  <depend>libqt5-widgets</depend>
  <depend>rviz2</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <rviz plugin="plugin_description.xml"/> ...
(more)
edit retag flag offensive close merge delete

Comments

I meet the same problem, had you solve it?

lrm gravatar image lrm  ( 2022-12-05 04:01:36 -0500 )edit

I did. I will add the answer below

phlipdiek gravatar image phlipdiek  ( 2022-12-06 00:53:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-06 00:59:48 -0500

phlipdiek gravatar image

updated 2022-12-06 01:03:00 -0500

I was able to solve the issue by editing the CMakeLists.txt:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)

project(autde_tello_panel LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rviz_ogre_vendor REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Widgets)

find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rviz_assimp_vendor REQUIRED)
find_package(rviz_rendering REQUIRED)
find_package(rviz_common REQUIRED)

ament_package_xml()
set(ROS_DISTRO "ROS 2")
set(OGRE_PLUGIN_PATH "rviz_ogre_vendor")

set(autde_tello_panel_headers_to_moc
include/autde_tello_panel.h
)

foreach(header "${autde_tello_panel_headers_to_moc}")
qt5_wrap_cpp(autde_tello_panel_moc_files "${header}")
endforeach()

set(autde_tello_panel_source_files
src/autde_tello_panel.cpp
)

add_library(autde_tello_panel SHARED
${autde_tello_panel_moc_files}
${autde_tello_panel_source_files}
)

target_include_directories(autde_tello_panel
PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

target_link_libraries(autde_tello_panel
PUBLIC
rviz_ogre_vendor::OgreMain
rviz_ogre_vendor::OgreOverlay
Qt5::Widgets
)

ament_target_dependencies(autde_tello_panel
PUBLIC
pluginlib
rclcpp
rviz_assimp_vendor
rviz_rendering
rviz_common
)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(autde_tello_panel PRIVATE "RVIZ_DEFAULT_PLUGINS_BUILDING_LIBRARY")

# prevent pluginlib from using boost
target_compile_definitions(autde_tello_panel PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(rviz_common plugin_description.xml)

ament_export_targets(autde_tello_panel)
ament_export_dependencies(
rviz_rendering
rviz_common
rcl_interfaces
pluginlib
rclcpp
)
ament_export_include_directories(include)
ament_export_libraries(autde_tello_panel)

install(
TARGETS autde_tello_panel
EXPORT autde_tello_panel
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

install(
DIRECTORY include/
DESTINATION include
)

ament_package()

Some if this code might be project specific as it is quite a while ago I am not sure but I hope this helps.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2021-09-09 07:06:54 -0500

Seen: 1,072 times

Last updated: Dec 06 '22