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

Alive Robots in robot_factory_position #2212

Closed
wants to merge 11 commits into from
Closed

Conversation

shourikb
Copy link
Contributor

@shourikb shourikb commented Mar 6, 2024

Changed a few things so that robot_factory_position and a couple other classes use the alive_robots_ array properly. Had to change the type of alive_robots_ from vector to array in a few classes.

In the loop in robot_factory_position, there is a variable j that keeps track of the count and the for each loop gets all of the booleans from alive_robots_ and uses that value in whether to execute the code in the loop body or not.

Copy link
Contributor

@sid-parikh sid-parikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to update the position.cpp implementation of alive robots. It currently searches the list for the robot id, but it should instead check if alive_robots[robot_id] == true or something like that, because you changed it from a vector to an array

@@ -94,18 +94,19 @@ SimRadio::SimRadio(bool blue_team)
ip::udp::endpoint(address_, blue_team_ ? kSimBlueCommandPort : kSimYellowCommandPort);
sim_control_endpoint_ = ip::udp::endpoint(address_, kSimCommandPort);

// assume robots 0-6 are always alive in sim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// assume robots 0-6 are always alive in sim
// assume robots 0-5 are always alive in sim

@@ -49,29 +50,29 @@ std::optional<RobotIntent> RobotFactoryPosition::get_task(WorldState& world_stat
// Assigning new position
// Checking whether we have possesion or if the ball is on their half (using 1.99 to avoid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Checking whether we have possesion or if the ball is on their half (using 1.99 to avoid
// Checking whether we have possesion or if the ball is on their half

@@ -49,29 +50,29 @@ std::optional<RobotIntent> RobotFactoryPosition::get_task(WorldState& world_stat
// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// rounding issues on midline)

@@ -6,7 +6,6 @@ RobotFactoryPosition::RobotFactoryPosition(int r_id) : Position(r_id, "RobotFact
if (robot_id_ == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (robot_id_ == 0) {
if (robot_id_ == goalie_id_) {

Copy link
Contributor

@rishiso rishiso Mar 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goalie is never reassigned inside get_task(), so it is important to do this here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@@ -16,7 +15,7 @@ RobotFactoryPosition::RobotFactoryPosition(int r_id) : Position(r_id, "RobotFact
std::optional<RobotIntent> RobotFactoryPosition::get_task(WorldState& world_state,
FieldDimensions& field_dimensions) {
// If keeper, make no changes
if (robot_id_ == 0) {
if (robot_id_ == goalie_id_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will need to double-check with Sid about this, but if the goalie can change, we need to add functionality here to update the goalie if it is not assigned correctly.

if (Position::our_possession_ ||
world_state.ball.position.y() > field_dimensions.length() / 1.99) {
if (our_possession_ ||
world_state.ball.position.y() > field_dimensions.center_field_loc().y() - kBallDiameter) {
// Offensive mode
// Closest 2 robots on defense, rest on offense
if (i <= 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're working on this file, could we change the i variable name to something more descriptive? Perhaps robot_y_index?
Variable defined on line 42 but it's collapsed so GitHub won't let me comment there

@sid-parikh
Copy link
Contributor

Merged into kicker-picker see #2200

@sid-parikh sid-parikh closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants