| 3 | using namespace mocka; |
| 4 | |
| 5 | void |
| 6 | Maps::randomMapGenerate() |
| 7 | { |
| 8 | |
| 9 | std::default_random_engine eng(info.seed); |
| 10 | |
| 11 | double _resolution = 1 / info.scale; |
| 12 | |
| 13 | double _x_l = -info.sizeX / (2 * info.scale); |
| 14 | double _x_h = info.sizeX / (2 * info.scale); |
| 15 | double _y_l = -info.sizeY / (2 * info.scale); |
| 16 | double _y_h = info.sizeY / (2 * info.scale); |
| 17 | double _h_l = 0; |
| 18 | double _h_h = info.sizeZ / info.scale; |
| 19 | |
| 20 | std::uniform_real_distribution<double> rand_x; |
| 21 | std::uniform_real_distribution<double> rand_y; |
| 22 | std::uniform_real_distribution<double> rand_w; |
| 23 | std::uniform_real_distribution<double> rand_h; |
| 24 | |
| 25 | pcl::PointXYZ pt_random; |
| 26 | |
| 27 | rand_x = std::uniform_real_distribution<double>(_x_l, _x_h); |
| 28 | rand_y = std::uniform_real_distribution<double>(_y_l, _y_h); |
| 29 | rand_w = std::uniform_real_distribution<double>(_w_l, _w_h); |
| 30 | rand_h = std::uniform_real_distribution<double>(_h_l, _h_h); |
| 31 | |
| 32 | for (int i = 0; i < _ObsNum; i++) |
| 33 | { |
| 34 | double x, y; |
| 35 | x = rand_x(eng); |
| 36 | y = rand_y(eng); |
| 37 | |
| 38 | double w, h; |
| 39 | w = rand_w(eng); |
| 40 | h = rand_h(eng); |
| 41 | |
| 42 | int widNum = ceil(w / _resolution); |
| 43 | int heiNum = ceil(h / _resolution); |
| 44 | |
| 45 | int rl, rh, sl, sh; |
| 46 | rl = -widNum / 2; |
| 47 | rh = widNum / 2; |
| 48 | sl = -widNum / 2; |
| 49 | sh = widNum / 2; |
| 50 | |
| 51 | for (int r = rl; r < rh; r++) |
| 52 | for (int s = sl; s < sh; s++) |
| 53 | { |
| 54 | for (int t = 0; t < heiNum; t++) |
| 55 | { |
| 56 | if ((r - rl) * (r - rh + 1) * (s - sl) * (s - sh + 1) * t * |
| 57 | (t - heiNum + 1) == |
| 58 | 0) |
| 59 | { |
| 60 | pt_random.x = x + r * _resolution; |
| 61 | pt_random.y = y + s * _resolution; |
| 62 | pt_random.z = t * _resolution; |