コード例 #1
0
ファイル: pool.py プロジェクト: pista329/cqla
class ConnectionPool:
    def __init__(self, keyspace, server_list=["localhost"], port=None, **kwargs):
        """
            TODO:
                 credentials=None,
                 timeout=0.5,
                 use_threadlocal=True,
                 pool_size=5,
                 prefill=True,
                 socket_factory=default_socket_factory,
                 transport_factory=default_transport_factory,
                 **kwargs):
        """
        self._manager = SystemManager(server_list, port=port)
        self._manager.set_keyspace(keyspace)
コード例 #2
0
    def test_get_swap_usage(self):
        flexmock(utils).should_receive("get_secret").and_return("fake secret")

        expected_keys = [JSONTags.SWAP, JSONTags.FREE, JSONTags.USED]
        actual = json.loads(SystemManager().get_swap_usage("fake secret"))
        actual_keys = [actual.keys()[0]]
        for key in actual.values()[0].keys():
            actual_keys.append(key)

        self.assertSetEqual(set(expected_keys), set(actual_keys))
コード例 #3
0
    def test_get_disk_usage(self):
        flexmock(utils).should_receive("get_secret").and_return("fake secret")

        expected_keys = [JSONTags.DISK, JSONTags.FREE, JSONTags.USED]
        actual = json.loads(SystemManager().get_disk_usage("fake secret"))
        actual_keys = [actual.keys()[0]]

        # Example: {'disk': [ {'/': {'used': 3513118720, 'free': 5747404800}} ]}
        if len(actual.values()[0]) > 0:
            for key in actual.values()[0][0].values()[0].keys():
                actual_keys.append(key)

        self.assertSetEqual(set(expected_keys), set(actual_keys))
コード例 #4
0
    def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, ssl=True):
        """
    Initialize a new instance of the infrastructure manager service.

    Args:
      host  Hostname to which the service should bind (Optional). Defaults
            to 0.0.0.0.
      port  Port of the service (Optional). Default to 17444.
      ssl   True if SSL should be engaged or False otherwise (Optional).
            Defaults to True. When engaged, this implementation expects
            to find the necessary SSL certificates in the /etc/appscale/certs
            directory.
    """
        self.host = host
        self.port = port

        secret = None
        while True:
            try:
                secret = utils.get_secret(self.APPSCALE_DIR + 'secret.key')
                break
            except Exception:
                logging.info('Waiting for the secret key to become available')
                utils.sleep(5)
        logging.info('Found the secret set to: {0}'.format(secret))

        SOAPpy.Config.simplify_objects = True

        if ssl:
            logging.info('Checking for the certificate and private key')
            cert = self.APPSCALE_DIR + 'certs/mycert.pem'
            key = self.APPSCALE_DIR + 'certs/mykey.pem'
            while True:
                if os.path.exists(cert) and os.path.exists(key):
                    break
                else:
                    logging.info('Waiting for certificates')
                    utils.sleep(5)

            ssl_context = SSL.Context()
            ssl_context.load_cert(cert, key)
            self.server = SOAPpy.SOAPServer((host, port),
                                            ssl_context=ssl_context)
        else:
            self.server = SOAPpy.SOAPServer((host, port))

        parent_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
        config_file = os.path.join(parent_dir, self.CONFIG_FILE)
        if os.path.exists(config_file):
            with open(config_file) as file_handle:
                params = json.load(file_handle)
            if params.has_key(PersistentStoreFactory.PARAM_STORE_TYPE):
                logging.info(
                    'Loading infrastructure manager configuration from ' +
                    config_file)
                i = InfrastructureManager(params)
            else:
                i = InfrastructureManager()
        else:
            i = InfrastructureManager()

        self.server.registerFunction(i.describe_operation)
        self.server.registerFunction(i.run_instances)
        self.server.registerFunction(i.terminate_instances)
        self.server.registerFunction(i.attach_disk)

        system_manager = SystemManager()

        self.server.registerFunction(system_manager.get_cpu_usage)
        self.server.registerFunction(system_manager.get_disk_usage)
        self.server.registerFunction(system_manager.get_memory_usage)
        self.server.registerFunction(system_manager.get_service_summary)
        self.server.registerFunction(system_manager.get_swap_usage)
        self.server.registerFunction(system_manager.get_loadavg)

        self.started = False
コード例 #5
0
ファイル: utils.py プロジェクト: olavblj/thesis-pong
from datetime import datetime, timezone, timedelta

import numpy as np

from config import Path
from system_manager import SystemManager

sys_manager = SystemManager.get_instance()


def date_str(timestamp):
    return datetime.fromtimestamp(timestamp, tz=timezone(offset=timedelta(hours=2)))


def fetch_highscore():
    file_path = Path.high_score_list

    names = []
    scores = []
    with open(file_path) as infile:
        for i, line in enumerate(infile):
            tokens = [t.strip() for t in line.split(";")]
            name, score = tokens
            names.append(name)
            scores.append(int(score))

    order = np.flip(np.argsort(scores))
    scores = np.array(scores)[order]
    names = np.array(names)[order]

    res = []
コード例 #6
0
parser_other.add_argument("--l1d_tag_latency", default="")
parser_other.add_argument("--l1i_tag_latency", default="")
parser_other.add_argument("--l2_tag_latency", default="")
parser_other.add_argument("--l3_tag_latency", default="")

parser_other.add_argument("--branch_predictor", default='TournamentBP')

args = main_parser.parse_args()
print(args)
############################################################
# Setup system
############################################################

print(bcol.I("Setting up system ..."))
print(bcol.W("Using " + args.cpu + " CPU."))
system = SystemManager(args).getSystem(args)
print(bcol.OK("Done."))
print("")

############################################################
# Setup process
############################################################

print(bcol.I("Setting up the process to run ..."))
process = Process()

if args.subcommand == "run-benchmark":
    print(bcol.W("Custom benchmark selected."))
    print(bcol.W("Command           : " + args.cmd))
    print(
        bcol.W("Command-line args : " +
コード例 #7
0
ファイル: observer.py プロジェクト: radarku/state_observer
    def __init__(self, is_sitl, is_airsim):

        self.manager = SystemManager(is_sitl)

        if is_sitl:

            nodes_filename = 'nodes_sitl.yaml'

        else:

            nodes_filename = 'nodes.yaml'
        
        with open(sys.path[0] + '/../config/' + nodes_filename, 'r') as stream:

            NODES = yaml.load(stream)

        # Add any key suffix (for multi-platform configurations)
        self.platform_suffix = rospy.get_param('~platform_suffix', "")
        print('platform_suffix = ' + self.platform_suffix)
        self.adjust_keys_for_platform_suffix(NODES)

        for k,v in NODES.items():
                    
            # Let all nodes know their names - which are their keys in the NODES map
            v['name'] = k

            v['topic_type'] = eval(v['topic_type'])

        # Setting dynamic parameters for the dwa planner
        self.global_dwa_params = {
            'acc_lim_x': 0.5,
            'max_vel_x': 0.5, 
            'min_vel_x': -0.15, 
            'max_vel_trans': 0.5, 
            'min_vel_trans': -0.15,  

            'max_vel_theta': 0.5, 
            'min_vel_theta': -0.5,
            'acc_lim_theta': 1.5,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 1.0, 
            'yaw_goal_tolerance': 0.2,

            'path_distance_bias': 10.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.05
            
            }

        self.global_locost_params = {
            'width': 8.0,
            'height': 8.0
        }

        self.global_glocost_params = {
            'width': 30.0,
            'height': 30.0
        }

        self.transition_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.35, 
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.35, 
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.5, 
            'min_vel_theta': -0.5,
            'acc_lim_theta': 1.0,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.5, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.03
            
            }

        self.transition_locost_params = {
            'width': 2.5,
            'height': 2.5
        }

        self.transition_glocost_params = {
            'width': 20.0,
            'height': 20.0
        }
        
        self.slam_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.3,
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.3,
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.35, 
            'min_vel_theta': -0.35,
            'acc_lim_theta': 0.75,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.35, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 24.0,
            'occdist_scale' : 0.03
            
            }

        self.slam_locost_params = {
            'width': 12.0,
            'height': 12.0
        }

        self.slam_glocost_params = {
            'width': 20.0,
            'height': 20.0
        }
        
        self.amcl_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.3,
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.3,
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.35, 
            'min_vel_theta': -0.35,
            'acc_lim_theta': 0.75,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.5, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.03
            
            }

        self.amcl_locost_params = {
            'width': 8.0,
            'height': 8.0
        }

        self.amcl_glocost_params = {
            'width': 15.0,
            'height': 15.0
        }

        if is_sitl == False:

            print("Hardware mode")

            self.common_nodes = {k:v for k,v in NODES.items() if k in ['roscore', 'robot', 'video', 'state_obs', 'april_tags', 'rosbridge', 'realsense', 'imu', 'drive', 'lidar', 'ekf', 'navigation']}.values()

            self.global_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv', 'control_global']}.values()

            self.transition_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv']}.values()

            self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()

            self.amcl_nodes = {k:v for k,v in NODES.items() if k in ['amcl', 'map_local']}.values()

        else:

            if is_airsim:

                print("AirSim mode")

                common_node_names = ['roscore', 'video', 'state_obs', 'april_tags', 'rosbridge', 'sitl', 'ekf', 'navigation', 'rviz']
                common_node_names = self.adjust_strings_for_platform_suffix(common_node_names)

                global_node_names = ['map_tf', 'gps_driver_airsim', 'nav_sat', 'control_global']
                global_node_names = self.adjust_strings_for_platform_suffix(global_node_names)

                print('Common node names: ')
                print(common_node_names)

                self.common_nodes = {k:v for k,v in NODES.items() if k in common_node_names}.values()
                self.global_nodes = {k:v for k,v in NODES.items() if k in global_node_names}.values()

                transition_node_names = ['map_tf', 'gps_driver','gps_conv']
                transition_node_names = self.adjust_strings_for_platform_suffix(transition_node_names)
                self.transition_nodes = {k:v for k,v in NODES.items() if k in transition_node_names}.values()

                slam_node_names = ['map', 'map_local']
                slam_node_names = self.adjust_strings_for_platform_suffix(slam_node_names)
                self.slam_nodes = {k:v for k,v in NODES.items() if k in slam_node_names}.values()

                self.global_nodes = {k:v for k,v in NODES.items() if k in ['gps_driver_airsim', 'gps_conv', 'control_global']}.values()

                self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()
            
            else:

                print("Gazebo mode")

                self.common_nodes = {k:v for k,v in NODES.items() if k in ['roscore', 'video', 'state_obs', 'april_tags', 'rosbridge', 'sitl', 'ekf', 'navigation', 'rviz']}.values()

                self.global_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv', 'control_global']}.values()

                self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()

                self.amcl_nodes = {k:v for k,v in NODES.items() if k in ['amcl', 'map_local']}.values()

                self.transition_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv']}.values()

        self.system_states = ['idle', 'broadcasting', 'fault']

        self.system_modes = ['', 'slam', 'amcl','global', 'transition']

        self.system_nodes = {'': [], 'slam': self.slam_nodes, 'amcl': self.amcl_nodes, 'global': self.global_nodes, 'transition': self.transition_nodes}

        self.system_dwa_params = {'': [], 'slam': self.slam_dwa_params, 'amcl': self.amcl_dwa_params, 'global': self.global_dwa_params, 'transition': self.transition_dwa_params}

        self.system_locost_params = {'': [], 'slam': self.slam_locost_params, 'amcl': self.amcl_locost_params, 'global': self.global_locost_params, 'transition': self.transition_locost_params}

        self.system_glocost_params = {'': [], 'slam': self.slam_glocost_params, 'amcl': self.amcl_glocost_params, 'global': self.global_glocost_params, 'transition': self.transition_glocost_params}


        self.current_system_mode = ''

        self.current_system_diagnostics = ''

        self.startup_mode = True

        self.update_system_on = False

        self.failed_nodes = []

        self.to_be_healed = []

        self.count = 0
コード例 #8
0
ファイル: observer.py プロジェクト: radarku/state_observer
class Observer:

    def adjust_keys_for_platform_suffix(self, dictionary):

        for k,v in dictionary.items():
            new_key = k + self.platform_suffix
            print('Old key: ' + k + ', key with suffix: ' + new_key)
            del dictionary[k]
            dictionary[new_key] = v


    def adjust_strings_for_platform_suffix(self, string_array):

        result = []
        for name in string_array:
            result.append(name + self.platform_suffix)
        return result


    def __init__(self, is_sitl, is_airsim):

        self.manager = SystemManager(is_sitl)

        if is_sitl:

            nodes_filename = 'nodes_sitl.yaml'

        else:

            nodes_filename = 'nodes.yaml'
        
        with open(sys.path[0] + '/../config/' + nodes_filename, 'r') as stream:

            NODES = yaml.load(stream)

        # Add any key suffix (for multi-platform configurations)
        self.platform_suffix = rospy.get_param('~platform_suffix', "")
        print('platform_suffix = ' + self.platform_suffix)
        self.adjust_keys_for_platform_suffix(NODES)

        for k,v in NODES.items():
                    
            # Let all nodes know their names - which are their keys in the NODES map
            v['name'] = k

            v['topic_type'] = eval(v['topic_type'])

        # Setting dynamic parameters for the dwa planner
        self.global_dwa_params = {
            'acc_lim_x': 0.5,
            'max_vel_x': 0.5, 
            'min_vel_x': -0.15, 
            'max_vel_trans': 0.5, 
            'min_vel_trans': -0.15,  

            'max_vel_theta': 0.5, 
            'min_vel_theta': -0.5,
            'acc_lim_theta': 1.5,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 1.0, 
            'yaw_goal_tolerance': 0.2,

            'path_distance_bias': 10.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.05
            
            }

        self.global_locost_params = {
            'width': 8.0,
            'height': 8.0
        }

        self.global_glocost_params = {
            'width': 30.0,
            'height': 30.0
        }

        self.transition_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.35, 
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.35, 
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.5, 
            'min_vel_theta': -0.5,
            'acc_lim_theta': 1.0,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.5, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.03
            
            }

        self.transition_locost_params = {
            'width': 2.5,
            'height': 2.5
        }

        self.transition_glocost_params = {
            'width': 20.0,
            'height': 20.0
        }
        
        self.slam_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.3,
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.3,
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.35, 
            'min_vel_theta': -0.35,
            'acc_lim_theta': 0.75,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.35, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 24.0,
            'occdist_scale' : 0.03
            
            }

        self.slam_locost_params = {
            'width': 12.0,
            'height': 12.0
        }

        self.slam_glocost_params = {
            'width': 20.0,
            'height': 20.0
        }
        
        self.amcl_dwa_params = {
            'acc_lim_x': 0.25, 
            'max_vel_x': 0.3,
            'min_vel_x': -0.1, 
            'max_vel_trans': 0.3,
            'min_vel_trans': -0.1,  

            'max_vel_theta': 0.35, 
            'min_vel_theta': -0.35,
            'acc_lim_theta': 0.75,

            'sim_time': 3.5,
            'vx_samples': 10,
            'vth_samples': 10,

            'xy_goal_tolerance': 0.5, 
            'yaw_goal_tolerance': 0.15,

            'path_distance_bias': 32.0,
            'goal_distance_bias': 20.0,
            'occdist_scale' : 0.03
            
            }

        self.amcl_locost_params = {
            'width': 8.0,
            'height': 8.0
        }

        self.amcl_glocost_params = {
            'width': 15.0,
            'height': 15.0
        }

        if is_sitl == False:

            print("Hardware mode")

            self.common_nodes = {k:v for k,v in NODES.items() if k in ['roscore', 'robot', 'video', 'state_obs', 'april_tags', 'rosbridge', 'realsense', 'imu', 'drive', 'lidar', 'ekf', 'navigation']}.values()

            self.global_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv', 'control_global']}.values()

            self.transition_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv']}.values()

            self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()

            self.amcl_nodes = {k:v for k,v in NODES.items() if k in ['amcl', 'map_local']}.values()

        else:

            if is_airsim:

                print("AirSim mode")

                common_node_names = ['roscore', 'video', 'state_obs', 'april_tags', 'rosbridge', 'sitl', 'ekf', 'navigation', 'rviz']
                common_node_names = self.adjust_strings_for_platform_suffix(common_node_names)

                global_node_names = ['map_tf', 'gps_driver_airsim', 'nav_sat', 'control_global']
                global_node_names = self.adjust_strings_for_platform_suffix(global_node_names)

                print('Common node names: ')
                print(common_node_names)

                self.common_nodes = {k:v for k,v in NODES.items() if k in common_node_names}.values()
                self.global_nodes = {k:v for k,v in NODES.items() if k in global_node_names}.values()

                transition_node_names = ['map_tf', 'gps_driver','gps_conv']
                transition_node_names = self.adjust_strings_for_platform_suffix(transition_node_names)
                self.transition_nodes = {k:v for k,v in NODES.items() if k in transition_node_names}.values()

                slam_node_names = ['map', 'map_local']
                slam_node_names = self.adjust_strings_for_platform_suffix(slam_node_names)
                self.slam_nodes = {k:v for k,v in NODES.items() if k in slam_node_names}.values()

                self.global_nodes = {k:v for k,v in NODES.items() if k in ['gps_driver_airsim', 'gps_conv', 'control_global']}.values()

                self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()
            
            else:

                print("Gazebo mode")

                self.common_nodes = {k:v for k,v in NODES.items() if k in ['roscore', 'video', 'state_obs', 'april_tags', 'rosbridge', 'sitl', 'ekf', 'navigation', 'rviz']}.values()

                self.global_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv', 'control_global']}.values()

                self.slam_nodes = {k:v for k,v in NODES.items() if k in ['map', 'map_local', 'explore']}.values()

                self.amcl_nodes = {k:v for k,v in NODES.items() if k in ['amcl', 'map_local']}.values()

                self.transition_nodes = {k:v for k,v in NODES.items() if k in ['map_tf', 'gps_driver', 'gps_conv']}.values()

        self.system_states = ['idle', 'broadcasting', 'fault']

        self.system_modes = ['', 'slam', 'amcl','global', 'transition']

        self.system_nodes = {'': [], 'slam': self.slam_nodes, 'amcl': self.amcl_nodes, 'global': self.global_nodes, 'transition': self.transition_nodes}

        self.system_dwa_params = {'': [], 'slam': self.slam_dwa_params, 'amcl': self.amcl_dwa_params, 'global': self.global_dwa_params, 'transition': self.transition_dwa_params}

        self.system_locost_params = {'': [], 'slam': self.slam_locost_params, 'amcl': self.amcl_locost_params, 'global': self.global_locost_params, 'transition': self.transition_locost_params}

        self.system_glocost_params = {'': [], 'slam': self.slam_glocost_params, 'amcl': self.amcl_glocost_params, 'global': self.global_glocost_params, 'transition': self.transition_glocost_params}


        self.current_system_mode = ''

        self.current_system_diagnostics = ''

        self.startup_mode = True

        self.update_system_on = False

        self.failed_nodes = []

        self.to_be_healed = []

        self.count = 0


    def update_system_info(self, which_nodes = 'all'):

        self.failed_nodes = []

        if which_nodes == 'all':

            current_nodes = self.common_nodes + self.system_nodes[self.current_system_mode]

        elif which_nodes == 'healed':

            current_nodes = self.to_be_healed

        # checking node health
        for node in current_nodes:

            if node['method'] == 'topic':

                try:

                    rospy.wait_for_message(node['topic'], node['topic_type'], node['timeout'])

                except:

                    self.failed_nodes.append(node['name'])

            elif node['method'] == 'node':

                if self.manager.check_package(node['name']):

                    self.failed_nodes.append(node['name'])

            elif node['method'] == 'websocket':

                try: 

                    self.ws = create_connection("ws://localhost:9090")

                    self.ws.send("ping_websocket")

                except:

                    self.failed_nodes.append(node['name'])


    def heal_nodes(self):

        self.to_be_healed = {k:v for k,v in NODES.items() if k in self.failed_nodes}.values()

        print(self.to_be_healed)

        self.manager.restart_stack(self.to_be_healed)


    def get_system_info(self):

        self.update_system_on = True

        self.update_system_info()

        if self.failed_nodes != []: 

            self.current_system_diagnostics = 'faulty nodes: ' + str(self.failed_nodes)

        else:

            self.current_system_diagnostics = 'system healthy'

        self.startup_mode = False

        self.update_system_on = False
        
        return (self.current_system_mode, self.current_system_diagnostics)


    def set_system_mode(self, new_mode):

        self.reconf_dwa = dynamic_reconfigure.client.Client('/MOVE/DWAPlannerROS')

        self.reconf_locost = dynamic_reconfigure.client.Client('/MOVE/local_costmap')

        self.reconf_glocost = dynamic_reconfigure.client.Client('/MOVE/global_costmap')

        nodes  = []

        all_nodes = (self.common_nodes + self.system_nodes[new_mode])

        print(all_nodes)

        for node in all_nodes:
            
            nodes.append(node['name'])

        cur_nodes = self.manager.get_active_packages()

        to_be_stopped = [x for x in cur_nodes if x not in nodes]

        for stack in to_be_stopped:

            self.manager.stop_package(stack)

        self.current_system_mode = new_mode

        to_be_started_keys = [x for x in nodes if x not in cur_nodes]

        to_be_started = [k for k in all_nodes if k['name'] in to_be_started_keys]

        self.manager.start_stack(to_be_started)

        self.reconf_dwa.update_configuration(self.system_dwa_params[new_mode])

        self.reconf_locost.update_configuration(self.system_locost_params[new_mode])

        self.reconf_glocost.update_configuration(self.system_glocost_params[new_mode])

        return 'mode set to: ' + str(self.current_system_mode)


    def system_reset(self):

        self.count = 0
        
        self.startup_mode = True

        self.manager.restart_stack(self.common_nodes + self.system_nodes[self.current_system_mode])

            

    
           
コード例 #9
0
import discord
import yaml
from modules.reminders import delayed_response
from system_manager import SystemManager
from bot_response_unit import Responder
from bot_tasks import calendar_task, birthday_task, reminder_task
from commands import MainCommand
from modules.reactions import reactor

configuration = yaml.safe_load(open("settings.yml"))

# Secret Token
TOKEN = configuration['secret_token']

client = discord.Client()
system = SystemManager(configuration)
bot_responder = Responder(client, system)


@client.event
async def on_ready():
    """
    Method that is called when the bot is ready.
    """
    print("The bot is ready.")
    system.bot = client.user
    # Add Bot Birthday & Nickname into any database.
    if system.database_manager:
        system.database_manager.insert_bot(system.bot)
    await bot_responder.change_visual_id()