-
Notifications
You must be signed in to change notification settings - Fork 98
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
Gamecontroller can Bind to a Different Port Based on Command Line Argument #3207
base: master
Are you sure you want to change the base?
Changes from 17 commits
bacfacf
d620120
1557448
5478f15
8d394cd
0b5d2a6
5d5e130
53b3120
c052a97
ace67d6
730753a
9b8d59d
9453411
ebcc8d6
6ad2b47
e730860
60dad81
b44cdcf
0c984eb
749fb3f
f3a42e7
bed3109
51f42e2
1e8fcba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ def __init__( | |
:param test_name: The name of the test to run | ||
:param blue_full_system_proto_unix_io: The blue full system proto unix io to use | ||
:param yellow_full_system_proto_unix_io: The yellow full system proto unix io to use | ||
:param gamecontroller: The gamecontroller context managed instance | ||
:param gamecontroller: The gamecontroller context managed instance | ||
:param publish_validation_protos: whether to publish validation protos | ||
:param: is_yellow_friendly: if yellow is the friendly team | ||
""" | ||
|
@@ -320,6 +320,27 @@ def load_command_line_arguments(): | |
help="Run the test with friendly robots in yellow mode", | ||
) | ||
|
||
parser.add_argument( | ||
"--sslvision_multicast_address", | ||
type=str, | ||
default=SSL_VISION_ADDRESS, | ||
help="the multicast address for ssl vision", | ||
) | ||
|
||
parser.add_argument( | ||
"--use_unconventional_port", | ||
action="store_true", | ||
default=False, | ||
help="setting this option would cause gamecontroller to bind on an unconventional port, likely 12393", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this as @nimazareian suggested. If we run |
||
|
||
parser.add_argument( | ||
"--not_launch_gc", | ||
action="store_true", | ||
default=False, | ||
help="whether we are launching gamecontroller or not", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's do the inverse |
||
|
||
estop_group = parser.add_mutually_exclusive_group() | ||
estop_group.add_argument( | ||
"--keyboard_estop", | ||
|
@@ -373,84 +394,88 @@ def field_test_runner(): | |
debug_full_system=debug_full_sys, | ||
friendly_colour_yellow=args.run_yellow, | ||
should_restart_on_crash=False, | ||
) as friendly_fs, RobotCommunication( | ||
) as friendly_fs, Gamecontroller( | ||
use_unconventional_port=args.use_unconventional_port, | ||
not_launch_gc=args.not_launch_gc, | ||
supress_logs=(not args.show_gamecontroller_logs), | ||
) as gamecontroller, RobotCommunication( | ||
current_proto_unix_io=friendly_proto_unix_io, | ||
multicast_channel=getRobotMulticastChannel(args.channel), | ||
interface=args.interface, | ||
estop_mode=estop_mode, | ||
estop_path=estop_path, | ||
enable_radio=args.enable_radio, | ||
sslvision_address=args.sslvision_multicast_address, | ||
referee_port=gamecontroller.get_referee_port(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup this is exactly right, but we don't need |
||
) as rc_friendly: | ||
with Gamecontroller( | ||
supress_logs=(not args.show_gamecontroller_logs) | ||
) as gamecontroller: | ||
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, yellow_full_system_proto_unix_io, | ||
) | ||
# Inject the proto unix ios into thunderscope and start the test | ||
tscope = Thunderscope( | ||
configure_field_test_view( | ||
simulator_proto_unix_io=simulator_proto_unix_io, | ||
blue_full_system_proto_unix_io=blue_full_system_proto_unix_io, | ||
yellow_full_system_proto_unix_io=yellow_full_system_proto_unix_io, | ||
yellow_is_friendly=args.run_yellow, | ||
), | ||
layout_path=None, | ||
) | ||
|
||
# connect the keyboard estop toggle to the key event if needed | ||
if estop_mode == EstopMode.KEYBOARD_ESTOP: | ||
tscope.keyboard_estop_shortcut.activated.connect( | ||
rc_friendly.toggle_keyboard_estop | ||
) | ||
# we call this method to enable estop automatically when a field test starts | ||
rc_friendly.toggle_keyboard_estop() | ||
logger.warning( | ||
"\x1b[31;20m" | ||
+ "Keyboard Estop Enabled, robots will start moving automatically when test starts!" | ||
+ "\x1b[0m" | ||
) | ||
friendly_fs.setup_proto_unix_io(friendly_proto_unix_io) | ||
rc_friendly.setup_for_fullsystem() | ||
|
||
time.sleep(LAUNCH_DELAY_S) | ||
runner = FieldTestRunner( | ||
test_name=current_test, | ||
gamecontroller.setup_proto_unix_io( | ||
blue_full_system_proto_unix_io, yellow_full_system_proto_unix_io, | ||
) | ||
# Inject the proto unix ios into thunderscope and start the test | ||
tscope = Thunderscope( | ||
configure_field_test_view( | ||
simulator_proto_unix_io=simulator_proto_unix_io, | ||
blue_full_system_proto_unix_io=blue_full_system_proto_unix_io, | ||
yellow_full_system_proto_unix_io=yellow_full_system_proto_unix_io, | ||
gamecontroller=gamecontroller, | ||
thunderscope=tscope, | ||
is_yellow_friendly=args.run_yellow, | ||
yellow_is_friendly=args.run_yellow, | ||
), | ||
layout_path=None, | ||
) | ||
|
||
# connect the keyboard estop toggle to the key event if needed | ||
if estop_mode == EstopMode.KEYBOARD_ESTOP: | ||
tscope.keyboard_estop_shortcut.activated.connect( | ||
rc_friendly.toggle_keyboard_estop | ||
) | ||
# we call this method to enable estop automatically when a field test starts | ||
rc_friendly.toggle_keyboard_estop() | ||
logger.warning( | ||
"\x1b[31;20m" | ||
+ "Keyboard Estop Enabled, robots will start moving automatically when test starts!" | ||
+ "\x1b[0m" | ||
) | ||
|
||
friendly_proto_unix_io.register_observer(World, runner.world_buffer) | ||
|
||
# Setup proto loggers. | ||
# | ||
# NOTE: Its important we use the test runners time provider because | ||
# test will run as fast as possible with a varying tick rate. The | ||
# SimulatorTestRunner time provider is tied to the simulators | ||
# t_capture coming out of the wrapper packet (rather than time.time). | ||
with ProtoLogger( | ||
f"{args.blue_full_system_runtime_dir}/logs/{current_test}", | ||
time_provider=runner.time_provider, | ||
) as blue_logger, ProtoLogger( | ||
f"{args.yellow_full_system_runtime_dir}/logs/{current_test}", | ||
time_provider=runner.time_provider, | ||
) as yellow_logger: | ||
blue_full_system_proto_unix_io.register_to_observe_everything( | ||
blue_logger.buffer | ||
) | ||
yellow_full_system_proto_unix_io.register_to_observe_everything( | ||
yellow_logger.buffer | ||
) | ||
yield runner | ||
print( | ||
f"\n\nTo replay this test for the blue team, go to the `src` folder and run \n./tbots.py run thunderscope --blue_log {blue_logger.log_folder}", | ||
flush=True, | ||
) | ||
print( | ||
f"\n\nTo replay this test for the yellow team, go to the `src` folder and run \n./tbots.py run thunderscope --yellow_log {yellow_logger.log_folder}", | ||
flush=True, | ||
) | ||
time.sleep(LAUNCH_DELAY_S) | ||
runner = FieldTestRunner( | ||
test_name=current_test, | ||
blue_full_system_proto_unix_io=blue_full_system_proto_unix_io, | ||
yellow_full_system_proto_unix_io=yellow_full_system_proto_unix_io, | ||
gamecontroller=gamecontroller, | ||
thunderscope=tscope, | ||
is_yellow_friendly=args.run_yellow, | ||
) | ||
|
||
friendly_proto_unix_io.register_observer(World, runner.world_buffer) | ||
|
||
# Setup proto loggers. | ||
# | ||
# NOTE: Its important we use the test runners time provider because | ||
# test will run as fast as possible with a varying tick rate. The | ||
# SimulatorTestRunner time provider is tied to the simulators | ||
# t_capture coming out of the wrapper packet (rather than time.time). | ||
with ProtoLogger( | ||
f"{args.blue_full_system_runtime_dir}/logs/{current_test}", | ||
time_provider=runner.time_provider, | ||
) as blue_logger, ProtoLogger( | ||
f"{args.yellow_full_system_runtime_dir}/logs/{current_test}", | ||
time_provider=runner.time_provider, | ||
) as yellow_logger: | ||
blue_full_system_proto_unix_io.register_to_observe_everything( | ||
blue_logger.buffer | ||
) | ||
yellow_full_system_proto_unix_io.register_to_observe_everything( | ||
yellow_logger.buffer | ||
) | ||
yield runner | ||
print( | ||
f"\n\nTo replay this test for the blue team, go to the `src` folder and run \n./tbots.py run thunderscope --blue_log {blue_logger.log_folder}", | ||
flush=True, | ||
) | ||
print( | ||
f"\n\nTo replay this test for the yellow team, go to the `src` folder and run \n./tbots.py run thunderscope --yellow_log {yellow_logger.log_folder}", | ||
flush=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this arg, we can default to SSL_VISION_ADDRESS and just change the port