Skip to content

Commit

Permalink
Fix Code Style On settle-collect (#2321)
Browse files Browse the repository at this point in the history
automated style fixes

Co-authored-by: sanatd33 <[email protected]>
  • Loading branch information
github-actions[bot] and sanatd33 authored Jan 20, 2025
1 parent cd8ff84 commit 00e6ef9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
48 changes: 24 additions & 24 deletions soccer/src/soccer/planning/planner/collect_path_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ Trajectory CollectPathPlanner::plan(const PlanRequest& plan_request) {
case Intercept: {
Point delta_pos;
Point face_pos;

calc_delta_pos_for_dir(ball, start_instant, &delta_pos, &face_pos);
previous_ = intercept(plan_request, start_instant, static_obstacles, dynamic_obstacles, delta_pos, face_pos);
previous_ = intercept(plan_request, start_instant, static_obstacles, dynamic_obstacles,
delta_pos, face_pos);
break;
}
default:
previous_ = invalid(plan_request, static_obstacles, dynamic_obstacles);
break;
}


return previous_;
}

Expand All @@ -170,8 +170,8 @@ void CollectPathPlanner::check_solution_validity(BallState ball, RobotInstant st
}
}

void CollectPathPlanner::process_state_transition(const PlanRequest& request, BallState ball, RobotInstant start_instant) {

void CollectPathPlanner::process_state_transition(const PlanRequest& request, BallState ball,
RobotInstant start_instant) {
// If the ball is moving, intercept
// if not, regularly approach
if (current_state_ == CoarseApproach && average_ball_vel_.mag() > 0.2) {
Expand Down Expand Up @@ -243,14 +243,14 @@ Trajectory CollectPathPlanner::coarse_approach(
LinearMotionInstant target_slow{path_coarse_target_, target_slow_vel};

Replanner::PlanParams params{start,
target_slow,
static_obstacles,
dynamic_obstacles,
plan_request.field_dimensions,
plan_request.constraints,
AngleFns::face_point(ball.position),
plan_request.shell_id};
target_slow,
static_obstacles,
dynamic_obstacles,
plan_request.field_dimensions,
plan_request.constraints,
AngleFns::face_point(ball.position),
plan_request.shell_id};

Trajectory coarse_path = Replanner::create_plan(params, previous_);

if (plan_request.debug_drawer != nullptr) {
Expand All @@ -267,27 +267,27 @@ Trajectory CollectPathPlanner::coarse_approach(
}

void CollectPathPlanner::calc_delta_pos_for_dir(BallState ball, RobotInstant start_instant,

Check warning on line 269 in soccer/src/soccer/planning/planner/collect_path_planner.cpp

View workflow job for this annotation

GitHub Actions / build-and-test

method 'calc_delta_pos_for_dir' can be made static
rj_geometry::Point* delta_robot_pos,
rj_geometry::Point* face_pos) {
rj_geometry::Point* delta_robot_pos,
rj_geometry::Point* face_pos) {
// Get angle between target and normal hit
Point normal_face_vector = ball.position - start_instant.position();

// Since we loose the sign for the angle between call, there are two
// possibilities

*delta_robot_pos = Point(0, 0);
*face_pos = start_instant.position() +
Point::direction(normal_face_vector.angle()) * 10;
*face_pos = start_instant.position() + Point::direction(normal_face_vector.angle()) * 10;
}

Trajectory CollectPathPlanner::intercept(const PlanRequest& plan_request, RobotInstant start_instant,
const rj_geometry::ShapeSet& static_obstacles,
const std::vector<DynamicObstacle>& dynamic_obstacles,
rj_geometry::Point delta_pos, rj_geometry::Point face_pos) {

Trajectory CollectPathPlanner::intercept(const PlanRequest& plan_request,

Check warning on line 282 in soccer/src/soccer/planning/planner/collect_path_planner.cpp

View workflow job for this annotation

GitHub Actions / build-and-test

function 'intercept' has cognitive complexity of 27 (threshold 25)
RobotInstant start_instant,
const rj_geometry::ShapeSet& static_obstacles,
const std::vector<DynamicObstacle>& dynamic_obstacles,
rj_geometry::Point delta_pos,
rj_geometry::Point face_pos) {
const double max_ball_angle_change_for_path_reset =
settle::PARAM_max_ball_angle_for_reset * M_PI / 180.0f;

BallState ball = plan_request.world_state->ball;

// If the ball changed directions or magnitude really quickly, do a reset of
Expand All @@ -297,7 +297,7 @@ Trajectory CollectPathPlanner::intercept(const PlanRequest& plan_request, RobotI
first_intercept_target_found_ = false;
average_ball_vel_initialized_ = false;
}

// Try find best point to intercept using brute force method
// where we check ever X distance along the ball velocity vector
//
Expand Down
10 changes: 5 additions & 5 deletions soccer/src/soccer/planning/planner/collect_path_planner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class CollectPathPlanner : public PathPlanner {
// and won't intercept ball correctly anymore
void check_solution_validity(BallState ball, RobotInstant start);

void process_state_transition(const PlanRequest& request, BallState ball, RobotInstant start_instant);
void process_state_transition(const PlanRequest& request, BallState ball,
RobotInstant start_instant);

Trajectory coarse_approach(
const PlanRequest& plan_request, RobotInstant start,
const rj_geometry::ShapeSet& static_obstacles,
const std::vector<DynamicObstacle>& dynamic_obstacles);

Trajectory intercept(const PlanRequest& plan_request,
RobotInstant start_instant,
Trajectory intercept(const PlanRequest& plan_request, RobotInstant start_instant,
const rj_geometry::ShapeSet& static_obstacles,
const std::vector<DynamicObstacle>& dynamic_obstacles,
rj_geometry::Point delta_pos, rj_geometry::Point face_pos);
Expand All @@ -70,8 +70,8 @@ class CollectPathPlanner : public PathPlanner {

// Calculate the delta position to get the robot in the correct location
// And the face point to get the bounce right towards their goal
void calc_delta_pos_for_dir(BallState ball, RobotInstant start_instant, rj_geometry::Point* delta_robot_pos,
rj_geometry::Point* face_pos);
void calc_delta_pos_for_dir(BallState ball, RobotInstant start_instant,
rj_geometry::Point* delta_robot_pos, rj_geometry::Point* face_pos);

Trajectory previous_;

Expand Down
9 changes: 5 additions & 4 deletions soccer/src/soccer/planning/planner/settle_path_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,14 @@ Trajectory SettlePathPlanner::dampen(const PlanRequest& plan_request, RobotInsta
LinearMotionInstant final_stopping_motion{final_stopping_point};

Trajectory dampen_end;

if (previous_.empty()) {
dampen_end = CreatePath::simple(start_instant.linear_motion(), final_stopping_motion,
plan_request.constraints.mot, start_instant.stamp);
plan_request.constraints.mot, start_instant.stamp);
} else {
dampen_end = CreatePath::simple(previous_.instant_at(previous_.num_instants() - 1).linear_motion(), final_stopping_motion,
plan_request.constraints.mot, start_instant.stamp);
dampen_end = CreatePath::simple(
previous_.instant_at(previous_.num_instants() - 1).linear_motion(),
final_stopping_motion, plan_request.constraints.mot, start_instant.stamp);
}

dampen_end.set_debug_text("Damping");
Expand Down
3 changes: 1 addition & 2 deletions soccer/src/soccer/strategy/agent/position/solo_offense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ std::optional<RobotIntent> SoloOffense::state_to_task(RobotIntent intent) {
robotToBall = robotToBall.normalized(length);
planning::LinearMotionInstant target{
last_world_state_->get_robot(true, robot_id_).pose.position() + robotToBall};
auto pivot_cmd =
planning::MotionCommand{"collect"};
auto pivot_cmd = planning::MotionCommand{"collect"};
intent.motion_command = pivot_cmd;
intent.dribbler_speed = 255;
return intent;
Expand Down

0 comments on commit 00e6ef9

Please sign in to comment.