Skip to content
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
16 changes: 10 additions & 6 deletions src/rj_strategy/src/agent/position/free_kicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ std::optional<RobotIntent> FreeKicker::derived_get_task(RobotIntent intent) {

double ball_width_offset = 0.025;
rj_geometry::Point const right_goal_post =
this->field_dimensions_.their_goal_loc() + rj_geometry::Point((this->field_dimensions_.goal_width() / 2.0) - ball_width_offset, 0.0);

this->field_dimensions_.their_goal_loc() +
rj_geometry::Point((this->field_dimensions_.goal_width() / 2.0) - ball_width_offset, 0.0);

rj_geometry::Point const left_goal_post =
this->field_dimensions_.their_goal_loc() - rj_geometry::Point((this->field_dimensions_.goal_width() / 2.0) - ball_width_offset, 0.0);
this->field_dimensions_.their_goal_loc() -
rj_geometry::Point((this->field_dimensions_.goal_width() / 2.0) - ball_width_offset, 0.0);

rj_geometry::Point best_shot = right_goal_post;
double best_distance = -1.0;
Expand All @@ -40,16 +42,18 @@ std::optional<RobotIntent> FreeKicker::derived_get_task(RobotIntent intent) {
double t = i / static_cast<double>(num_samples - 1);
rj_geometry::Point shot_target = left_goal_post + (right_goal_post - left_goal_post) * t;

double distance = std::abs((enemy_goalie_location - ball_position).cross(shot_target - ball_position)) /
(shot_target - ball_position).mag();
double distance =
std::abs((enemy_goalie_location - ball_position).cross(shot_target - ball_position)) /
(shot_target - ball_position).mag();

if (distance > best_distance) {
best_distance = distance;
best_shot = shot_target;
}
}

SPDLOG_INFO("Free Kicker {} shooting at point {}, {}", this->robot_id_, best_shot.x(), best_shot.y());
SPDLOG_INFO("Free Kicker {} shooting at point {}, {}", this->robot_id_, best_shot.x(),
best_shot.y());

planning::LinearMotionInstant target{best_shot};
auto line_kick_cmd = planning::MotionCommand{"line_kick", target};
Expand Down