-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/noetic-devel' into noetic-devel
- Loading branch information
Showing
12 changed files
with
930 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(image_display_with_click) | ||
|
||
################### | ||
# compile options # | ||
################### | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fno-asm -fPIC") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0") | ||
|
||
|
||
# Qt settings # | ||
find_package(Qt5 ${rviz_QT_VERSION} REQUIRED Core Widgets) | ||
#find_package(QCustomPlot) | ||
|
||
macro(qt_wrap_ui) | ||
qt5_wrap_ui(${ARGN}) | ||
endmacro() | ||
include_directories(${Qt5Core_INCLUDE_DIRS}) | ||
include_directories(${Qt5Widgets_INCLUDE_DIRS}) | ||
add_definitions(-DQT_NO_KEYWORDS) | ||
# cmake settings # | ||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
|
||
# catkin # | ||
set(DEPEND_ROS_PKGS | ||
class_loader | ||
pluginlib | ||
roscpp | ||
rviz | ||
std_msgs | ||
atom_msgs | ||
) | ||
find_package(catkin REQUIRED | ||
COMPONENTS | ||
${DEPEND_ROS_PKGS} | ||
) | ||
|
||
catkin_package( | ||
INCLUDE_DIRS | ||
include | ||
LIBRARIES | ||
${PROJECT_NAME} | ||
CATKIN_DEPENDS | ||
${DEPEND_ROS_PKGS} | ||
DEPENDS | ||
) | ||
|
||
######### | ||
# Build # | ||
######### | ||
## add include directory ## | ||
include_directories( | ||
include | ||
${catkin_INCLUDE_DIRS} | ||
) | ||
## add library path ## | ||
link_directories(${catkin_LIBRARY_DIRS}) | ||
|
||
# source codes # | ||
set(HEADERS | ||
include/image_display_with_click/image_display_with_click.h | ||
include/image_display_with_click/mouse_watcher.h | ||
) | ||
#qt5_wrap_ui(UIC_FILES | ||
# src/ui/calibration_panel.ui | ||
# ) | ||
|
||
set(SOURCE_FILES | ||
src/plugin_load.cpp | ||
src/image_display_with_click.cpp | ||
src/mouse_watcher.cpp | ||
) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${HEADERS} ${UIC_FILES}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") | ||
target_include_directories(${PROJECT_NAME} PRIVATE "${OGRE_PREFIX_DIR}/include") | ||
|
||
|
||
|
||
########### | ||
# Install # | ||
########### | ||
install(FILES plugin_description.xml | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} | ||
) | ||
install(DIRECTORY icons DESTINATION share/${PROJECT_NAME}) | ||
install(DIRECTORY include/ DESTINATION include) | ||
install(TARGETS ${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin) |
85 changes: 85 additions & 0 deletions
85
...gins/image_display_with_click/include/image_display_with_click/image_display_with_click.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef IMAGE_DISPLAY_WITH_CLICK_H | ||
#define IMAGE_DISPLAY_WITH_CLICK_H | ||
|
||
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 | ||
#include "../../../../../../../usr/include/x86_64-linux-gnu/qt5/QtCore/QObject" | ||
#include "../../../../../../../usr/include/OGRE/OgreMaterial.h" | ||
#include "../../../../../../../usr/include/OGRE/OgreRenderTargetListener.h" | ||
#include "../../../../../../../usr/include/OGRE/OgreSharedPtr.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/image/image_display_base.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/image/ros_image_texture.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/render_panel.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/bool_property.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/float_property.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/int_property.h" | ||
#endif | ||
|
||
#include <iostream> | ||
#include <QMouseEvent> | ||
|
||
#include "ros/ros.h" | ||
#include "geometry_msgs/PointStamped.h" | ||
#include "std_msgs/String.h" | ||
|
||
#include <image_display_with_click/mouse_watcher.h> | ||
|
||
namespace Ogre | ||
{ | ||
class SceneNode; | ||
class Rectangle2D; | ||
} // namespace Ogre | ||
|
||
using namespace std; | ||
|
||
namespace atom_rviz | ||
{ | ||
class ImageDisplayWithClick : public rviz::ImageDisplayBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
ImageDisplayWithClick(); | ||
~ImageDisplayWithClick() override; | ||
|
||
// Overrides from Display | ||
void onInitialize() override; | ||
void update(float wall_dt, float ros_dt) override; | ||
void reset() override; | ||
|
||
public Q_SLOTS: | ||
virtual void updateNormalizeOptions(); | ||
|
||
|
||
|
||
protected: | ||
// overrides from Display | ||
void onEnable() override; | ||
void onDisable() override; | ||
|
||
/* This is called by incomingMessage(). */ | ||
void processMessage(const sensor_msgs::Image::ConstPtr& msg) override; | ||
|
||
Ogre::SceneManager* img_scene_manager_; | ||
|
||
rviz::ROSImageTexture texture_; | ||
|
||
rviz::RenderPanel* render_panel_; | ||
|
||
|
||
private: | ||
Ogre::SceneNode* img_scene_node_; | ||
Ogre::Rectangle2D* screen_rect_; | ||
Ogre::MaterialPtr material_; | ||
|
||
BoolProperty* normalize_property_; | ||
rviz::FloatProperty* min_property_; | ||
rviz::FloatProperty* max_property_; | ||
rviz::IntProperty* median_buffer_size_property_; | ||
bool got_float_image_; | ||
|
||
MouseWatcher* mouse_watcher; | ||
}; | ||
|
||
} // namespace rviz | ||
|
||
|
||
#endif |
50 changes: 50 additions & 0 deletions
50
atom_rviz_plugins/image_display_with_click/include/image_display_with_click/mouse_watcher.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef MOUSE_WATCHER_H | ||
#define MOUSE_WATCHER_H | ||
|
||
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 | ||
#include "../../../../../../../usr/include/x86_64-linux-gnu/qt5/QtCore/QObject" | ||
#include "../../../../../../../usr/include/OGRE/OgreMaterial.h" | ||
#include "../../../../../../../usr/include/OGRE/OgreRenderTargetListener.h" | ||
#include "../../../../../../../usr/include/OGRE/OgreSharedPtr.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/image/image_display_base.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/image/ros_image_texture.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/render_panel.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/bool_property.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/float_property.h" | ||
#include "../../../../../../../opt/ros/noetic/include/rviz/properties/int_property.h" | ||
#endif | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
#include <QMouseEvent> | ||
|
||
#include "ros/ros.h" | ||
#include "geometry_msgs/PointStamped.h" | ||
#include "std_msgs/String.h" | ||
|
||
using namespace std; | ||
|
||
namespace atom_rviz | ||
{ | ||
class MouseWatcher : public QObject | ||
{ | ||
public: | ||
MouseWatcher(QWidget * parent); | ||
virtual bool eventFilter(QObject * obj, QEvent * event); | ||
void setDimensions(int _img_width, int _img_height, int _win_width, int _win_height); | ||
void setTopic(string image_topic); | ||
|
||
private: | ||
string image_click_topic; | ||
bool has_dimensions; | ||
int img_width; | ||
int img_height; | ||
int win_width; | ||
int win_height; | ||
ros::Publisher* mouse_event_pub; | ||
ros::NodeHandle* node_handle; | ||
}; | ||
|
||
} // namespace rviz | ||
#endif |
Oops, something went wrong.