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

Add support for namespace-scoped DELETEALL action in Marker displays. #685

Merged
merged 2 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ void MarkerCommon::processMessage(const visualization_msgs::msg::Marker::ConstSh
break;

case visualization_msgs::msg::Marker::DELETEALL:
deleteAllMarkers();
if (!message->ns.empty()) {
deleteMarkersInNamespace(message->ns);
} else {
deleteAllMarkers();
}
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ visualization_msgs::msg::Marker::SharedPtr createSharedPtrMessage(
return std::make_shared<visualization_msgs::msg::Marker>(marker);
}

visualization_msgs::msg::Marker::SharedPtr createSharedPtrMessage(
int32_t action, int32_t type, const std::string & ns)
{
auto marker = createSharedPtrMessage(action, type);
marker->ns = ns;
return marker;
}

visualization_msgs::msg::Marker::SharedPtr createSharedPtrMessage(
int32_t action, const std::string & ns)
{
return createSharedPtrMessage(action, -1, ns);
}

TEST_F(MarkerCommonFixture, processMessage_creates_correct_marker_on_add_type) {
mockValidTransform();

Expand Down Expand Up @@ -125,6 +139,30 @@ TEST_F(MarkerCommonFixture, processMessage_deletes_correct_marker_on_delete_type
ASSERT_TRUE(rviz_default_plugins::findOnePointCloud(scene_manager_->getRootSceneNode()));
}

TEST_F(MarkerCommonFixture, processMessage_with_scoped_deleteall_deletes_correct_markers) {
mockValidTransform();

common_->processMessage(
createSharedPtrMessage(
visualization_msgs::msg::Marker::ADD,
visualization_msgs::msg::Marker::TEXT_VIEW_FACING,
"ns_a"));

common_->processMessage(
createSharedPtrMessage(
visualization_msgs::msg::Marker::ADD,
visualization_msgs::msg::Marker::POINTS,
"ns_b"));

common_->processMessage(
createSharedPtrMessage(
visualization_msgs::msg::Marker::DELETEALL,
"ns_a"));

ASSERT_FALSE(rviz_default_plugins::findOneMovableText(scene_manager_->getRootSceneNode()));
ASSERT_TRUE(rviz_default_plugins::findOnePointCloud(scene_manager_->getRootSceneNode()));
}

TEST_F(MarkerCommonFixture, processMessage_with_deleteall_deletes_all_markers) {
mockValidTransform();

Expand Down