Made goalie line up with ball and kicker in penalty#2469
Conversation
automated style fixes Co-authored-by: franklin-yuan <franklin-yuan@users.noreply.github.com>
| // return this->field_dimensions_.our_goal_loc(); | ||
| // be smart | ||
| // find robot on their team closest to ball | ||
| std::vector<RobotState> const their_robots = last_world_state_->their_robots; |
There was a problem hiding this comment.
No need to make a copy of their_robots. If you really want to keep this, make their_robots a reference.
| rj_geometry::Point enemy_location; | ||
| rj_geometry::Point enemy_shooter_location; |
There was a problem hiding this comment.
| rj_geometry::Point enemy_location; | |
| rj_geometry::Point enemy_shooter_location; |
| rj_geometry::Point enemy_shooter_location; | ||
|
|
||
| double closest_distance = std::numeric_limits<double>::infinity(); | ||
| RobotState curr_shooter; |
There was a problem hiding this comment.
curr_shooter can just store the enemy robot's position, no need to store the entire RobotState
|
|
||
| // SPDLOG_INFO("botpos {} {}", enemy_shooter_location.x(), enemy_shooter_location.y()); | ||
| // SPDLOG_INFO("ballpos {} {}", ball_pos.x(), ball_pos.y()); | ||
| // SPDLOG_INFO("GOALX {}", field_dimensions_.goal_width()); | ||
|
|
There was a problem hiding this comment.
| // SPDLOG_INFO("botpos {} {}", enemy_shooter_location.x(), enemy_shooter_location.y()); | |
| // SPDLOG_INFO("ballpos {} {}", ball_pos.x(), ball_pos.y()); | |
| // SPDLOG_INFO("GOALX {}", field_dimensions_.goal_width()); |
|
|
||
| // SPDLOG_INFO("enemy {}", goalie_pos_x); | ||
|
|
||
| rj_geometry::Point goaliepose = {goalie_pos_x, goalie_pos_y}; | ||
| return goaliepose; |
There was a problem hiding this comment.
| // SPDLOG_INFO("enemy {}", goalie_pos_x); | |
| rj_geometry::Point goaliepose = {goalie_pos_x, goalie_pos_y}; | |
| return goaliepose; | |
| rj_geometry::Point goalie_pos{goalie_pos_x, goalie_pos_y}; | |
| return goalie_pos; |
To keep consistent with other uses
| (ball_pos.x() - enemy_shooter_location.x())) / | ||
| (ball_pos.y() - enemy_shooter_location.y()); | ||
|
|
||
| goalie_pos_x = std::clamp(goalie_pos_x, -1 * field_dimensions_.goal_width() / 2, |
There was a problem hiding this comment.
Use the field_dimensions_.our_goal_segment() to make this easier for someone to understand
| // SPDLOG_INFO("GOALX {}", field_dimensions_.goal_width()); | ||
|
|
||
| double goalie_pos_y = field_dimensions_.our_goal_loc().y(); | ||
| float goalie_pos_x = |
There was a problem hiding this comment.
Nit: use the built-in intersect functions for this
| State latest_state_ = IDLING; | ||
|
|
||
| rj_geometry::Point penalty_location(); | ||
| rj_geometry::Point penalty_location(WorldState* world_state); |
There was a problem hiding this comment.
Nit: Consider passing in just the parts of the world_state you need instead of the entire thing
Description
Made goalie line up with the ball and the closest enemy robot to the ball
Associated / Resolved Issue
Resolves #86b6ubvaq or ClickUp card
Design Documents
Link
Steps to Test
Test Case 1
Setup penalty, set goalie state to penalty
Expected result:
Goalie should move automatically between ball and opposing kicker
Key Files to Review
Group 1
Group 2
Review Checklist
(Optional) Sub-issues (for drafts)
Note: if you find yourself breaking this PR into many smaller features, it may make sense to break up the PR into logical units based on these features.