Skip to content

Commit 914b32e

Browse files
committed
SlackTimeの計算で、パスの受取などを考慮
1 parent a652798 commit 914b32e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

utility/crane_msg_wrappers/src/world_model_wrapper.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,28 @@ auto WorldModelWrapper::getMinMaxSlackInterceptPointAndSlackTime(
406406
const double max_acc, const double max_vel, double distance_horizon)
407407
-> std::pair<std::optional<std::pair<Point, double>>, std::optional<std ::pair<Point, double>>>
408408
{
409-
auto ball_sequence = getBallSequence(t_horizon, t_step, ball.pos, ball.vel);
409+
std::vector<double> t_ball_sequence = generateSequence(0.0, t_horizon, t_step);
410+
std::vector<std::pair<Point, double>> ball_sequence;
411+
{
412+
std::optional<Point> intercepted_point = std::nullopt;
413+
for (auto t_ball : t_ball_sequence) {
414+
if (auto p_ball = getFutureBallPosition(ball.pos, ball.vel, t_ball); p_ball.has_value()) {
415+
auto [nearest_friend, friend_dist] =
416+
getNearestRobotWithDistanceFromPoint(p_ball.value(), ours.getAvailableRobots());
417+
auto [nearest_enemy, enemy_dist] =
418+
getNearestRobotWithDistanceFromPoint(p_ball.value(), theirs.getAvailableRobots());
419+
if (not intercepted_point and (friend_dist < 0.2 or enemy_dist < 0.2)) {
420+
intercepted_point = p_ball.value();
421+
}
422+
423+
if (intercepted_point) {
424+
ball_sequence.push_back({intercepted_point.value(), t_ball});
425+
} else {
426+
ball_sequence.push_back({p_ball.value(), t_ball});
427+
}
428+
}
429+
}
430+
}
410431
// ボールの位置とスラックタイムをペアにして計算
411432
auto slack_times = ball_sequence
412433
// distance_horizon以内のボールのみを抽出

0 commit comments

Comments
 (0)