Skip to content

Commit

Permalink
Fixed on_actionResetField_triggered() method (#2157)
Browse files Browse the repository at this point in the history
Added hard-coded robot positions in main_window reset method
  • Loading branch information
jvogt23 authored and sanatd33 committed Jan 29, 2024
1 parent ccc56fc commit 7d8bebe
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions soccer/src/soccer/ui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,17 +828,23 @@ void MainWindow::on_actionStopBall_triggered() {
}

void MainWindow::on_actionResetField_triggered() {
const int NUM_COLS = 2;
const int ROBOTS_PER_COL = kRobotsPerTeam / NUM_COLS;
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, -1, 0), 0, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, -1, 0), 0, true);

for (size_t i = 0; i < kRobotsPerTeam; ++i) {
double x_pos = +2.5 - i / ROBOTS_PER_COL;
double y_pos = i % ROBOTS_PER_COL - ROBOTS_PER_COL / NUM_COLS;
auto pose = rj_geometry::Pose(x_pos, y_pos, 0);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, 0, 0), 1, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, 0, 0), 1, true);

_ui.fieldView->set_robot_pose(pose, i, false);
_ui.fieldView->set_robot_pose(pose, i, true);
}
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, 1, 0), 2, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(2, 1, 0), 2, true);

_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, -1, 0), 3, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, -1, 0), 3, true);

_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, 0, 0), 4, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, 0, 0), 4, true);

_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, 1, 0), 5, false);
_ui.fieldView->set_robot_pose(rj_geometry::Pose(3, 1, 0), 5, true);

_ui.fieldView->set_ball_position(rj_geometry::Point(0.0, 0.0));
_ui.fieldView->set_ball_velocity(rj_geometry::Point(0.0, 0.0));
Expand Down

0 comments on commit 7d8bebe

Please sign in to comment.