rivz only visualizes polygon stamped topic if the frame id is the same as the rviz "Fixed Frame"
I made a function that is supposed to visualize a zone as a polygon:
void visualizeFilterZone(double minAngle, double maxAngle, double minDist, double maxDist, int resolution)
{
geometry_msgs::Polygon filterZone;
filterZone.points.reserve(resolution * 2);
double angleIncrement = (maxAngle - minAngle) / resolution;
// draw minDist arc
for (int i = 0; i <= resolution; i++)
{
geometry_msgs::Point32 point;
double angle = minAngle + i * angleIncrement;
point.x = minDist * cos(angle);
point.y = minDist * sin(angle);
point.z = 0;
filterZone.points.push_back(point);
}
// draw maxDist arc (opposite direction)
for (int i = resolution; i >= 0; i--)
{
geometry_msgs::Point32 point;
double angle = minAngle + i * angleIncrement;
point.x = maxDist * cos(angle);
point.y = maxDist * sin(angle);
point.z = 0;
filterZone.points.push_back(point);
}
geometry_msgs::PolygonStamped filterZoneStamped;
filterZoneStamped.polygon = filterZone;
filterZoneStamped.header.stamp = ros::Time::now();
filterZoneStamped.header.frame_id = mRefFrame;
mFilterZonePublisher.publish(filterZoneStamped);
}
When I create two frames, a and b, and I publish the transform, rviz correctly visualizes the tf tree. When I set frame a as fixed frame and visualize the polygon with mRefFrame = "a", the zone is shown correctly. But when I set mRefFrame to "b" the zone is not shown and no error or warning comes up. When I use rostopic echo the stamped polygon gets published with the given frame id. rviz is able to show the visualization markers published by the same node from any frame without problems. I have no idea what's going on here
Edit: Also when I keep mRefFrame equal to "a" but set the Fixed Frame in rviz to "b" the polygon is not shown. (but it is published)