[ROS] PyQT with ROS Melodic
Original : www.notion.so/researchbysuho/PyQT-with-ROS-Melodic-cfacbb074ec34b6fae2e4aad5c5903e2
I tried to do it with
but I need to do some work fot this.
because there are some errors about QT4.
QT4 is depreciated,
and ROS Melodic support QT5 officially.
so I need to remove some packages for this job done in ROS Melodic environment.
so
1. Delete test_gui, qt4rosgui, vizlib_test package.
2. there are wrong phrase in CMakeLists.txt file in qt_ros_test package.
so change
catkin_package( INCLUDE_DIRS include # LIBRARIES client_plugin CATKIN_DEPENDS roscpp std_msgs # DEPENDS system_lib )
to
catkin_package( # INCLUDE_DIRS include # LIBRARIES client_plugin CATKIN_DEPENDS roscpp std_msgs # DEPENDS system_lib )
3. Install qtcreator
sudo apt-get install qtcreator
4. Install qt-5-default
sudo apt-get install qt5-default
5. add line to CMakeLists.txt from dyn_cfg_gui package.
change
include_directories( include ${CMAKE_CURRENT_BINARY_DIR}/.. ${catkin_LIBRARY_DIRS} )
to
include_directories( include ${CMAKE_CURRENT_BINARY_DIR}/.. ${catkin_LIBRARY_DIRS} ${catkin_INCLUDE_DIRS} )
6. change my_cplugin.cpp from rqt_mypkg like below
change
PLUGINLIB_DECLARE_CLASS(rqt_mypkg_cpp, MyPlugin, rqt_mypkg_cpp::MyPlugin, rqt_gui_cpp::Plugin)
to
PLUGINLIB_EXPORT_CLASS(rqt_mypkg_cpp::MyPlugin, rqt_gui_cpp::Plugin)
ref:
7. Add ui folder to CMAKE_AUTOUIC_SEARCH_PATHS
CMakeLists.txt from ros_cv_gui package.
change
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON)
to
set(CMAKE_AUTOUIC_SEARCH_PATHS ui) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON)
ref:
How to place header and ui file in different folders using autouic in cmake
8. Edit CMakeList.txt from qt_ros_test package.
change
## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) find_package(OpenCV REQUIRED) find_package(Qt5Widgets REQUIRED) qt5_wrap_cpp(myMOC include/${PROJECT_NAME}/mydemo.h) qt5_generate_moc(include/${PROJECT_NAME}/mydemo.h mydemo.moc) qt5_wrap_ui(myUIC ui/mydemo.ui)
to
## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) find_package(OpenCV REQUIRED) find_package(Qt5Widgets REQUIRED) qt5_wrap_cpp(myMOC include/${PROJECT_NAME}/mydemo.h) qt5_generate_moc(include/${PROJECT_NAME}/mydemo.h mydemo.moc) qt5_wrap_ui(myUIC ui/mydemo.ui)
and
change
## Declare a C++ executable add_executable(${PROJECT_NAME}_node src/main.cpp src/qt_ros_test.cpp src/qt_ros_test.h src/qt_ros_test.ui)
to
## Declare a C++ executable add_executable(${PROJECT_NAME}_node src/main.cpp src/qt_ros_test.cpp ${MOC} ${UIC} qt_ros_test.moc src/qt_ros_test.h src/qt_ros_test.ui)
9. Edit CMakeList.txt from ros_cv_gui package.
change
## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) find_package(OpenCV REQUIRED) find_package(Qt5Widgets REQUIRED) qt5_wrap_cpp(myMOC include/${PROJECT_NAME}/mydemo.h) qt5_wrap_ui(myUIC ui/mydemo.ui)
to
## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) find_package(OpenCV REQUIRED) find_package(Qt5Widgets REQUIRED) qt5_wrap_cpp(myMOC include/${PROJECT_NAME}/mydemo.h) qt5_generate_moc(include/${PROJECT_NAME}/mydemo.h mydemo.moc) qt5_wrap_ui(myUIC ui/mydemo.ui)
and
change
## Declare a C++ executable add_executable(${PROJECT_NAME}_node src/main.cpp src/mydemo.cpp include/${PROJECT_NAME}/mydemo.h ui/mydemo.ui)
to
## Declare a C++ executable add_executable(${PROJECT_NAME}_node src/main.cpp src/mydemo.cpp ${myMOC} ${myUIC} mydemo.moc include/${PROJECT_NAME}/mydemo.h ui/mydemo.ui)