From b907cae95b4477d5fad18f7b06771f2675817048 Mon Sep 17 00:00:00 2001 From: Martin Idel Date: Thu, 12 Jul 2018 15:50:50 +0200 Subject: [PATCH 1/5] Fix GridCells display updating of colour to all grid cells --- .../displays/grid_cells/grid_cells_display.hpp | 1 + .../displays/grid_cells/grid_cells_display.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rviz_default_plugins/include/rviz_default_plugins/displays/grid_cells/grid_cells_display.hpp b/rviz_default_plugins/include/rviz_default_plugins/displays/grid_cells/grid_cells_display.hpp index bd05f48ed..04b35738f 100644 --- a/rviz_default_plugins/include/rviz_default_plugins/displays/grid_cells/grid_cells_display.hpp +++ b/rviz_default_plugins/include/rviz_default_plugins/displays/grid_cells/grid_cells_display.hpp @@ -89,6 +89,7 @@ class RVIZ_DEFAULT_PLUGINS_PUBLIC GridCellsDisplay : public private Q_SLOTS: void updateAlpha(); + void updateColor(); private: bool messageIsValid(nav_msgs::msg::GridCells::ConstSharedPtr msg); diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp index 289005c2d..0ec91e200 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp @@ -62,7 +62,7 @@ GridCellsDisplay::GridCellsDisplay() : last_frame_count_(uint64_t(-1)) { color_property_ = new rviz_common::properties::ColorProperty("Color", QColor(25, 255, 0), - "Color of the grid cells.", this); + "Color of the grid cells.", this, SLOT(updateColor())); alpha_property_ = new rviz_common::properties::FloatProperty("Alpha", 1.0f, "Amount of transparency to apply to the cells.", @@ -101,6 +101,12 @@ void GridCellsDisplay::updateAlpha() context_->queueRender(); } +void GridCellsDisplay::updateColor() +{ + cloud_->setPickColor(rviz_common::properties::qtToOgre(color_property_->getColor())); + context_->queueRender(); +} + void GridCellsDisplay::processMessage(nav_msgs::msg::GridCells::ConstSharedPtr msg) { if (context_->getFrameCount() == last_frame_count_) { From d9756937b097aa05a932883e96d3312a97bf4e36 Mon Sep 17 00:00:00 2001 From: Martin Idel Date: Fri, 13 Jul 2018 15:48:02 +0200 Subject: [PATCH 2/5] Fix image_display visual test --- .../src/rviz_default_plugins/displays/image/image_display.cpp | 1 - .../displays/image/image_display_visual_test.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/image/image_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/image/image_display.cpp index 1bd8798cb..f7f98f28d 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/image/image_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/image/image_display.cpp @@ -104,7 +104,6 @@ ImageDisplay::ImageDisplay(std::unique_ptr texture) void ImageDisplay::onInitialize() { RTDClass::onInitialize(); - topic_property_->setValue("image"); updateNormalizeOptions(); setupScreenRectangle(); diff --git a/rviz_default_plugins/test/rviz_default_plugins/displays/image/image_display_visual_test.cpp b/rviz_default_plugins/test/rviz_default_plugins/displays/image/image_display_visual_test.cpp index 36bda4602..e85a16e35 100644 --- a/rviz_default_plugins/test/rviz_default_plugins/displays/image/image_display_visual_test.cpp +++ b/rviz_default_plugins/test/rviz_default_plugins/displays/image/image_display_visual_test.cpp @@ -44,6 +44,7 @@ TEST_F(VisualTestFixture, test_image_display_with_published_image) { setCamLookAt(Ogre::Vector3(0, 0, 0)); auto image_display = addDisplay(); + image_display->setTopic("/image"); captureRenderWindow(image_display); From 8123d3bbeb39b86fa5ab8aa3a7ee45f4872c1023 Mon Sep 17 00:00:00 2001 From: Martin Idel Date: Fri, 13 Jul 2018 17:31:42 +0200 Subject: [PATCH 3/5] Fix GridCellsDisplay - setPickColor only sets pick color for selection handlers - introduce setColor to actually set the points' colour --- .../displays/grid_cells/grid_cells_display.cpp | 2 +- .../include/rviz_rendering/objects/point_cloud.hpp | 3 +++ rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp index 0ec91e200..f4993bca8 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/grid_cells/grid_cells_display.cpp @@ -103,7 +103,7 @@ void GridCellsDisplay::updateAlpha() void GridCellsDisplay::updateColor() { - cloud_->setPickColor(rviz_common::properties::qtToOgre(color_property_->getColor())); + cloud_->setColor(rviz_common::properties::qtToOgre(color_property_->getColor())); context_->queueRender(); } diff --git a/rviz_rendering/include/rviz_rendering/objects/point_cloud.hpp b/rviz_rendering/include/rviz_rendering/objects/point_cloud.hpp index 1ced922b6..e7be1a3cf 100644 --- a/rviz_rendering/include/rviz_rendering/objects/point_cloud.hpp +++ b/rviz_rendering/include/rviz_rendering/objects/point_cloud.hpp @@ -182,6 +182,9 @@ class PointCloud : public Ogre::MovableObject RVIZ_RENDERING_PUBLIC void setAlpha(float alpha, bool per_point_alpha = false); + RVIZ_RENDERING_PUBLIC + void setColor(const Ogre::ColourValue & color); + RVIZ_RENDERING_PUBLIC void setPickColor(const Ogre::ColourValue & color); diff --git a/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp b/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp index 6505313c6..aa79ebfbb 100644 --- a/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp +++ b/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp @@ -455,6 +455,14 @@ void PointCloud::setAlpha(float alpha, bool per_point_alpha) } } +void PointCloud::setColor(const Ogre::ColourValue & color) +{ + for(auto & point : points_) { + point.setColor(color.r, color.g, color.b, color.a); + } + regenerateAll(); +} + void PointCloud::addPoints( std::vector::iterator start_iterator, std::vector::iterator stop_iterator) From 930df37538faa195e6b18709047c58318efb0ae1 Mon Sep 17 00:00:00 2001 From: Andreas Greimel Date: Mon, 16 Jul 2018 09:26:45 +0200 Subject: [PATCH 4/5] Fix uncrustify in PointCloud --- rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp b/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp index aa79ebfbb..28387b01b 100644 --- a/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp +++ b/rviz_rendering/src/rviz_rendering/objects/point_cloud.cpp @@ -457,7 +457,7 @@ void PointCloud::setAlpha(float alpha, bool per_point_alpha) void PointCloud::setColor(const Ogre::ColourValue & color) { - for(auto & point : points_) { + for (auto & point : points_) { point.setColor(color.r, color.g, color.b, color.a); } regenerateAll(); From a33cef4985e8464b201e8c0879a0d7634d8032af Mon Sep 17 00:00:00 2001 From: Andreas Greimel Date: Mon, 16 Jul 2018 12:22:05 +0200 Subject: [PATCH 5/5] Use different sleeping mechanism in publisher to prevent blocking Use std::this_thread::sleep_for() instead of rclcpp::WallRate::sleep_for() --- .../rviz_visual_testing_framework/visual_test_publisher.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_publisher.hpp b/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_publisher.hpp index 909503b4b..6f4bee903 100644 --- a/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_publisher.hpp +++ b/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_publisher.hpp @@ -30,6 +30,7 @@ #ifndef RVIZ_VISUAL_TESTING_FRAMEWORK__VISUAL_TEST_PUBLISHER_HPP_ #define RVIZ_VISUAL_TESTING_FRAMEWORK__VISUAL_TEST_PUBLISHER_HPP_ +#include #include #include #include @@ -86,7 +87,6 @@ class VisualTestPublisher auto transformer_publisher_node = std::make_shared("static_transform_publisher"); tf2_ros::StaticTransformBroadcaster broadcaster(transformer_publisher_node); - rclcpp::WallRate loop_rate(0.2); rclcpp::executors::SingleThreadedExecutor executor; executor.add_node(transformer_publisher_node); @@ -101,7 +101,7 @@ class VisualTestPublisher broadcaster.sendTransform(msg); } executor.spin_some(); - loop_rate.sleep(); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); } }