예제 #1
0
    def stop(*args):
        """SocketIO Api: stop(module_name)"""
        if len(args) != 1:
            Config.log.critical('ModuleApi::stop bad args')
            return
        module_name = args[0]

        def __single_stop(module_name):
            conf = Config.get_module(module_name)
            if conf is None:
                Config.log.critical('ModuleApi::stop conf is None')
                return
            cmd = next(
                (cmd for cmd in conf.supported_commands if cmd.name == 'stop'),
                None)
            if cmd is None:
                Config.log.critical('ModuleApi::stop cmd is None')
                return
            # Update status and run command.
            RuntimeStatus.get_module(module_name).status = ModuleStatus.STOPPED
            system_cmd.async_run_command_pb(cmd)

        if module_name == 'all':
            _ = [__single_stop(conf.name) for conf in Config.get_pb().modules]
        else:
            __single_stop(module_name)
        RuntimeStatus.broadcast_status_if_changed()
예제 #2
0
    def health_check(*args):
        """SocketIO Api: health_check(hardware_name)"""
        if len(args) != 1:
            Config.log.critical('HardwareApi::health_check bad args')
            return
        hardware_name = args[0]

        def __single_check(hardware_name):
            conf = Config.get_hardware(hardware_name)
            if conf is None:
                Config.log.critical('HardwareApi::health_check conf is None')
                return
            cmd = next((cmd for cmd in conf.supported_commands
                        if cmd.name == 'health_check'), None)
            if cmd is None:
                Config.log.critical('HardwareApi::health_check cmd is None')
                return

            # Update status and run command.
            RuntimeStatus.get_hardware(hardware_name).status = \
                HardwareStatus.CHECKING
            system_cmd.async_run_command_pb(cmd)

        if hardware_name == 'all':
            _ = [
                __single_check(conf.name) for conf in Config.get_pb().hardware
            ]
        else:
            __single_check(hardware_name)
        RuntimeStatus.broadcast_status_if_changed()
예제 #3
0
 def stop_recording(cls):
     """SocketIO Api: stop_recording()"""
     cls.__exec_bash_tool('stop_recording')
     RuntimeStatus.get_tools().recording_status = (
         ToolStatus.RECORDING_FINISHED)
     RuntimeStatus.stat_playable_duration()
     RuntimeStatus.broadcast_status_if_changed()
예제 #4
0
    def start(*args):
        """SocketIO Api: start(module_name)"""
        if len(args) != 1:
            Config.log.critical('ModuleApi::start bad args')
            return
        module_name = args[0]

        def __single_start(module_name):
            conf = Config.get_module(module_name)
            if conf is None:
                Config.log.critical('ModuleApi::start conf is None')
                return
            cmd = next(
                (cmd
                 for cmd in conf.supported_commands if cmd.name == 'start'),
                None)
            if cmd is None:
                Config.log.critical('ModuleApi::start cmd is None')
                return
            # Update status and run command.
            RuntimeStatus.get_module(module_name).status = ModuleStatus.STARTED
            system_cmd.async_run_command_pb(cmd)

        if module_name == 'all':
            for conf in Config.get_pb().modules:
                __single_start(conf.name)
        elif module_name == 'record_replay_required_modules':
            for mod in Config.record_replay_required_modules:
                __single_start(mod)
        else:
            __single_start(module_name)
        RuntimeStatus.broadcast_status_if_changed()
예제 #5
0
 def reset_all(cls):
     """SocketIO Api: reset_all()"""
     ModuleApi.stop('all')
     RuntimeStatus.reset()
     cls.__exec_bash_tool('stop_player')
     cls.__exec_bash_tool('stop_recording')
     RuntimeStatus.broadcast_status_if_changed()
예제 #6
0
 def start_recording(cls):
     """SocketIO Api: start_recording()"""
     cls.__exec_bash_tool('start_recording')
     tool_status = RuntimeStatus.get_tools()
     tool_status.recording_status = ToolStatus.RECORDING
     tool_status.playing_status = ToolStatus.PLAYING_NOT_READY
     RuntimeStatus.broadcast_status_if_changed()
예제 #7
0
 def stop_playing(cls):
     """SocketIO Api: stop_playing()"""
     RosBridgeApi.change_driving_mode('manual')
     cls.__exec_bash_tool('stop_player')
     tool_status = RuntimeStatus.get_tools()
     tool_status.playing_status = ToolStatus.PLAYING_READY_TO_CHECK
     tool_status.planning_ready = False
     RuntimeStatus.broadcast_status_if_changed()
예제 #8
0
 def setup_playing(cls):
     """SocketIO Api: setup_playing()"""
     if not RuntimeStatus.are_record_replay_modules_ready():
         ModuleApi.start('record_replay_required_modules')
     if not RuntimeStatus.are_all_hardware_ready():
         HardwareApi.health_check('all')
     cls.__exec_bash_tool('start_player')
     RuntimeStatus.get_tools().playing_status = ToolStatus.PLAYING_CHECKING
     RuntimeStatus.broadcast_status_if_changed()
예제 #9
0
 def setup_recording(cls):
     """SocketIO Api: setup_recording()"""
     if not RuntimeStatus.are_record_replay_modules_ready():
         ModuleApi.start('record_replay_required_modules')
     if not RuntimeStatus.are_all_hardware_ready():
         HardwareApi.health_check('all')
     RuntimeStatus.get_tools().recording_status = (
         ToolStatus.RECORDING_CHECKING)
     RuntimeStatus.broadcast_status_if_changed()
예제 #10
0
 def reset_recording(cls):
     """SocketIO Api: reset_recording()"""
     file_to_play = gflags.FLAGS.file_to_play
     if os.path.exists(file_to_play):
         os.rename(file_to_play, file_to_play + '.bak')
     # Also stop player in case user has set it up.
     cls.__exec_bash_tool('stop_player')
     tool_status = RuntimeStatus.get_tools()
     tool_status.recording_status = ToolStatus.RECORDING_READY_TO_CHECK
     tool_status.playing_status = ToolStatus.PLAYING_NOT_READY
     tool_status.planning_ready = False
     RuntimeStatus.broadcast_status_if_changed()
예제 #11
0
    def switch_map(cls, *args):
        """SocketIO Api: switch_map(map_name)"""
        if len(args) != 1:
            Config.log.critical('ToolApi::switch_map bad args')
            return
        map_name = args[0]
        map_dir = Config.maps.get(map_name)
        if map_dir is None:
            Config.log.critical('Cannot find map %s', map_name)
            return
        with open(Config.get_pb().global_flagfile, 'a') as fout:
            fout.write('\n--map_dir={}\n'.format(map_dir))

        RuntimeStatus.pb_singleton.config.current_map = map_name
        RuntimeStatus.broadcast_status_if_changed()
예제 #12
0
    def switch_vehicle(cls, *args):
        """SocketIO Api: switch_vehicle(vehicle_name)"""
        if len(args) != 1:
            Config.log.critical('ToolApi::switch_vehicle bad args')
            return
        vehicle_name = args[0]
        vehicle_path = Config.vehicles.get(vehicle_name)
        if vehicle_path is None:
            Config.log.critical('Cannot find vehicle %s', vehicle_name)
            return

        # Copy vehicle_param_pb.
        conf_pb = Config.get_pb()
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'vehicle_param.pb.txt'),
            conf_pb.vehicle_param_pb_target_path)
        # Copy calibration_table.
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'calibration_table.pb.txt'),
            conf_pb.calibration_table_target_path)
        # Copy velodyne_params.
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'velodyne_params'),
            Config.get_ros_path(conf_pb.velodyne_params_target_path))
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'start_velodyne.launch'),
            Config.get_ros_path(conf_pb.velodyne_launch_target_path))
        # Copy gnss_conf.
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'gnss_params/gnss_conf_mkz.txt'),
            Config.get_ros_path(conf_pb.gnss_conf_target_path))
        system_cmd.safe_copy(
            os.path.join(vehicle_path, 'gnss_params/gnss_driver.launch'),
            Config.get_ros_path(conf_pb.gnss_driver_target_path))

        RuntimeStatus.pb_singleton.config.current_vehicle = vehicle_name
        RuntimeStatus.broadcast_status_if_changed()
예제 #13
0
 def start_playing(cls):
     """SocketIO Api: start_playing()"""
     RosBridgeApi.change_driving_mode('auto')
     RuntimeStatus.get_tools().playing_status = ToolStatus.PLAYING
     RuntimeStatus.broadcast_status_if_changed()