Skip to content

Commit

Permalink
Fix Code Style On best-shot (#2171)
Browse files Browse the repository at this point in the history
automated style fixes

Co-authored-by: sid-parikh <[email protected]>
  • Loading branch information
github-actions[bot] and sid-parikh committed Feb 1, 2024
1 parent bc303c9 commit b56bd3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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 @@ -414,18 +414,18 @@ void Offense::derived_acknowledge_ball_in_transit() {
}

rj_geometry::Point Offense::calculate_best_shot() {

// Goal location
rj_geometry::Point their_goal_pos = field_dimensions_.our_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;

rj_geometry::Point best_shot = their_goal_pos;
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 @@ -443,19 +443,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) {

Check warning on line 456 in soccer/src/soccer/strategy/agent/position/offense.cpp

View workflow job for this annotation

GitHub Actions / build-and-test

repeated branch in conditional chain
min_angle = angle;
} else if(angle < min_angle) {
} else if (angle < min_angle) {
min_angle = angle;
}
}
Expand Down
4 changes: 2 additions & 2 deletions soccer/src/soccer/strategy/agent/position/offense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ class Offense : public Position {

/**
* @brief Calcualtes the best location for a shot
*/
*/
rj_geometry::Point calculate_best_shot();

/**
* @brief Calculates the distance of vector from other team's closest robot
*/
*/
double distance_from_their_robots(rj_geometry::Point tail, rj_geometry::Point heaad);

Check failure on line 126 in soccer/src/soccer/strategy/agent/position/offense.hpp

View workflow job for this annotation

GitHub Actions / build-and-test

class member cannot be redeclared

Check failure on line 126 in soccer/src/soccer/strategy/agent/position/offense.hpp

View workflow job for this annotation

GitHub Actions / build-and-test

class member cannot be redeclared
};

Expand Down

0 comments on commit b56bd3e

Please sign in to comment.