| 173 | } |
| 174 | |
| 175 | void IteratorsDemo::demoPolygonIterator(const bool prepareForOtherDemos) |
| 176 | { |
| 177 | ROS_INFO("Running polygon iterator demo."); |
| 178 | map_.clearAll(); |
| 179 | if (prepareForOtherDemos) map_["type"].setZero(); |
| 180 | publish(); |
| 181 | |
| 182 | grid_map::Polygon polygon; |
| 183 | polygon.setFrameId(map_.getFrameId()); |
| 184 | polygon.addVertex(Position( 0.480, 0.000)); |
| 185 | polygon.addVertex(Position( 0.164, 0.155)); |
| 186 | polygon.addVertex(Position( 0.116, 0.500)); |
| 187 | polygon.addVertex(Position(-0.133, 0.250)); |
| 188 | polygon.addVertex(Position(-0.480, 0.399)); |
| 189 | polygon.addVertex(Position(-0.316, 0.000)); |
| 190 | polygon.addVertex(Position(-0.480, -0.399)); |
| 191 | polygon.addVertex(Position(-0.133, -0.250)); |
| 192 | polygon.addVertex(Position( 0.116, -0.500)); |
| 193 | polygon.addVertex(Position( 0.164, -0.155)); |
| 194 | polygon.addVertex(Position( 0.480, 0.000)); |
| 195 | |
| 196 | geometry_msgs::PolygonStamped message; |
| 197 | grid_map::PolygonRosConverter::toMessage(polygon, message); |
| 198 | polygonPublisher_.publish(message); |
| 199 | |
| 200 | for (grid_map::PolygonIterator iterator(map_, polygon); |
| 201 | !iterator.isPastEnd(); ++iterator) { |
| 202 | map_.at("type", *iterator) = 1.0; |
| 203 | if (!prepareForOtherDemos) { |
| 204 | publish(); |
| 205 | ros::Duration duration(0.02); |
| 206 | duration.sleep(); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (!prepareForOtherDemos) { |
| 211 | ros::Duration duration(1.0); |
| 212 | duration.sleep(); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | void IteratorsDemo::demoSlidingWindowIterator() |
| 217 | { |