Skip to content
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
24 changes: 17 additions & 7 deletions src/software/field_tests/field_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
from proto.import_all_protos import *

from software.simulated_tests import validation
from software.thunderscope.constants import EstopMode
from software.thunderscope.constants import EstopMode, IndividualRobotMode
from software.thunderscope.thunderscope import Thunderscope
from software.thunderscope.proto_unix_io import ProtoUnixIO
from software.thunderscope.binary_context_managers.full_system import FullSystem
from software.thunderscope.binary_context_managers.game_controller import Gamecontroller
from software.thunderscope.wifi_communication_manager import WifiCommunicationManager
from software.logger.logger import create_logger


Expand Down Expand Up @@ -360,27 +361,29 @@ def field_test_runner():

# Launch all binaries
with FullSystem(
runtime_dir,
full_system_runtime_dir=runtime_dir,
debug_full_system=debug_full_sys,
friendly_colour_yellow=args.run_yellow,
should_restart_on_crash=False,
) as friendly_fs, Gamecontroller(
# we would be using conventional port if and only if we are playing in robocup.
suppress_logs=(not args.show_gamecontroller_logs),
use_conventional_port=False,
) as gamecontroller, RobotCommunication(
) as gamecontroller, WifiCommunicationManager(
current_proto_unix_io=friendly_proto_unix_io,
multicast_channel=getRobotMulticastChannel(args.channel),
should_setup_full_system=True,
interface=args.interface,
estop_mode=estop_mode,
estop_path=estop_path,
enable_radio=args.enable_radio,
referee_port=gamecontroller.get_referee_port()
if gamecontroller
else SSL_REFEREE_PORT,
) as wifi_communication_manager, RobotCommunication(
current_proto_unix_io=friendly_proto_unix_io,
communication_manager=wifi_communication_manager,
estop_mode=estop_mode,
estop_path=estop_path,
) as rc_friendly:
friendly_fs.setup_proto_unix_io(friendly_proto_unix_io)
rc_friendly.setup_for_fullsystem()

gamecontroller.setup_proto_unix_io(
blue_full_system_proto_unix_io=blue_full_system_proto_unix_io,
Expand All @@ -398,6 +401,13 @@ def field_test_runner():
layout_path=None,
)

# Set control mode for all robots to AI so that packets are sent to the robots
for robot_id in range(MAX_ROBOT_IDS_PER_SIDE):
rc_friendly.toggle_individual_robot_control_mode(
robot_id,
IndividualRobotMode.AI,
)
Comment thread
Andrewyx marked this conversation as resolved.

# connect the keyboard estop toggle to the key event if needed
if estop_mode == EstopMode.KEYBOARD_ESTOP:
tscope.keyboard_estop_shortcut.activated.connect(
Expand Down
9 changes: 6 additions & 3 deletions src/software/simulated_tests/simulated_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ def run_test(
assert failed_tests == 0


def load_command_line_arguments():
def load_command_line_arguments(allow_unrecognized: bool = False):
"""Load in command-line arguments using argparse

NOTE: Pytest has its own built in argument parser (conftest.py, pytest_addoption)
but it doesn't seem to play nicely with bazel. We just use argparse instead.

:param allow_unrecognized: if true, does not raise an error for unrecognized arguments
"""
parser = argparse.ArgumentParser(description="Run simulated pytests")
parser.add_argument(
Expand Down Expand Up @@ -464,15 +466,16 @@ def load_command_line_arguments():
default=False,
help="Use realism in the simulator",
)
return parser.parse_args()
return parser.parse_known_args()[0] if allow_unrecognized else parser.parse_args()


def pytest_main(file):
"""Runs the pytest file

:param file: The test file to run
"""
args = load_command_line_arguments()
args = load_command_line_arguments(allow_unrecognized=True)

# Run the test, -s disables all capturing at -vv increases verbosity
# -W ignore::DeprecationWarning ignores deprecation warnings that spam the output
sys.exit(
Expand Down
5 changes: 2 additions & 3 deletions src/software/thunderscope/robot_diagnostics/robot_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ def create_control_mode_menu(
)

control_mode_menu.currentIndexChanged.connect(
lambda mode,
robot_id=self.robot_id: self.individual_robot_control_mode_signal.emit(
robot_id, IndividualRobotMode(mode)
lambda mode: self.individual_robot_control_mode_signal.emit(
self.robot_id, IndividualRobotMode(mode)
)
)

Expand Down
14 changes: 7 additions & 7 deletions src/software/thunderscope/robot_diagnostics/robot_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ def __init__(self, available_control_modes: list[IndividualRobotMode]) -> None:

self.layout = QVBoxLayout()

self.robot_view_widgets = []
self.components = []

for id in range(MAX_ROBOT_IDS_PER_SIDE):
robot_view_widget = RobotViewComponent(
component = RobotViewComponent(
id, available_control_modes, self.individual_robot_control_mode_signal
)
self.robot_view_widgets.append(robot_view_widget)
self.layout.addWidget(robot_view_widget)
self.components.append(component)
self.layout.addWidget(component)

# for a QScrollArea, widgets cannot be added to it directly
# doing so causes no scrolling to happen, and all the components get smaller
Expand All @@ -134,16 +134,16 @@ def refresh(self) -> None:
and robot_statistic is not None
and robot_status.robot_id == robot_statistic.robot_id
): # if both pieces of data are available
self.robot_view_widgets[robot_status.robot_id].update(
self.components[robot_status.robot_id].update(
robot_status=robot_status, robot_statistic=robot_statistic
)
else:
if robot_status is not None:
self.robot_view_widgets[robot_status.robot_id].update(
self.components[robot_status.robot_id].update(
robot_status,
robot_statistic=None,
)
if robot_statistic is not None:
self.robot_view_widgets[robot_statistic.robot_id].update(
self.components[robot_statistic.robot_id].update(
robot_status=None, robot_statistic=robot_statistic
)
1 change: 0 additions & 1 deletion src/software/thunderscope/thunderscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(
The interval in milliseconds to refresh all the widgets.
"""
self.refresh_interval_ms = refresh_interval_ms
self.widgets = {}
self.refresh_timers = []

self.tabs = QTabWidget()
Expand Down
Loading