ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rivz only visualizes polygon stamped topic if the frame id is the same as the rviz "Fixed Frame"

asked 2019-11-25 06:15:02 -0600

ThimoF gravatar image

updated 2019-11-25 06:25:20 -0600

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)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-11-27 08:22:04 -0600

ThimoF gravatar image

Found the problem! I was publishing the transforms using rostopic pub /tf but I did not add a proper timestamp which was causing problems

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-11-25 06:15:02 -0600

Seen: 1,080 times

Last updated: Nov 27 '19