From 159f0fffcba95829386977ad95d120ff6cd5b1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasper=20G=C3=BCldenstein?= Date: Wed, 14 Feb 2018 15:56:46 +0100 Subject: [PATCH 1/3] added a boolean property to the wrench visualization to make hiding small forces/torques optional --- src/rviz/default_plugin/wrench_display.cpp | 22 +++++++++++++++------- src/rviz/default_plugin/wrench_display.h | 3 ++- src/rviz/default_plugin/wrench_visual.cpp | 14 +++++++++++--- src/rviz/default_plugin/wrench_visual.h | 2 ++ 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/rviz/default_plugin/wrench_display.cpp b/src/rviz/default_plugin/wrench_display.cpp index 8767540ba9..ad4482748b 100644 --- a/src/rviz/default_plugin/wrench_display.cpp +++ b/src/rviz/default_plugin/wrench_display.cpp @@ -23,32 +23,32 @@ WrenchStampedDisplay::WrenchStampedDisplay() force_color_property_ = new rviz::ColorProperty( "Force Color", QColor( 204, 51, 51 ), "Color to draw the force arrows.", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); torque_color_property_ = new rviz::ColorProperty( "Torque Color", QColor( 204, 204, 51), "Color to draw the torque arrows.", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); alpha_property_ = new rviz::FloatProperty( "Alpha", 1.0, "0 is fully transparent, 1.0 is fully opaque.", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); force_scale_property_ = new rviz::FloatProperty( "Force Arrow Scale", 2.0, "force arrow scale", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); torque_scale_property_ = new rviz::FloatProperty( "Torque Arrow Scale", 2.0, "torque arrow scale", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); width_property_ = new rviz::FloatProperty( "Arrow Width", 0.5, "arrow width", - this, SLOT( updateColorAndAlpha() )); + this, SLOT( updateProperties() )); history_length_property_ = @@ -56,6 +56,11 @@ WrenchStampedDisplay::WrenchStampedDisplay() "Number of prior measurements to display.", this, SLOT( updateHistoryLength() )); + hide_small_values_property_ = + new rviz::BoolProperty( "Hide Small Values", true, + "Hide small values", + this, SLOT( updateProperties() )); + history_length_property_->setMin( 1 ); history_length_property_->setMax( 100000 ); } @@ -77,12 +82,13 @@ void WrenchStampedDisplay::reset() visuals_.clear(); } -void WrenchStampedDisplay::updateColorAndAlpha() +void WrenchStampedDisplay::updateProperties() { float alpha = alpha_property_->getFloat(); float force_scale = force_scale_property_->getFloat(); float torque_scale = torque_scale_property_->getFloat(); float width = width_property_->getFloat(); + bool hide_small_values = hide_small_values_property_->getBool(); Ogre::ColourValue force_color = force_color_property_->getOgreColor(); Ogre::ColourValue torque_color = torque_color_property_->getOgreColor(); @@ -93,6 +99,7 @@ void WrenchStampedDisplay::updateColorAndAlpha() visuals_[i]->setForceScale( force_scale ); visuals_[i]->setTorqueScale( torque_scale ); visuals_[i]->setWidth( width ); + visuals_[i]->setHideSmallValues( hide_small_values ); } } @@ -102,6 +109,7 @@ void WrenchStampedDisplay::updateHistoryLength() visuals_.rset_capacity(history_length_property_->getInt()); } + bool validateFloats( const geometry_msgs::WrenchStamped& msg ) { return rviz::validateFloats(msg.wrench.force) && rviz::validateFloats(msg.wrench.torque) ; diff --git a/src/rviz/default_plugin/wrench_display.h b/src/rviz/default_plugin/wrench_display.h index 23514a8d55..09daaa0e46 100644 --- a/src/rviz/default_plugin/wrench_display.h +++ b/src/rviz/default_plugin/wrench_display.h @@ -42,7 +42,7 @@ class WrenchStampedDisplay: public rviz::MessageFilterDisplay width_); - bool show_torque = (torque_length > width_); + // hide markers if they get too short and hide_small_values_ is activated + // "too short" is defined as "force_length > width_" + bool show_force = (force_length > width_) || !hide_small_values_; + bool show_torque = (torque_length > width_) || !hide_small_values_; + if (show_force) { arrow_force_->setScale(Ogre::Vector3(force_length, width_, width_)); arrow_force_->setDirection(force); @@ -131,6 +133,12 @@ void WrenchVisual::setWidth( float w ) width_ = w; } +void WrenchVisual::setHideSmallValues( bool h ) +{ + hide_small_values_ = h; +} + + void WrenchVisual::setVisible(bool visible) { frame_node_->setVisible(visible); diff --git a/src/rviz/default_plugin/wrench_visual.h b/src/rviz/default_plugin/wrench_visual.h index c6c5df6fcf..cf85c9e926 100644 --- a/src/rviz/default_plugin/wrench_visual.h +++ b/src/rviz/default_plugin/wrench_visual.h @@ -53,6 +53,7 @@ class WrenchVisual void setForceScale( float s ); void setTorqueScale( float s ); void setWidth( float w ); + void setHideSmallValues(bool h); void setVisible( bool visible ); private: @@ -62,6 +63,7 @@ class WrenchVisual rviz::BillboardLine* circle_torque_; rviz::Arrow* circle_arrow_torque_; float force_scale_, torque_scale_, width_; + bool hide_small_values_; // A SceneNode whose pose is set to match the coordinate frame of // the WrenchStamped message header. From 7d243fa6140978391b120489969412c24c8d842a Mon Sep 17 00:00:00 2001 From: dhood Date: Fri, 6 Apr 2018 18:16:48 -0700 Subject: [PATCH 2/3] update doc text --- src/rviz/default_plugin/wrench_display.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rviz/default_plugin/wrench_display.h b/src/rviz/default_plugin/wrench_display.h index 09daaa0e46..2c95e5d1aa 100644 --- a/src/rviz/default_plugin/wrench_display.h +++ b/src/rviz/default_plugin/wrench_display.h @@ -41,7 +41,7 @@ class WrenchStampedDisplay: public rviz::MessageFilterDisplay Date: Fri, 6 Apr 2018 18:17:40 -0700 Subject: [PATCH 3/3] whitespace fixup --- src/rviz/default_plugin/wrench_visual.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rviz/default_plugin/wrench_visual.h b/src/rviz/default_plugin/wrench_visual.h index cf85c9e926..6fe741fe3a 100644 --- a/src/rviz/default_plugin/wrench_visual.h +++ b/src/rviz/default_plugin/wrench_visual.h @@ -53,7 +53,7 @@ class WrenchVisual void setForceScale( float s ); void setTorqueScale( float s ); void setWidth( float w ); - void setHideSmallValues(bool h); + void setHideSmallValues( bool h ); void setVisible( bool visible ); private: