Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added regex filter field for TF display #1744

Merged
merged 11 commits into from
Mar 29, 2023

Conversation

bpotokar
Copy link
Contributor

Description

When there is a lot of frames on /tf it can be hard to properly visualize them in RViz especially if frames overlap. Usually solution to this is to enable and disable desired frames in Frames field of the TF display. But it quickly become very annoying task if there is a lot of frames (e.g. 100 +) and each one needs to be found in a long list first and then disabled/enabled.

Because of that I suggest adding regex field which filters frames and displays only the ones matching entered expression. For convenience I also suggest adding additional field for blacklist filter.
Benefit of this approach is that user can quickly setup one or more displays, each showing specific group of frames and he can turn each one on/off as needed.
Scene with a lot of frames ...
image
... can be easily filtered so only interesting frames are displayed
image

Example when multiple TF displays are added. Each one has its own settings and frame filter.
image

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Please consider my comments.

@@ -40,6 +41,7 @@
#include "rviz/ogre_helpers/axes.h"
#include "rviz/ogre_helpers/movable_text.h"
#include "rviz/properties/bool_property.h"
#include "rviz/properties/color_property.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to add ColorProperty?

Comment on lines 185 to 187
filter_property_ = new StringProperty("Filter", ".*", "Regex filter", this);

filter_blacklist_property_ = new StringProperty("Filter (blacklist)", "", "Regex filter", this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving these properties as children of frames_category_. This makes it clear, where the filters are applied to. However, it makes the property harder to discover. What do you think?
Please rename "Filter" -> "Filter (whitelist)".

@@ -372,22 +377,34 @@ void TFDisplay::updateFrames()
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

context_->getTFClient()->getFrameStrings(frames);
context_->getTFClient()->getFrameStrings(frames);

#ifndef _WIN32
#pragma GCC diagnostic pop
#endif
std::sort(frames.begin(), frames.end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest filtering frame names before sorting them (for efficiency).

Comment on lines 403 to 404
if (!blacklist_regex_string.empty())
if (std::regex_match(frame, blacklist_regex))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer logical AND over nested IF:

Suggested change
if (!blacklist_regex_string.empty())
if (std::regex_match(frame, blacklist_regex))
if (!blacklist_regex_string.empty()) && std::regex_match(frame, blacklist_regex))

Comment on lines 727 to 745
delete frame->tree_property_;
// delete frame->tree_property_; // Here happens segmentation fault. With skipping deletinion, memory leak
// appears but is not significant and only happens when user changes fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be fixed!

@@ -119,7 +119,8 @@ private Q_SLOTS:
BoolProperty* all_enabled_property_;

FloatProperty* scale_property_;

StringProperty* filter_property_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename:

Suggested change
StringProperty* filter_property_;
StringProperty* filter_whitelist_property_;

@rhaschke
Copy link
Contributor

rhaschke commented Aug 1, 2022

@BlazPotokar, do you plan to fix the remaining issues and finish this PR?

Blaz Potokar and others added 6 commits August 17, 2022 23:23
Move items to the end instead.
The segfault occured due to an attempt to delete frame->tree_property_ twice,
because it was deleted previously with a parent frame.
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were several open issues, which I now resolved:

  • segfault when recurrently removing frames from tree view
  • missing error handling
  • inefficient filtering (erasing std::vector elements requires copying all remaining ones)

@rhaschke
Copy link
Contributor

rhaschke commented Mar 29, 2023

I will handle remaining issues in separate commits: #1789

@rhaschke rhaschke merged commit 9450f78 into ros-visualization:melodic-devel Mar 29, 2023
@bpotokar
Copy link
Contributor Author

Thank you so much for resolving the remaining issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants