Skip to content

Commit

Permalink
Fixing issue with obstacle during play state
Browse files Browse the repository at this point in the history
  • Loading branch information
rishiso committed Nov 6, 2023
1 parent 62c9f46 commit a4a8f14
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions soccer/src/soccer/planning/planner/plan_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,19 @@ void fill_obstacles(const PlanRequest& in, rj_geometry::ShapeSet* out_static,
}

// Adding ball as a static obstacle (because dynamic obstacles are not working)
double ball_vel = in.world_state->ball.velocity.mag();
out_static->add(std::make_shared<rj_geometry::Circle>(
in.world_state->ball.position, kBallRadius * (1.0 + ball_vel) + in.min_dist_from_ball));
double ball_vel_scaled = in.world_state->ball.velocity.mag() * .1;
double radius = kBallRadius + in.min_dist_from_ball * (1.0 + ball_vel_scaled);
if (in.min_dist_from_ball > 0) {
out_static->add(std::make_shared<rj_geometry::Circle>(
in.world_state->ball.position, radius));
}

// Finally, add the ball as a dynamic obstacle.
// (This is for when the other team is trying to do ball placement, so we
// don't interfere with them.)
if (avoid_ball && out_dynamic != nullptr && out_ball_trajectory != nullptr) {
// Where should we store the ball trajectory?
*out_ball_trajectory = in.world_state->ball.make_trajectory();
double radius = kBallRadius * (1.0 + ball_vel) + in.min_dist_from_ball;

out_dynamic->emplace_back(radius, out_ball_trajectory);

if (in.debug_drawer != nullptr) {
Expand Down

0 comments on commit a4a8f14

Please sign in to comment.