Skip to content

Commit

Permalink
more fixes to ros-visualization#1275
Browse files Browse the repository at this point in the history
- invalid quaternion: issue warning only
- triangle list accepts points.size()/3 colors as well (face colors)
- don't create (empty) text marker for interactive marker control with empty description
  • Loading branch information
rhaschke committed Sep 9, 2019
1 parent 779cbe8 commit 0265125
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ bool InteractiveMarker::processMessage( const visualization_msgs::InteractiveMar
boost::make_shared<InteractiveMarkerControl>( context_,
reference_node_, this );

description_control_->processMessage( interactive_markers::makeTitle( message ));
if (!message.description.empty())
description_control_->processMessage( interactive_markers::makeTitle( message ));

//create menu
menu_entries_.clear();
Expand Down
14 changes: 8 additions & 6 deletions src/rviz/default_plugin/marker_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool checkMarkerMsg(const visualization_msgs::Marker& marker, MarkerDisplay* own
checkQuaternion(marker, ss, level);
checkScale(marker, ss, level);
checkPointsNotEmpty(marker, ss, level);
checkColors(marker, ss, level);
checkColors(marker, ss, level, marker.type == visualization_msgs::Marker::TRIANGLE_LIST ? 3 : 1);
checkTextEmpty(marker, ss, level);
checkMeshEmpty(marker, ss, level);
break;
Expand Down Expand Up @@ -272,14 +272,14 @@ void checkQuaternion(const visualization_msgs::Marker& marker, std::stringstream
marker.pose.orientation.w == 0.0)
{
addSeparatorIfRequired(ss);
ss << "Uninitialized quaternion assuming identity.";
ss << "Uninitialized quaternion, assuming identity.";
increaseWarningLevel(StatusProperty::Warn, level);
}
else if(!validateQuaternions(marker.pose))
{
addSeparatorIfRequired(ss);
ss << "Unnormalized quaternion in marker message.";
increaseWarningLevel(StatusProperty::Error, level);
increaseWarningLevel(StatusProperty::Warn, level);
}
}

Expand Down Expand Up @@ -338,12 +338,14 @@ void checkScaleText(const visualization_msgs::Marker& marker, std::stringstream&
ss << "Text height of TEXT_VIEW_FACING is 0.0 (scale.z).";
increaseWarningLevel(StatusProperty::Warn, level);
}
#if 0 // There is too much code out there, which sets all 3 axis scales
else if(marker.scale.x != 0.0 || marker.scale.y != 0.0)
{
addSeparatorIfRequired(ss);
ss << "scale.x and scale.y of TEXT_VIEW_FACING are ignored.";
increaseWarningLevel(StatusProperty::Warn, level);
}
#endif
}

void checkColor(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level)
Expand Down Expand Up @@ -416,17 +418,17 @@ void checkPointsEmpty(const visualization_msgs::Marker& marker, std::stringstrea
}
}

void checkColors(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level)
void checkColors(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level, unsigned int multiple)
{
if(marker.colors.size() == 0)
{
checkColor(marker, ss, level);
return;
}
if(marker.colors.size() != marker.points.size())
if(marker.colors.size() != marker.points.size() && (multiple == 1 || multiple * marker.colors.size() != marker.points.size()))
{
addSeparatorIfRequired(ss);
ss << "Number of colors is not equal to number of points or 0.";
ss << "Number of colors doesn't match number of points.";
increaseWarningLevel(StatusProperty::Error, level);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rviz/default_plugin/marker_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void checkPointsArrow(const visualization_msgs::Marker& marker, std::stringstrea
void checkPointsNotEmpty(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level);
void checkPointsEmpty(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level);

void checkColors(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level);
void checkColors(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level, unsigned int multiple = 1);
void checkColorsEmpty(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level);

void checkTextNotEmptyOrWhitespace(const visualization_msgs::Marker& marker, std::stringstream& ss, StatusProperty::Level& level);
Expand Down
8 changes: 4 additions & 4 deletions src/test/mesh_marker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ publishMesh(
marker.ns = "mesh";
if (mesh) {
marker.type = Marker::MESH_RESOURCE;
marker.mesh_resource = "package://rviz/src/test/meshes/pr2-base.dae";
marker.mesh_use_embedded_materials = use_embedded_materials;
} else {
marker.type = Marker::SPHERE;
}
marker.action = Marker::ADD;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.1;
marker.pose.orientation.w = 1.0;
marker.pose.orientation.z = 0.0995;
marker.pose.orientation.w = 0.995;
marker.scale.x = 1;
marker.scale.y = 1;
marker.scale.z = 1;
Expand All @@ -66,8 +68,6 @@ publishMesh(
marker.color.b = b;
marker.color.a = a;
marker.frame_locked = true;
marker.mesh_resource = "package://rviz/src/test/meshes/pr2-base.dae";
marker.mesh_use_embedded_materials = use_embedded_materials;
marker.id = id;
marker.pose.position.x = x;
marker.pose.position.y = y;
Expand Down

0 comments on commit 0265125

Please sign in to comment.