rviz plugin troubleshooting

目前

http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB

You can't run a plugin by itself in gdb; you need to run it as part of a node.

The easiest way to go about this is to run the node which loads your plugin in gdb; in this case that would be move_base. Just edit the launch file which runs move_base to run it inside of gdb.

Depending on the node and the failure case, you may get more output by adding the output="screen"option in your launch file as well.

As a side node, negative exit codes (like -11) indicate the signal that caused your program to exit; signal 11 is segfault. The signal numbers are standardized for all Linux, OSX and POSIX systems, and are widely documented; for example: http://man7.org/linux/man-pages/man7/...

#要在一个node 里面 debug plugin

<launch>
  <include file="$(find velodyne)/launch/VelodyneParam.launch" />
  <node pkg="nodelet" type="nodelet" name="standalone_nodelet" args="manager" launch_prefix="xterm -e gdb --args"/>
   
  <node pkg="nodelet" type="nodelet" name="Project3D"
  args="load velodyne/Project3D standalone_nodelet" output="screen" launch_prefix="xterm -e gdb --args">
  </node>
  <node pkg="nodelet" type="nodelet" name="Points"
  args="load velodyne/Points standalone_nodelet" launch_prefix="xterm -e gdb --args">
  </node>
  </launch>

自己再写个launch file 

<launch>

  


  <!-- run rviz -->
  <node pkg="rviz" type="rviz" name="rviz"
    args="-d $(find annotate_rosbags)/rviz/annotate_rosbags.rviz" output="screen" launch-prefix="xterm -e gdb --args"> 
  </node>

</launch>

launch 如何用gdb file 

http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB

3

You can either debug an application by starting it with GDB

%> gdb <your_executable>

or what is usually easier is to start your application and then attach the debugger to the process using the PID.

%> gdb -p <pid>

For command line options, just type gdb -h and while running inside of gdb help is always available by typing "help" on the gdb command line.

Here is a quick cheat sheet and a tutorial site on some common commands.

As Arkaitz mentioned, be sure to compile your code so that it has the necessary debug information included in the executable.

If debugging from the command line is a bit daunting, there are some UIs available that use GDB. I do a lot of my debugging in Eclipse using gdb.

Once you get started down the gdb path, I'm sure you'll have more questions and I encourage you to ask those more specific questions on SO.

Good luck.

https://github.com/ros-visualization/rviz_animated_view_controller/issues/5

As an additional note, compilation under Kinetic works but the CMakeLists.txt should add the following line:

add_dependencies(${PROJECT_NAME} ${view_controller_msgs_EXPORTED_TARGETS})

I didn't do a PR because there is not kinectic-devel branch yet.

${view_controller_msgs_EXPORTED_TARGETS} what is that means ?

#############################################################

Hi,

It seems that there is some inconsistencies with Qt versions. So here is what we at NRG lab found out:
Initial observations:

  • initially without any changes in the cmakelists file, rviz throws a seg fault when loading the plugin without any further info. just gone
  • when "rviz plugin tutorials" example cmakelists is used, an error pops up saying:
    Failed to load library /home/repositories/motoman/devel/lib/librviz_animated_view_controller.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/andrew/repositories/motoman/devel/lib/librviz_animated_view_controller.so: undefined symbol: _ZTVN29rviz_animated_view_controller22AnimatedViewControllerE)

After some debugging:

  • In CMakeLists.txt, the "rviz_QT_VERSION" prints out version which is +5.x.x, which is ok since ...
  • ... rviz binary on kinetic is by default compiled against qt5 and therefore qt5 must be used when compiling your rviz plugin.
  • Rviz plugin tutorials is fancy and checks the version of qt but fails on using either of them afterwards. By failing I mean, that incorrect cmake variables are used and/or set (variables that point out where include files and libs are located)
  • Not sure about that one but it seems that before qt5, these "QT_INCLUDE_DIR" contained paths to all qt related stuff. Now with qt5, user has to specify what kind of "stuff" is needed. For example if its looking for "QT_INCLUDE_DIR" or "QT_USE_FILE" (magical qt specific cmake variables for qt widget, core, gui, etc., directories) it gets nothing.
  • Now finally, when the plugin was built with qt4, everything is fine until rviz loads the plugin. It will get something completely different than its expecting and rviz crashes (some internal magic due to version differences: "v4 for dynamically loaded plugin" vs "v5 rviz binary")

These are just the things we observed, without knowing the specific inner clockwork of cmake/qmake/find_package magic. But we are quite sure, that "rviz plugin tutorials" cmakelists
is unfinished or broken and kinda spreads the chaos. SO as a quick fix in kinetic, you:

  • Set the include directories manually, for example: if your plugin needs qtcore and qt widgets: "set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} )" and use it in the include_directories() cmake function: "include_directories(include ${catkin_INCLUDE_DIRS} otherDir1 otherDir2 )". Again, qt4 had this nice variable "QT_INCLUDE_DIR" that already contained all the necessary things but with qt5, this thing either does not exist, has a different name or requires some specific cmake function to be called out beforehand. Dunno.
  • use "qt5_wrap_cpp(MOC_FILES bla bla)" instead of "set(CMAKE_AUTOMOC ON)". MOC is a magic within a witchcraft mixed with fairy tales that makes all hannibal's plans come together. We did not dig deep, but this gives a short overview: http://doc.qt.io/qt-4.8/moc.html . The use of either "automoc" or "qt5_wrap_cpp()" depends on the version of the cmake: http://doc.qt.io/qt-5/cmake-manual.html

Thats about it. You can find the rviz_animated_view_controller for kinetic here: https://github.com/UTNuclearRoboticsPublic/rviz_animated_view_controller

I hope this info helps.

#############################

// so the issue may related to the qt4 and qt5 ?  check the cmakelists

//////// 终于成了//////////////

This is the same issue as in
ros-visualization/rviz_animated_view_controller#5

the inconsistency of the Qt library cause this issue
Qt5 in kinectic.

so I modify the CMakeLists file

It works

## BEGIN_TUTORIAL
## This CMakeLists.txt file for annotate_rosbags_rviz_plugin builds both the TeleopPanel tutorial and the ImuDisplay tutorial.
##
## First start with some standard catkin stuff.
cmake_minimum_required(VERSION 2.8.3)
project(annotate_rosbags_rviz_plugin)
find_package(catkin REQUIRED COMPONENTS rviz)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})
# add_dependencies(${PROJECT_NAME} ${view_controller_msgs_EXPORTED_TARGETS})


if(rviz_QT_VERSION VERSION_LESS "5")
  message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
  ## pull in all required include dirs, define QT_LIBRARIES, etc.
  include(${QT_USE_FILE})
else()
  message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
  ## make target_link_libraries(${QT_LIBRARIES}) pull in all required dependencies
  set(QT_LIBRARIES Qt5::Widgets)
endif()

## This plugin includes Qt widgets, so we must include Qt like so:
# find_package(Qt5 COMPONENTS QtCore QtGui REQUIRED)
# include(${QT_USE_FILE})

## I prefer the Qt signals and slots to avoid defining "emit", "slots",
## etc because they can conflict with boost signals, so define QT_NO_KEYWORDS here.
add_definitions(-DQT_NO_KEYWORDS)

## Here we specify which header files need to be run through "moc",
## Qt's meta-object compiler.
qt5_wrap_cpp(MOC_FILES
  src/drive_widget.h
  src/teleop_panel.h
)

## Here we specify the list of source files, including the output of
## the previous command which is stored in ``${MOC_FILES}``.
set(SOURCE_FILES
  src/drive_widget.cpp
  src/teleop_panel.cpp 
  ${MOC_FILES}
)

## An rviz plugin is just a shared library, so here we declare the
## library to be called ``${PROJECT_NAME}`` (which is
## "annotate_rosbags_rviz_plugin", or whatever your version of this project
## is called) and specify the list of source files we collected above
## in ``${SOURCE_FILES}``.
add_library(${PROJECT_NAME} ${SOURCE_FILES})

## Link the library with whatever Qt libraries have been defined by
## the ``find_package(Qt4 ...)`` line above, and with whatever libraries
## catkin has included.
##
## Although this puts "annotate_rosbags_rviz_plugin" (or whatever you have
## called the project) as the name of the library, cmake knows it is a
## library and names the actual file something like
## "libannotate_rosbags_rviz_plugin.so", or whatever is appropriate for your
## particular OS.
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
## END_TUTORIAL


## Install rules

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})

install(DIRECTORY media/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/media)

install(DIRECTORY icons/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/icons)

install(PROGRAMS scripts/send_test_msgs.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

//就是qt版本不一样造成的 

猜你喜欢

转载自blog.csdn.net/fly1ng_duck/article/details/89474864
今日推荐