Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Code Style On has-open-shot #2179

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions soccer/src/soccer/strategy/agent/position/offense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ std::optional<RobotIntent> Offense::state_to_task(RobotIntent intent) {
}

bool Offense::has_open_shot() {

// Goal location
rj_geometry::Point their_goal_pos = field_dimensions_.their_goal_loc();
double goal_width = field_dimensions_.goal_width(); // 1.0 meters
double goal_width = field_dimensions_.goal_width(); // 1.0 meters

// Ball location
rj_geometry::Point ball_position = this->last_world_state_->ball.position;

double best_distance = -1.0;
rj_geometry::Point increment(0.05, 0);
rj_geometry::Point curr_point = their_goal_pos - rj_geometry::Point(goal_width / 2.0, 0) + increment;
rj_geometry::Point curr_point =
their_goal_pos - rj_geometry::Point(goal_width / 2.0, 0) + increment;
for (int i = 0; i < 19; i++) {
double distance = distance_from_their_robots(ball_position, curr_point);
if (distance > best_distance) {
Expand All @@ -226,19 +226,19 @@ double Offense::distance_from_their_robots(rj_geometry::Point tail, rj_geometry:
double min_angle = -0.5;
for (auto enemy : their_robots) {
rj_geometry::Point enemy_vec = enemy.pose.position() - tail;
if (enemy_vec.dot(vec) < 0 ) {
if (enemy_vec.dot(vec) < 0) {
continue;
}
auto projection = (enemy_vec.dot(vec)/vec.dot(vec));
enemy_vec = enemy_vec - (projection) * vec;
auto projection = (enemy_vec.dot(vec) / vec.dot(vec));
enemy_vec = enemy_vec - (projection)*vec;
double distance = enemy_vec.mag();
if (distance < (kRobotRadius + kBallRadius)) {
return -1.0;
}
double angle = distance / projection;
if (min_angle < 0) {
min_angle = angle;
} else if(angle < min_angle) {
} else if (angle < min_angle) {
min_angle = angle;
}
}
Expand Down