0
$\begingroup$

Rosanswers logo

Hello,

I'm trying to create an RVIZ plugin on ROS KINETIC that does something similar to the "2D pose Estimate" function. My idea is to capture a specific pose on the map and publish on a specific topic. However, I am getting the following error message when I click on the "Add a new Tool" menu in RVIZ:

[ERROR] [1611276556.186111089]: PluginlibFactory: The plugin for class 'rviz_plugin_setDock/SetDock' failed to load.  Error: Failed to load library /home/mateus/catkin_ws/devel/lib/libsetDock.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/mateus/catkin_ws/devel/lib/libsetDock.so: undefined symbol: _ZN19rviz_plugin_setDock7SetDockD1Ev)

the link to my package is this:

https://drive.google.com/file/d/1L-vMHZUaHM6aVD4FuIBOouQnXi-rRkFJ/view?usp=sharing

setDock.cpp:

#include <tf/transform_listener.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include "rviz/display_context.h"
#include "setDock/setDock.hpp"

namespace rviz_plugin_setDock
{
SetDock::SetDock()
{
}

/*SetDock::~SetDock()
{
}*/

void SetDock::onInitialize()
{
  SetDock::onInitialize();
  setName("Set_Dock");
  updateTopic();
}

void SetDock::updateTopic()
{
  pub_ = nh_.advertise<geometry_msgs::PoseWithCovarianceStamped>( "dock_position", 1 );
}

void SetDock::onPoseSet(double x, double y, double theta)
{
  ROS_INFO("test"); 
}

}  // namespace rviz_plugin_setDock

#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS(rviz_plugin_setDock::SetDock, rviz::Tool)

setDock.hpp:

#ifndef SETDOCK_HPP
#define SETDOCK_HPP

#ifndef Q_MOC_RUN  // See: https://bugreports.qt-project.org/browse/QTBUG-22829
#include <QObject>
#include <ros/ros.h>
#include "rviz/default_plugin/tools/pose_tool.h"
#endif


namespace rviz_plugin_setDock
{
class SetDock;
class Arrow;
class DisplayContext;


class SetDock : public rviz::PoseTool
{
  Q_OBJECT
public:
  SetDock();
  virtual ~SetDock();
  virtual void onInitialize();

protected:
  virtual void onPoseSet(double x, double y, double theta);

public Q_SLOTS:
  void updateTopic();

private:
  ros::NodeHandle nh_;
  ros::Publisher pub_;

};
}  // namespace rviz_plugin_setDock

#endif  // SETDOCK_HPP

package.xml:

<?xml version="0.1.0"?>
<package>
  <name>setDock</name>
  <version>0.1.0</version>
  <description>Rviz plugin para definir a posicao da doca de recarga das baterias.</description>
  <maintainer  email="[email protected]">Mateus</maintainer>
  <license>A</license>
  <author email="[email protected]">Mateus</author>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rviz</build_depend>

  <run_depend>rviz</run_depend>

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

plugin_description.xml:

<library path="libsetDock">
  <class name="rviz_plugin_setDock/SetDock"
         type="rviz_plugin_setDock::SetDock"
         base_class_type="rviz::Tool">
    <description>
      Plugin para definir a posicao da Doca para recarga de baterias.
    </description>
  </class>
</library>

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(setDock)
find_package(catkin REQUIRED COMPONENTS rviz)
catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})

find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets Quick)
set(QT_LIBRARIES Qt5::Widgets)
qt5_wrap_cpp(MOC_FILES
  include/setDock/setDock.hpp
  )
add_definitions(-DQT_NO_KEYWORDS)

add_library(${PROJECT_NAME}
  src/setDock.cpp
  ${MOC_FILES}
  )

target_link_libraries(${PROJECT_NAME}
  ${QT_LIBRARIES}
  ${catkin_LIBRARIES}
  )

install(TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  )

install(FILES
  plugin_description.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

I don't have much experience with C ++, so any help is welcome

thanks


Originally posted by mateusguilherme on ROS Answers with karma: 125 on 2021-01-21

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

At first glance the SetDock class inherits from the rviz::PoseTool class so you might want to try to use rviz::PoseTool as your "base_class_type" when calling the PLUGINLIB C++ macro in your setDock.cpp file and when you specify the base_class_type tag in the plugin_description.xml file.

For example:

PLUGINLIB_EXPORT_CLASS(rviz_plugin_setDock::SetDock, rviz::PoseTool)

and

base_class_type="rviz::PoseTool">


Originally posted by danambrosio with karma: 106 on 2021-01-24

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.