Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to build Qt5 Application with custom ROS messages

I'm attempting to add a custom ROS message to a simple QT5 application. I placed 3 files into msg folder in the package root, called generate on them and verified that they were built in my devel directory. It seems once catkin trys to build the QT application, it fails looking for the included message headers. I'm new to ROS and relatively new to QT so it's probably something obvious in my CMakeLists.txt.

This is my CMakeLists.txt

cmake_minimum_required(VERSION 3.1.0)
project(demointerface)

# set(CMAKE_INCLUDE_CURRENT_DIR ON)
# set(CMAKE_AUTOMOC ON)
# set(CMAKE_AUTOUIC ON)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  message_generation
  std_msgs
  qt_build
)
find_package(yaml-cpp REQUIRED)

# set(Qt5_DIR "/opt/Qt/5.12.0/gcc_64/lib/cmake/Qt5")
# rosbuild_prepare_qt4(QtCore QtGui)

##############################################################################
## Build
##############################################################################
include_directories( ${catkin_INCLUDE_DIRS} )

add_message_files( 
  FILES 
  heartbeatData.msg 
  testCfgData.msg 
  targetCmd.msg
)

generate_messages( DEPENDENCIES std_msgs)

catkin_package(CATKIN_DEPENDS message_runtime)

##############################################################################
# Qt Environment
##############################################################################


find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
message("QT Version: ${Qt5_VERSION}")

file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/demointerface/*.hpp)


qt5_add_resources(QT_RESOURCES_CPP ${QT_RESOURCES})
qt5_wrap_ui(QT_FORMS_HPP ${QT_FORMS})
qt5_wrap_cpp(QT_MOC_HPP ${QT_MOC})

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

##############################################################################
# Binaries
##############################################################################
add_executable(demointerface ${QT_SOURCES} ${QT_MOC_HPP} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} )
add_dependencies(demointerface demointerface_generate_messages_cpp)
target_link_libraries(demointerface 
  Qt5::Core
  Qt5::Widgets
  Qt5::Gui
  ${YAML_CPP_LIBRARIES}
  ${catkin_LIBRARIES})
install(TARGETS demointerface RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

ROS Packages: qt_build 2.1.0 roscpp 1.12.14 std_msgs 0.5.11

Platform Information: Ubuntu Xenial 4.15.0-43-generic gcc 5.4.0 Qt 5.5.1 ROS Kinetic

Thanks for the help.