88import google .protobuf
99from google .protobuf .internal import api_implementation
1010
11+ from software .thunderscope .binary_context_managers .runtime_manager import (
12+ runtime_manager_instance ,
13+ )
14+
1115protobuf_impl_type = api_implementation .Type ()
1216assert protobuf_impl_type == "upb" , (
1317 f"Trying to use the { protobuf_impl_type } protobuf implementation. "
1418 "Please use the upb implementation, available in python protobuf version 4.21.0 and above."
1519 f"The current version of protobuf is { google .protobuf .__version__ } "
1620)
1721
18-
1922from software .thunderscope .thunderscope import Thunderscope
2023from software .thunderscope .constants import LogLevels
2124from software .thunderscope .binary_context_managers import *
2225from proto .import_all_protos import *
2326from software .py_constants import *
2427from software .thunderscope .robot_communication import RobotCommunication
2528from software .thunderscope .wifi_communication_manager import WifiCommunicationManager
26- from software .thunderscope .constants import EstopMode , ProtoUnixIOTypes
29+ from software .thunderscope .constants import (
30+ EstopMode ,
31+ ProtoUnixIOTypes ,
32+ RuntimeManagerConstants ,
33+ )
2734from software .thunderscope .estop_helpers import get_estop_config
2835from software .thunderscope .proto_unix_io import ProtoUnixIO
2936import software .thunderscope .thunderscope_config as config
@@ -432,31 +439,16 @@ def __ticker(tick_rate_ms: int) -> None:
432439 tick_rate_ms , tscope .proto_unix_io_map [ProtoUnixIOTypes .SIM ], tscope
433440 )
434441
435- # Libraries to use for yellow
436-
437- # TODO (#3557) Set external_ai variables to follow toml file in /opt/tbotspython/external_ai/ai_config.toml
438- blue_external_ai = None
439- yellow_external_ai = None
440-
441- # If ai selected is default, use the unix full system generated by the current branch build in the bazel sand blue_full_system_proto_unix_io
442- # Else, find the unix full system in opt
443- blue_path_to_binary = (
444- "software/unix_full_system"
445- if not blue_external_ai
446- else "/opt/tbotspython/external_ai/{}" .format (blue_external_ai )
447- )
448-
449- yellow_path_to_binary = (
450- "software/unix_full_system"
451- if not yellow_external_ai
452- else "/opt/tbotspython/external_ai/{}" .format (yellow_external_ai )
453- )
442+ # Fetch the AI runtime/backends
443+ runtime_config = runtime_manager_instance .fetch_runtime_config ()
454444
455445 # Launch all binaries
456446 with Simulator (
457447 args .simulator_runtime_dir , args .debug_simulator , args .enable_realism
458448 ) as simulator , FullSystem (
459- path_to_binary = blue_path_to_binary ,
449+ path_to_binary = runtime_config [
450+ RuntimeManagerConstants .RUNTIME_CONFIG_BLUE_KEY
451+ ],
460452 full_system_runtime_dir = args .blue_full_system_runtime_dir ,
461453 debug_full_system = args .debug_blue_full_system ,
462454 friendly_colour_yellow = False ,
@@ -465,7 +457,9 @@ def __ticker(tick_rate_ms: int) -> None:
465457 running_in_realtime = (not args .ci_mode ),
466458 log_level = args .log_level ,
467459 ) as blue_fs , FullSystem (
468- path_to_binary = yellow_path_to_binary ,
460+ path_to_binary = runtime_config [
461+ RuntimeManagerConstants .RUNTIME_CONFIG_YELLOW_KEY
462+ ],
469463 full_system_runtime_dir = args .yellow_full_system_runtime_dir ,
470464 debug_full_system = args .debug_yellow_full_system ,
471465 friendly_colour_yellow = True ,
0 commit comments