MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/RACER / update

Method update

uav_simulator/Utils/rviz_plugins/src/probmap_display.cpp:219–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219void ProbMapDisplay::update(float wall_dt, float ros_dt) {
220 {
221 boost::mutex::scoped_lock lock(mutex_);
222
223 current_map_ = updated_map_;
224 }
225
226 if (!current_map_ || !new_map_) {
227 return;
228 }
229
230 if (current_map_->data.empty()) {
231 return;
232 }
233
234 new_map_ = false;
235
236 if (!validateFloats(*current_map_)) {
237 setStatus(StatusProperty::Error, "Map", "Message contained invalid floating point values (nans or "
238 "infs)");
239 return;
240 }
241
242 if (current_map_->info.width * current_map_->info.height == 0) {
243 std::stringstream ss;
244 ss << "Map is zero-sized (" << current_map_->info.width << "x" << current_map_->info.height << ")";
245 setStatus(StatusProperty::Error, "Map", QString::fromStdString(ss.str()));
246 return;
247 }
248
249 clear();
250
251 setStatus(StatusProperty::Ok, "Message", "Map received");
252
253 ROS_DEBUG("Received a %d X %d map @ %.3f m/pix\n", current_map_->info.width, current_map_->info.height,
254 current_map_->info.resolution);
255
256 float resolution = current_map_->info.resolution;
257
258 int width = current_map_->info.width;
259 int height = current_map_->info.height;
260
261 Ogre::Vector3 position(current_map_->info.origin.position.x, current_map_->info.origin.position.y,
262 current_map_->info.origin.position.z);
263 Ogre::Quaternion orientation(
264 current_map_->info.origin.orientation.w, current_map_->info.origin.orientation.x,
265 current_map_->info.origin.orientation.y, current_map_->info.origin.orientation.z);
266 frame_ = current_map_->header.frame_id;
267 if (frame_.empty()) {
268 frame_ = "/map";
269 }
270
271 // Expand it to be RGB data
272 unsigned int pixels_size = width * height;
273 unsigned char* pixels = new unsigned char[pixels_size];
274 memset(pixels, 255, pixels_size);
275
276 bool map_status_set = false;

Callers 1

map2d_callbackFunction · 0.45

Calls 6

validateFloatsFunction · 0.85
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected