# This represents a 2-D grid map std_msgs/Header header builtin_interfaces/Time stamp int32 sec uint32 nanosec string frame_id
# MetaData for the map MapMetaData info builtin_interfaces/Time map_load_time int32 sec uint32 nanosec float32 resolution uint32 width uint32 height geometry_msgs/Pose origin Point position float64 x float64 y float64 z Quaternion orientation float64 x 0 float64 y 0 float64 z 0 float64 w 1
# The map data, in row-major order, starting with (0,0). # Cell (1, 0) will be listed second, representing the next cell in the x direction. # Cell (0, 1) will be at the index equal to info.width, followed by (1, 1). # The values inside are application dependent, but frequently, # 0 represents unoccupied, 1 represents definitely occupied, and # -1 represents unknown. int8[] data
std::vector<Magick::Quantum> channels = {pixel.redQuantum(), pixel.greenQuantum(), pixel.blueQuantum()}; if (load_parameters.mode == MapMode::Trinary && img.matte()) { // To preserve existing behavior, average in alpha with color channels in Trinary mode. // CAREFUL. alpha is inverted from what you might expect. High = transparent, low = opaque channels.push_back(MaxRGB - pixel.alphaQuantum()); } double sum = 0; for (auto c : channels) { sum += c; } /// on a scale from 0.0 to 1.0 how bright is the pixel? double shade = Magick::ColorGray::scaleQuantumToDouble(sum / channels.size());
// If negate is true, we consider blacker pixels free, and whiter // pixels occupied. Otherwise, it's vice versa. /// on a scale from 0.0 to 1.0, how occupied is the map cell (before thresholding)? double occ = (load_parameters.negate ? shade : 1.0 - shade);