ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Here a sample CMakeLists.txt
which allowed us to create rviz
panels, I'm not quite sure what you need to adapt, however, we had no manual copying to do. Seems like you are missing the MOC_FILES
and the UIC_FILES
at the add_library()
call...
Note that this is Qt4 only, but I guess the Qt5 way should be pretty similar...
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_NO_KEYWORDS)
set(
HEADER_FILES
src/my_panel.h
)
# required if you want to add some images, etc. Could be made differently/nicer, probably.
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.resource)
qt4_add_resources(
QT_RESOURCES_CPP
${QT_RESOURCES}
)
qt4_wrap_cpp(
MOC_FILES
${HEADER_FILES}
)
qt4_wrap_ui(
UIC_FILES
resource/my_panel.ui
)
set(
SOURCE_FILES
src/my_panel.cpp
)
add_library(my_panel ${SOURCE_FILES} ${QT_RESOURCES_CPP} ${MOC_FILES} ${UIC_FILES})
target_link_libraries(my_panell ${QT_LIBRARIES} ${catkin}_LIBRARIES)
# maybe you also need a add_dependencies() call, we did not...
2 | No.2 Revision |
Here a sample CMakeLists.txt
which allowed us to create rviz
panels, I'm not quite sure what you need to adapt, however, we had no manual copying to do. Seems like you are missing the MOC_FILES
and the UIC_FILES
at the add_library()
call...
Note that this is Qt4 only, but I guess the Qt5 way should be pretty similar...
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_NO_KEYWORDS)
set(
HEADER_FILES
src/my_panel.h
)
# required if you want to add some images, etc. Could be made differently/nicer, probably.
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.resource)
qt4_add_resources(
QT_RESOURCES_CPP
${QT_RESOURCES}
)
qt4_wrap_cpp(
MOC_FILES
${HEADER_FILES}
)
qt4_wrap_ui(
UIC_FILES
resource/my_panel.ui
)
set(
SOURCE_FILES
src/my_panel.cpp
)
add_library(my_panel ${SOURCE_FILES} ${QT_RESOURCES_CPP} ${MOC_FILES} ${UIC_FILES})
target_link_libraries(my_panell ${QT_LIBRARIES} ${catkin}_LIBRARIES)
${catkin_LIBRARIES})
# maybe you also need a add_dependencies() call, we did not...
3 | No.3 Revision |
Here a sample CMakeLists.txt
which allowed us to create rviz
panels, I'm not quite sure what you need to adapt, however, we had no manual copying to do. Seems like you are missing the MOC_FILES
and the UIC_FILES
at the add_library()
call...
Note that this is Qt4 only, but I guess the Qt5 way should be pretty similar...
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_NO_KEYWORDS)
set(
HEADER_FILES
src/my_panel.h
)
# required if you want to add some images, etc. Could be made differently/nicer, probably.
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.resource)
qt4_add_resources(
QT_RESOURCES_CPP
${QT_RESOURCES}
)
qt4_wrap_cpp(
MOC_FILES
${HEADER_FILES}
)
qt4_wrap_ui(
UIC_FILES
resource/my_panel.ui
)
set(
SOURCE_FILES
src/my_panel.cpp
)
add_library(my_panel ${SOURCE_FILES} ${QT_RESOURCES_CPP} ${MOC_FILES} ${UIC_FILES})
target_link_libraries(my_panell ${QT_LIBRARIES} ${catkin_LIBRARIES})
# maybe you also need a add_dependencies() call, we did not...
EDIT
Note that this is implemented as a QWidget
.
Some more templates:
Our header my_panel.h
:
#include <ros/ros.h>
#include <rviz/panel.h>
namespace Ui
{
class MyPanelUi;
}
namespace my_panel
{
class MyPanel: public rviz::Panel
{
Q_OBJECT
public:
MyPanel( QWidget* parent = 0 );
~MyPanel();
protected:
ros::NodeHandle nh_;
Ui::MyPanelUi *ui_;
private Q_SLOTS:
// Q_SLOTS for interaction with buttons, etc.
void gui_button_stop();
// your custom stuff
}; // MyPanel
} // my_panel
The my_panel.cpp
#include "my_panel.h"
#include "ui_my_panel.h"
#include <QMessageBox>
namespace my_panel
{
MyPanel::MyPanel( QWidget* parent )
: rviz::Panel( parent )
, ui_(new Ui::MyPanelUi())
{
// set up the GUI
ui_->setupUi(this);
// connecting the signals to the respectiv SLOTs
/*
* Main Control Buttons *
*/
// the button is called pushButton_stop in the ui file
connect( ui_->pushButton_stop, SIGNAL( clicked() ), this, SLOT( gui_button_stop() ));
}