Skip to content

Commit

Permalink
Waller Clear version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayden Bastien authored and Jayden Bastien committed Feb 19, 2025
1 parent 83debe9 commit cc171c8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 75 deletions.
52 changes: 28 additions & 24 deletions soccer/src/soccer/strategy/agent/position/defense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ Defense::State Defense::update_state() {
}

switch (current_state_) {
case IDLING:{
break;}
case JOINING_WALL:{
case IDLING: {
break;
}
case JOINING_WALL: {
send_join_wall_request();
// SPDLOG_INFO("join wall {}", robot_id_);
next_state = WALLING;
walling_robots_ = {(u_int8_t)robot_id_};
break;}
case WALLING:{
break;
}
case WALLING: {
// If a wall is already full,
// Remove the robot with the highest ID from a wall
// and make them a marker instead.
Expand All @@ -59,42 +61,48 @@ Defense::State Defense::update_state() {
send_leave_wall_request();
next_state = STEALING;
}
break;}
case SEARCHING:{
break;}
case RECEIVING:{
break;
}
case SEARCHING: {
break;
}
case RECEIVING: {
// transition to idling if we are close enough to the ball
if (distance_to_ball < ball_receive_distance_) {
next_state = IDLING;
}
break;}
case PASSING:{
break;
}
case PASSING: {
// transition to idling if we no longer have the ball (i.e. it was passed or it was
// stolen)
if (check_is_done() || distance_to_ball > ball_lost_distance_) {
next_state = JOINING_WALL;
}
break;}
case FACING:{
break;
}
case FACING: {
if (check_is_done()) {
next_state = IDLING;
}}
case MARKING:{
}
}
case MARKING: {
if (marker_.get_target() == -1 || marker_.target_out_of_bounds(world_state)) {
next_state = ENTERING_MARKING;
}
break;}
case ENTERING_MARKING:{
break;
}
case ENTERING_MARKING: {
marker_.choose_target(world_state);
int target_id = marker_.get_target();
if (target_id == -1) {
next_state = ENTERING_MARKING;
} else {
next_state = MARKING;
}
break;}
case STEALING: // wall steal
{
break;
}
case STEALING: {// wall steal
// Go to passing if successful
if (check_is_done()) {
send_leave_wall_request();
Expand Down Expand Up @@ -199,10 +207,6 @@ std::optional<RobotIntent> Defense::state_to_task(RobotIntent intent) {
planning::LinearMotionInstant target{clear_point_};
auto line_kick_cmd = planning::MotionCommand{"line_kick", target};
intent.motion_command = line_kick_cmd;

// note: the way this is set up makes it impossible to
// shoot on time without breakbeam
// TODO(Kevin): make intent hold a manip msg instead? to be cleaner?
intent.shoot_mode = RobotIntent::ShootMode::CHIP;
intent.trigger_mode = RobotIntent::TriggerMode::ON_BREAK_BEAM;
intent.kick_speed = 4.0;
Expand Down
1 change: 0 additions & 1 deletion soccer/src/soccer/strategy/agent/position/framework
Submodule framework deleted from a6c523
49 changes: 0 additions & 49 deletions soccer/src/soccer/strategy/agent/position/offense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,48 +521,6 @@ double Offense::distance_from_their_robots(rj_geometry::Point tail, rj_geometry:
return min_angle;
}

// bool Offense::can_steal_ball() const {
// // Ball in red zone or not
// if (ball_in_red()) {
// return false;
// }
// // Ball location
// rj_geometry::Point ball_position = this->last_world_state_->ball.position;

// // Our robot is closest robot to ball
// bool closest = true;

// auto current_pos = last_world_state_->get_robot(true, robot_id_).pose.position();

// auto our_dist = (current_pos - ball_position).mag();
// for (auto enemy : this->last_world_state_->their_robots) {
// auto dist = (enemy.pose.position() - ball_position).mag();
// if (dist < our_dist) {
// closest = false;
// break;
// }
// }

// if (!closest) {
// return closest;
// }

// for (auto pal : this->last_world_state_->our_robots) {
// // if (pal.robot_id_ == robot_id_) {
// // continue;
// // }
// auto dist = (pal.pose.position() - ball_position).mag();
// if (dist < our_dist) {
// closest = false;
// break;
// }
// }

// return closest;

// // return distance_to_ball() < kStealBallRadius;
// }

rj_geometry::Point Offense::calculate_best_shot() const {
// Goal location
rj_geometry::Point their_goal_pos = field_dimensions_.their_goal_loc();
Expand All @@ -587,13 +545,6 @@ rj_geometry::Point Offense::calculate_best_shot() const {
return best_shot;
}

// // Checks whether ball is out of range for stealing/receiving
// bool Offense::ball_in_red() const {
// auto& ball_pos = last_world_state_->ball.position;
// return (field_dimensions_.our_defense_area().contains_point(ball_pos) ||
// field_dimensions_.their_defense_area().contains_point(ball_pos) ||
// !field_dimensions_.field_rect().contains_point(ball_pos));
// }
void Offense::broadcast_seeker_request(rj_geometry::Point seeking_point, bool adding) {
communication::SeekerRequest seeker_request{};
communication::generate_uid(seeker_request);
Expand Down
1 change: 0 additions & 1 deletion soccer/src/soccer/strategy/agent/position/waller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ std::optional<RobotIntent> Waller::get_task(RobotIntent intent, const WorldState
auto num_wallers = walling_robots_.size();



// Find ball_direction unit vector
rj_geometry::Point ball_dir_vector{(ball_pos - goal_pos)};

Expand Down

0 comments on commit cc171c8

Please sign in to comment.