Skip to content

Commit

Permalink
Add support for namespace-scoped DELETEALL action in Marker displays. (
Browse files Browse the repository at this point in the history
…ros-visualization#685)

Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored May 13, 2021
1 parent f810163 commit f61c164
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
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

0 comments on commit f61c164

Please sign in to comment.