95 std::vector<Request> requests;
96 requests.reserve(
static_cast<std::size_t
>(count));
98 std::uniform_real_distribution<float> yawDistribution{-M_PIf32, M_PIf32};
106 std::vector<NamedPose> reachable;
109 const Eigen::Vector2f position =
location.pose.translation().head<2>();
110 const auto clearance = costmap.
value(position);
112 if (clearance.has_value() and clearance.value() > 0.F)
119 <<
"` is inside an obstacle for a robot of this radius; "
120 "excluded from the location category.";
124 if (reachable.size() < 2)
126 ARMARX_WARNING <<
"Fewer than two reachable named locations; skipping this "
131 std::uniform_int_distribution<std::size_t> pick{0, reachable.size() - 1};
135 std::size_t from = pick(rng);
136 std::size_t to = pick(rng);
137 for (
int attempt = 0; attempt < parameters.
maxAttempts and to == from; attempt++)
144 requests.push_back({.kind = kind,
146 .start = reachable.at(from).pose,
147 .goal = reachable.at(to).pose,
148 .startName = reachable.at(from).name,
149 .goalName = reachable.at(to).name});
159 ARMARX_WARNING <<
"No corridor in this scene; skipping the corridor-exit "
164 const auto& corridor = room.
corridor.value();
170 std::vector<Eigen::Vector2f> inside;
171 std::vector<Eigen::Vector2f> outside;
173 for (
int ix = 0; ix < costmap.
getGrid().rows(); ix++)
175 for (
int iy = 0; iy < costmap.
getGrid().cols(); iy++)
189 else if (p.y() > corridor.max.y() + 500.F)
193 outside.push_back(p);
198 if (inside.empty() or outside.empty())
200 ARMARX_WARNING <<
"Corridor holds " << inside.size() <<
" free cell(s) and "
202 <<
" outside it; a robot of this radius does not fit. Skipping "
203 "the corridor-exit category.";
207 ARMARX_INFO <<
"corridor_exit: " << inside.size() <<
" cells inside the corridor, "
208 << outside.size() <<
" outside.";
210 std::uniform_int_distribution<std::size_t> pickInside{0, inside.size() - 1};
211 std::uniform_int_distribution<std::size_t> pickOutside{0, outside.size() - 1};
215 const Eigen::Vector2f start = inside.at(pickInside(rng));
216 const Eigen::Vector2f goal = outside.at(pickOutside(rng));
220 const float startYaw = std::atan2(goal.y() - start.y(), goal.x() - start.x());
222 requests.push_back({.kind = kind,
224 .start = poseAt(start, startYaw),
225 .goal = poseAt(goal, yawDistribution(rng)),
236 : std::numeric_limits<float>::max();
238 const std::vector<Eigen::Vector2f> cells = collectCells(costmap,
lo,
hi);
240 if (cells.size() < 2)
242 ARMARX_WARNING <<
"Only " << cells.size() <<
" cell(s) in the clearance band [" <<
lo
243 <<
", " <<
hi <<
"] mm; skipping the " <<
toString(kind) <<
" category.";
248 <<
" cells with clearance in [" <<
lo <<
", " <<
hi <<
"] mm.";
250 std::uniform_int_distribution<std::size_t> pick{0, cells.size() - 1};
256 for (
int attempt = 0; attempt < parameters.
maxAttempts and not found; attempt++)
258 const Eigen::Vector2f start = cells.at(pick(rng));
259 const Eigen::Vector2f goal = cells.at(pick(rng));
266 requests.push_back({.kind = kind,
268 .start = poseAt(start, yawDistribution(rng)),
269 .goal = poseAt(goal, yawDistribution(rng)),
std::vector< Request > sampleRequests(const RequestKind kind, const int count, const algorithms::Costmap &costmap, const RoomScene &room, const SamplingParameters ¶meters, std::mt19937 &rng)
Draw count requests of the given kind.