Exemplo n.º 1
0
    def __init__(self,
                 _client,
                 _drones,
                 _initial_positions,
                 _malicious,
                 _anomaly_type,
                 _time_factor=1):
        Scenario.__init__(self, _client, _drones, _initial_positions,
                          _malicious, _anomaly_type, _time_factor)

        num_of_sim_drones = 5

        # Create a rectangle of size 200 x 200 and split randomly to all drones
        initial_rectangle = Rectangle((-25, -25), (25, 25))
        rectangles = initial_rectangle.divide(num_of_sim_drones)
        self.paths = [to_airsim_path(r.get_path()) for r in rectangles]

        # Set the time of the scenario to be the time it will take to survey the average rectangle
        # (2 is the velocity of the drones)
        distance_list = [r.get_distance() for r in rectangles]
        avg_distance = sum(distance_list) / len(distance_list)
        self.time = avg_distance / (2 * _time_factor)

        # The initial position each drone is the initial point in its path
        self.goto_initial_locations([path[0] for path in self.paths])

        self.started = False
        self.started_anomaly = False
        # Get the beginning time of the scenario
        self.start = time.perf_counter()
Exemplo n.º 2
0
    def __init__(self, sniff_thread, tcp_handshake, dpid):
        Scenario.__init__(self, sniff_thread, tcp_handshake)
        self.echo = False
        self.xid = 0
        self.dpid = dpid
        self.answer_features = False
        self.answer_config = False
        self.answer_barrier = False
        self.answer_role = False
        self.answer_stats = False
        self.answer_stats_ports = False
        self.answer_request_port_desc = False
        self.answer_stats_manufacturer = False
        self.answer_flow = False
        self.counter_dict = {
            'echo': 0,
            'config': 0,
            'features': 0,
            'barrier': 0,
            'role': 0,
            'stats': 0,
            'port_desc': 0,
            'flows': 0
        }

        self.rules = {}
    def __init__(self,
                 _client,
                 _drones,
                 _initial_positions,
                 _malicious,
                 _anomaly_type,
                 _time_factor=1):
        Scenario.__init__(self, _client, _drones, _initial_positions,
                          _malicious, _anomaly_type, _time_factor)

        self.started_anomaly = False
        self.pos = {}
        # the new initial positions will be later determined according to the goal & base axis
        self.initial_positions = []

        self.yaw = {}
        for drone in _drones:
            self.yaw[drone] = 0

        # The maximum step a drone can move in a single action
        self.step = 0.5
        # The distance to keep from obstacles
        self.coll_thres = 1.5

        # The first item in goal represents the axis (0 = x, 1 = y), the second item represents the index
        # (for example [1, 60] would represent that the goal is 60 on the y axis)
        self.goal = [0, 0]
        self.goal[0] = np.random.randint(0, 2)
        self.goal[1] = np.random.randint(-30, 30)

        # base represents the initial axis of the drones
        # its axis is the same as the goal, and its distance from the goal is 80-120 meters
        base_range = random.choice([(-120, -80), (80, 120)])
        self.base = self.goal[1] + random.randint(*base_range)

        # The time of the scenario is the minimum time needed to get from the base to the goal
        # (theoretically going in straight line, without obstacles on the way)
        self.time = abs(self.base - self.goal[1]) / (2 * _time_factor)

        # Set the drones in their initial locations
        self.goto_initial_locations()
        # Get the scenario's obstacles
        self.obstacles = self.get_obstacles()
        # Get the beginning time of the scenario
        self.start = time.perf_counter()
    def __init__(self,
                 _client,
                 _drones,
                 _initial_positions,
                 _malicious,
                 _anomaly_type,
                 _time_factor=1):
        Scenario.__init__(self, _client, _drones, _initial_positions,
                          _malicious, _anomaly_type, _time_factor)

        # if the time factor is 1, the scenario time should be 50 seconds
        self.monitoring_time = 50 / _time_factor

        self.path = {}
        self.generate_path()

        # Set the drones to be in their initial locations
        self.goto_initial_locations()

        self.started = False
        self.started_anomaly = False
        # Get the beginning time of the scenario
        self.start = time.perf_counter()
Exemplo n.º 5
0
    def __init__(self,
                 _client,
                 _drones,
                 _initial_positions,
                 _malicious,
                 _anomaly_type,
                 _time_factor=1):
        Scenario.__init__(self, _client, _drones, _initial_positions,
                          _malicious, _anomaly_type, _time_factor)

        self.Y = 100  # meter
        self.V = 2  # Ms
        self.monitoring_time = (self.Y / self.V) / _time_factor

        self.X = np.random.randint((0), (10))
        self.Z = np.random.randint((-4), (-2))

        # Set the drones to be in their initial locations
        self.goto_initial_locations()

        self.started = False
        self.started_anomaly = False
        # Get the beginning time of the scenario
        self.start = time.perf_counter()
Exemplo n.º 6
0
 def __init__(self, **attrs):
     Scenario.__init__(self, **attrs)
     
     self.full_reset()