Skip to content

Fix robot control mode not being initialized properly on startup#3461

Merged
williamckha merged 5 commits into
UBC-Thunderbots:masterfrom
williamckha:william/robot_control_mode_fix
Jun 14, 2025
Merged

Fix robot control mode not being initialized properly on startup#3461
williamckha merged 5 commits into
UBC-Thunderbots:masterfrom
williamckha:william/robot_control_mode_fix

Conversation

@williamckha

@williamckha williamckha commented May 31, 2025

Copy link
Copy Markdown
Member

Description

Fixes issue where no packets were being sent to robot while running AI

Testing Done

Tested in mezz

Resolved Issues

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

@williamckha williamckha requested a review from mkhlb May 31, 2025 20:25
@williamckha williamckha requested a review from Andrewyx June 1, 2025 02:16
Comment on lines +352 to +372
for tab in tscope_config.tabs:
if hasattr(tab, "widgets"):
robot_view_widget = tab.find_widget("Robot View")
if robot_view_widget is not None:
robot_view_widget.individual_robot_control_mode_signal.connect(
lambda robot_id,
robot_mode: robot_communication.toggle_individual_robot_control_mode(
robot_id, robot_mode
)
)

# Set mode for robot in RobotCommunication to initial value of combo box
for (
robot_view_component
) in robot_view_widget.robot_view_widgets:
robot_info = robot_view_component.robot_info
robot_communication.toggle_individual_robot_control_mode(
robot_info.robot_id,
IndividualRobotMode(
robot_info.control_mode_menu.currentIndex()
),

@Andrewyx Andrewyx Jun 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pyramid of doom ah. Can we sep this apart to diff functions to make it more readable? Also, was getting rid of if args.run_diagnostics so that this should be available in ai vs ai (i.e. testing)?

Comment on lines +475 to +481
parser = argparse.ArgumentParser()
parser.add_argument(
"--test_filter",
action="store",
default="",
)
args, _ = parser.parse_known_args()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

help missing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed this and added an optional allow_unrecognized param to load_command_line_args instead.

This was just a hack to get field tests to run without erroring. Command-line args passed to field tests don't match the ones used for simulated tests, but they both use the same pytest_main func which uses the simulated test's version of load_command_line_args. Hence, args specific to field tests wouldn't be recognized and cause an exception.

Comment thread src/software/field_tests/field_test_fixture.py
self.referee_port,
referee_interface,
lambda data: self.__forward_to_proto_unix_io(SSL_Referee, data),
lambda data: self.__forward_to_proto_unix_io(Referee, data),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is this change for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SSL_Referee does not exist, looks like this is a typo

Comment thread src/software/thunderscope/thunderscope_main.py Outdated

@itsarune itsarune left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wait, so the widget was only connected if --run_diagnostics was passed? how come we didn't see this earlier?

to the refresh function
"""
self.name = name
self.widgets = widgets

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

self.widgets is unused

@williamckha

Copy link
Copy Markdown
Member Author

wait, so the widget was only connected if --run_diagnostics was passed? how come we didn't see this earlier?

Yep, no idea why we never noticed this before. Probably went unnoticed since we don't really field test with AI


Did some refactoring to return out the RobotView widget from the TScopeConfig creator instead of hunting for it after the fact. Also simplified some obfuscated logic in thunderscope_config.py

@williamckha williamckha requested review from Andrewyx and itsarune June 11, 2025 04:35
itsarune
itsarune previously approved these changes Jun 11, 2025

@itsarune itsarune left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Nice work 💯

@itsarune itsarune left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! ⚽

@Andrewyx Andrewyx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ltmg

@williamckha williamckha merged commit 3c8ee82 into UBC-Thunderbots:master Jun 14, 2025
6 checks passed
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.

3 participants