MCPcopy Create free account
hub / github.com/ANYbotics/grid_map / demoSlidingWindowIterator

Method demoSlidingWindowIterator

grid_map_demos/src/IteratorsDemo.cpp:216–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void IteratorsDemo::demoSlidingWindowIterator()
217{
218 ROS_INFO("Running sliding window iterator demo.");
219 demoPolygonIterator(true);
220 publish();
221 const size_t windowSize = 3;
222 const grid_map::SlidingWindowIterator::EdgeHandling edgeHandling = grid_map::SlidingWindowIterator::EdgeHandling::CROP;
223 map_.add("copy", map_["type"]);
224
225 for (grid_map::SlidingWindowIterator iterator(map_, "copy", edgeHandling, windowSize);
226 !iterator.isPastEnd(); ++iterator) {
227 map_.at("type", *iterator) = iterator.getData().meanOfFinites(); // Blurring.
228 publish();
229
230 // Visualize sliding window as polygon.
231 grid_map::Polygon polygon;
232 Position center;
233 map_.getPosition(*iterator, center);
234 const Length windowHalfLength(Length::Constant(0.5 * (double) windowSize * map_.getResolution()));
235 polygon.addVertex(center + (Eigen::Array2d(-1.0,-1.0) * windowHalfLength).matrix());
236 polygon.addVertex(center + (Eigen::Array2d(-1.0, 1.0) * windowHalfLength).matrix());
237 polygon.addVertex(center + (Eigen::Array2d( 1.0, 1.0) * windowHalfLength).matrix());
238 polygon.addVertex(center + (Eigen::Array2d( 1.0,-1.0) * windowHalfLength).matrix());
239 polygon.setFrameId(map_.getFrameId());
240 geometry_msgs::PolygonStamped message;
241 grid_map::PolygonRosConverter::toMessage(polygon, message);
242 polygonPublisher_.publish(message);
243
244 ros::Duration duration(0.02);
245 duration.sleep();
246 }
247}
248
249void IteratorsDemo::publish()
250{

Callers

nothing calls this directly

Calls 9

atMethod · 0.80
getDataMethod · 0.80
getPositionMethod · 0.80
addVertexMethod · 0.80
addMethod · 0.45
isPastEndMethod · 0.45
getResolutionMethod · 0.45
setFrameIdMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected