Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot Factory Upgrade #2338

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void RobotFactoryPosition::handle_ready() {
if (current_position_->get_name() == "Offense" ||
current_position_->get_name() == "PenaltyPlayer" ||
current_position_->get_name() == "GoalKicker") {
set_current_position<Idle>();
set_current_position<SmartIdle>();
}
}
}
Expand Down Expand Up @@ -216,19 +216,6 @@ bool RobotFactoryPosition::am_closest_kicker() {
}

void RobotFactoryPosition::set_default_position() {
// zoner defense testing
// if (robot_id_ == goalie_id_) {
// return;
// }
// if (robot_id_ == 1) {
// set_current_position<Zoner>();
// } else {
// set_current_position<Defense>();
// }
// return;
// end zoner defense testing

// TODO (Rishi and Jack): Make this synchronized across all robots to avoid race conditions
// Get sorted positions of all friendly robots
using RobotPos = std::pair<int, double>; // (robotId, yPosition)

Expand Down Expand Up @@ -256,24 +243,23 @@ void RobotFactoryPosition::set_default_position() {
}

// Assigning new position
// Checking whether we have possesion or if the ball is on their half (using 1.99 to avoid
// rounding issues on midline)
// Checking whether we have possesion or if the ball is on their half
if (our_possession_ || last_world_state_->ball.position.y() >
field_dimensions_.center_field_loc().y() - kBallDiameter) {
// Offensive mode
// Closest 2 robots on defense, rest on offense
if (i <= 3) {
if (i <= 1) {
set_current_position<Defense>();
} else {
set_current_position<SoloOffense>();
set_current_position<Offense>();
}
} else {
// Defensive mode
// Closest 4 robots on defense, rest on offense
if (i <= 3) {
set_current_position<Defense>();
} else {
set_current_position<SoloOffense>();
set_current_position<Offense>();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ class RobotFactoryPosition : public Position {
*/
template <class Pos>
void set_current_position() {
// If we are not currently playing Pos
// if (current_position_->get_name() == "Defense") {
// SPDLOG_INFO("we are never leaving defense :)");
// return;
// }
if (dynamic_cast<Pos*>(current_position_.get()) == nullptr) {
// This line requires Pos to implement the constructor Pos(const
// Position&)
Expand Down
Loading