예제 #1
0
    def test_conflicts(self):

        simulation = self.SimulationMock()
        airport = Airport.create("simple")

        a1 = Aircraft("A1", None, self.n1, State.stop)
        a2 = Aircraft("A2", None, self.n1, State.stop)
        a3 = Aircraft("A3", None, self.n2, State.stop)

        airport.aircrafts.append(a1)
        airport.aircrafts.append(a2)
        airport.aircrafts.append(a3)

        # Get only one conflict
        self.assertEqual(len(airport.conflicts), 1)

        # Test if the conflict looks like what we expected
        conflict = airport.conflicts[0]
        self.assertTrue(conflict.locations[0] == self.n1)
        self.assertEqual(len(conflict.aircrafts), 2)
        self.assertTrue(a1 in conflict.aircrafts)
        self.assertTrue(a2 in conflict.aircrafts)

        # Add one far aircraft to the same spot
        a4 = Aircraft("A4", None, self.n1, State.stop)
        airport.aircrafts.append(a4)

        # Test if the third aircraft shown in conflict correctly
        self.assertEqual(len(airport.conflicts), 3)
예제 #2
0
 def __init__(self,
              frame='',
              max_speed=20,
              max_accel=30,
              wheelbase=0.335,
              wheeltrack=0.296,
              max_wheel_turn=35,
              turning_circle=1.8,
              skid_turn_rate=140, # degrees/sec
              skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.turning_circle = turning_circle
     self.wheelbase = wheelbase
     self.wheeltrack = wheeltrack
     self.max_wheel_turn = max_wheel_turn
     self.last_time = self.time_now
     self.skid_steering = skid_steering
     self.skid_turn_rate = skid_turn_rate
     if self.skid_steering:
         # these are taken from a 6V wild thumper with skid steering,
         # with a sabertooth controller
         self.max_accel = 14
         self.max_speed = 4
예제 #3
0
    def __init__(self,
                 frame='+',
                 hover_throttle=0.65,
                 terminal_velocity=40.0,
                 frame_height=0.1,
                 hover_lean=8.0,
                 yaw_zero=0.1,
                 rotor_rot_accel=radians(20),
                 mass=2.13):
        Aircraft.__init__(self)
        self.mass = mass  # Kg
        self.hover_throttle = hover_throttle
        self.terminal_velocity = terminal_velocity
        self.terminal_rotation_rate = 4 * radians(360.0)
        self.frame_height = frame_height
        self.last_time = time.time()
        self.roll_rate_max = radians(1400)
        self.pitch_rate_max = radians(1400)
        self.yaw_rate_max = radians(1400)
        self.rsc_setpoint = 0.8
        self.thrust_scale = (self.mass * self.gravity) / self.hover_throttle
        self.rotor_rot_accel = rotor_rot_accel

        # calculate lateral thrust ratio for tail rotor
        self.tail_thrust_scale = sin(
            radians(hover_lean)) * self.thrust_scale / yaw_zero
예제 #4
0
    def test_deterministic_scheduler_with_one_conflict(self):

        Config.params["scheduler"]["name"] = "deterministic_scheduler"
        a1 = Aircraft("A1", None, self.g1, State.stop)
        a3 = Aircraft("A3", None, self.g2, State.stop)

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            a1, a3, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule, priority = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a3 has an early departure time, so it goes first
        self.assertTrue(self.a1 in schedule.itineraries)
        self.assertTrue(self.a3 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a1]
        iti2 = schedule.itineraries[self.a3]

        self.assertEqual(iti1.targets[1].nodes[0], self.g1)
        self.assertEqual(iti1.targets[1].nodes[1], self.s1)
        self.assertEqual(iti1.targets[2].nodes[0], self.s1)
        self.assertEqual(iti1.targets[2].nodes[1], self.runway_start)

        self.assertEqual(iti2.targets[2].nodes[0], self.g2)
        self.assertEqual(iti2.targets[2].nodes[1], self.s1)
        self.assertEqual(iti2.targets[3].nodes[0], self.s1)
        self.assertEqual(iti2.targets[3].nodes[1], self.runway_start)
예제 #5
0
 def __init__(
         self,
         frame='',
         max_speed=20,
         max_accel=30,
         wheelbase=0.335,
         wheeltrack=0.296,
         max_wheel_turn=35,
         turning_circle=1.8,
         skid_turn_rate=140,  # degrees/sec
         skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.turning_circle = turning_circle
     self.wheelbase = wheelbase
     self.wheeltrack = wheeltrack
     self.max_wheel_turn = max_wheel_turn
     self.last_time = self.time_now
     self.skid_steering = skid_steering
     self.skid_turn_rate = skid_turn_rate
     if self.skid_steering:
         # these are taken from a 6V wild thumper with skid steering,
         # with a sabertooth controller
         self.max_accel = 14
         self.max_speed = 4
예제 #6
0
파일: rover.py 프로젝트: robolamp/rAutotest
    def __init__(self,
                 max_speed=2,
                 max_accel=1.5,
                 wheelbase=1.8,
                 wheeltrack=1.3,
                 max_wheel_turn=35,
                 turning_circle=5,
                 skid_turn_rate=9, # degrees/sec
				 accel_by_pds = 4.46, # m/s^2
				 accel_by_enge = 1.12,
				 accel_by_idle = 0.45,
                 skid_steering=False):
        Aircraft.__init__(self)
        self.max_speed = max_speed
        self.max_accel = max_accel
        self.turning_circle = turning_circle
        self.wheelbase = wheelbase
        self.wheeltrack = wheeltrack
        self.max_wheel_turn = max_wheel_turn
        self.last_time = time.time()
        self.skid_steering = skid_steering
        self.skid_turn_rate = skid_turn_rate
        self.accel_by_pds = accel_by_pds
        self.accel_by_enge = accel_by_enge
        self.accel_by_idle = accel_by_idle
        if self.skid_steering:
            # these are taken from a 6V wild thumper with skid steering,
            # with a sabertooth controller
            self.max_accel = 14
            self.max_speed = 4
예제 #7
0
 def __init__(self,
              max_speed=10,
              max_accel=10,
              max_turn_rate=45):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.max_turn_rate = max_turn_rate
     self.last_time = time.time()
예제 #8
0
 def __init__(self,
              max_speed=10,
              max_accel=10,
              max_turn_rate=45,
              skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.max_turn_rate = max_turn_rate
     self.last_time = time.time()
     self.skid_steering = skid_steering
예제 #9
0
파일: rover.py 프로젝트: gcm70/ardupilot
 def __init__(self,
              max_speed=13,
              max_accel=10,
              max_turn_rate=100,
              skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.max_turn_rate = max_turn_rate
     self.last_time = time.time()
     self.skid_steering = skid_steering
예제 #10
0
 def __init__(self, frame="+", hover_throttle=0.65, terminal_velocity=40.0, frame_height=0.1, mass=2.5):
     Aircraft.__init__(self)
     self.mass = mass  # Kg
     self.hover_throttle = hover_throttle
     self.terminal_velocity = terminal_velocity
     self.terminal_rotation_rate = 4 * radians(360.0)
     self.frame_height = frame_height
     self.last_time = time.time()
     self.roll_rate_max = radians(720)
     self.pitch_rate_max = radians(720)
     self.yaw_rate_max = radians(720)
     self.rsc_setpoint = 0.8
     self.thrust_scale = (self.mass * self.gravity) / self.hover_throttle
예제 #11
0
    def __init__(self, frame="generic"):
        Aircraft.__init__(self)

        self.sim = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sim.connect(('127.0.0.1', 9002))
        self.sim.setblocking(0)
        self.accel_body = Vector3(0, 0, -self.gravity)
        self.frame = frame
        self.last_timestamp = 0
        if self.frame.find("heli") != -1:
            self.decode_servos = self.decode_servos_heli
        else:
            self.decode_servos = self.decode_servos_fixed_wing
예제 #12
0
    def __init__(self, frame="generic"):
        Aircraft.__init__(self)

        self.sim = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sim.connect(('127.0.0.1', 9002))
        self.sim.setblocking(0)
        self.accel_body = Vector3(0, 0, -self.gravity)
        self.frame = frame
        self.last_timestamp = 0
        if self.frame.find("heli") != -1:
            self.decode_servos = self.decode_servos_heli
        else:
            self.decode_servos = self.decode_servos_fixed_wing
예제 #13
0
class Flight():
    """Main flight plan driver application."""
    def __init__(self):
        """Start up aircraft."""
        self.aircraft = Aircraft()

    def run(self):
        """Start application."""
        print(f'Battery: {self.aircraft.battery}%')
        self.aircraft.take_off()
        self.aircraft.fly('../samples/square.json')
        # self.aircraft.land()
        print(f'Battery: {self.aircraft.battery}%')
예제 #14
0
    def __init__(self):
        Aircraft.__init__(self)
        self.motor_speed = [ 0.0, 0.0, 0.0, 0.0 ]
        self.mass = 1.0 # Kg
        self.hover_throttle = 0.37
        self.terminal_velocity = 30.0
        self.frame_height = 0.1

        # scaling from total motor power to Newtons. Allows the copter
        # to hover against gravity when each motor is at hover_throttle
        self.thrust_scale = (self.mass * self.gravity) / (4.0 * self.hover_throttle)

        self.last_time = time.time()
예제 #15
0
    def __init__(self, conf):
        self.conf = conf
        self.aircraft = Aircraft()
        self.flight_phase = FlightPhase(self.aircraft)
        self.flight = Flight()
        self.time = 0
        self.sample_rate = 1  # Hz

        self.recording = False

        self.flush_interval_sec = 10
        self.flush_time = 0

        self.flight_data = []
예제 #16
0
    def __init__(self, frame="+", hover_throttle=0.37, terminal_velocity=30.0, frame_height=0.1, mass=1.0):
        Aircraft.__init__(self)
        self.motors = build_motors(frame)
        self.motor_speed = [0.0] * len(self.motors)
        self.mass = mass  # Kg
        self.hover_throttle = hover_throttle
        self.terminal_velocity = terminal_velocity
        self.terminal_rotation_rate = 4 * radians(360.0)
        self.frame_height = frame_height

        # scaling from total motor power to Newtons. Allows the copter
        # to hover against gravity when each motor is at hover_throttle
        self.thrust_scale = (self.mass * self.gravity) / (len(self.motors) * self.hover_throttle)

        self.last_time = time.time()
예제 #17
0
 def __init__(self, callsign, model, from_airport, to_gate, runway,
              arrival_time, appear_time):
     super().__init__(Aircraft(callsign, model, None, State.flying))
     self.from_airport = from_airport
     self.to_gate = to_gate
     self.arrival_time = arrival_time
     self.appear_time = appear_time
예제 #18
0
 def __init__(self, callsign, model, to_airport, from_gate, runway,
              departure_time, appear_time):
     super().__init__(Aircraft(callsign, model, None, State.stop))
     self.to_airport = to_airport
     self.from_gate = from_gate
     self.departure_time = departure_time
     self.appear_time = appear_time
예제 #19
0
    def get_all_aircraft(self) -> [Aircraft]:
        """
        Returns list of all aircraft scanner has seen regardless of whether it 
        has received all Aircraft information (such as tail number or Flight #)
        :return: List of Airfract seen by the receiver
        """ 
        _raw_aircraft_data = self._query(self._scanner_aircraft_path)

        # List of attributes from aircraft JSON. Is there a better way? 
        _response_keys = [
            'hex',
            'flight',
            'squawk',
            'lat',
            'lon',
            'alt_geom', #altitude
            'geom_rate',
            'track',
            'gs',
            'seen' ,
        ]

        known_aircarft = []
        _parameters = {}
        # To-Do: n^2, need something better instead of brute force,
        # (Replace with generator? )
        for i in _raw_aircraft_data['aircraft']:
            for k in _response_keys:
                try:
                    _parameters.update({k : i[k]})
                except KeyError: # Data was not picked up by reciever
                    pass  
            known_aircarft.append(Aircraft(**_parameters))
            _parameters = {}
        return known_aircarft
예제 #20
0
 def __init__(self,
              max_speed=20,
              max_accel=30,
              wheelbase=0.335,
              wheeltrack=0.296,
              max_wheel_turn=35,
              turning_circle=1.8,
              skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.turning_circle = turning_circle
     self.wheelbase = wheelbase
     self.wheeltrack = wheeltrack
     self.max_wheel_turn = max_wheel_turn
     self.last_time = time.time()
     self.skid_steering = skid_steering
예제 #21
0
 def __init__(self, frame='+',
              hover_throttle=0.65,
              terminal_velocity=40.0,
              frame_height=0.1,
              mass=2.5):
     Aircraft.__init__(self)
     self.mass = mass # Kg
     self.hover_throttle = hover_throttle
     self.terminal_velocity = terminal_velocity
     self.terminal_rotation_rate = 4*radians(360.0)
     self.frame_height = frame_height
     self.last_time = time.time()
     self.roll_rate_max = radians(720)
     self.pitch_rate_max = radians(720)
     self.yaw_rate_max = radians(720)
     self.rsc_setpoint = 0.8
     self.thrust_scale = (self.mass * self.gravity) / self.hover_throttle
예제 #22
0
 def __init__(self,
              max_speed=20,
              max_accel=30,
              wheelbase=0.335,
              wheeltrack=0.296,
              max_wheel_turn=35,
              turning_circle=1.8,
              skid_steering=False):
     Aircraft.__init__(self)
     self.max_speed = max_speed
     self.max_accel = max_accel
     self.turning_circle = turning_circle
     self.wheelbase = wheelbase
     self.wheeltrack = wheeltrack
     self.max_wheel_turn = max_wheel_turn
     self.last_time = time.time()
     self.skid_steering = skid_steering
예제 #23
0
 def connect_to(self, comm_port):
     aircraft = Aircraft(comm_port)
     # wait for the heartbeat msg to find the system ID
     print("Waiting for APM heartbeat from aircraft %s" % comm_port)
     aircraft.wait_heartbeat()
     print("I saw a heartbeat, now I am going to acknowledge I have seen the aircraft")
     aircraft.send_ack()
     print("Waiting for APM home location from aircraft %s" % comm_port)
     aircraft.wait_set_home_location()
     self.aircrafts[comm_port] = aircraft
예제 #24
0
    def _update_aircraft(cls, msg: Message) -> None:
        for craft in cls.aircraft:
            if craft == msg.icao:
                craft.update(msg.data)
                break
        else:
            cls.aircraft.insert(0, Aircraft(msg.icao, msg.data))

        if len(cls.aircraft) > 100:
            cls.aircraft = cls.aircraft[25:]
예제 #25
0
def eachAircraft():

    groundstation = Groundstation()

    aircraft_seen = {}

    conn = sqlite3.connect('flightevents.db')

    nmea = open('data.nmea', 'r')

    for line in nmea:
        try:
            commas = line.count(',')
            sentence = pynmea2.parse(line, check=True)
        except pynmea2.ChecksumError:
            # ignore sentences that produce a checksum error
            continue
        except pynmea2.ParseError:
            # ignore sentences that can't be parsed
            continue

        # ignore Flarm PFLAU sentences
        if Observation.is_pflau_sentence(sentence):
            continue

        # The groundstation must have received the UTC time from the GPS
        # before we permit any processing of Flarm PFLAA observations.
        if (groundstation.valid_time()
                and Observation.is_pflaa_sentence(sentence)):
            observation = Observation()
            if observation.set(conn, groundstation, sentence):
                aircraft_id = observation.get_aircraft_id()
                if aircraft_id not in aircraft_seen:
                    aircraft_seen[aircraft_id] = Aircraft(aircraft_id)
                aircraft_seen[aircraft_id].append_observations(observation)

        elif sentence.sentence_type == 'RMC':
            # this sentence contains the current date
            groundstation.set_date(sentence.datestamp)
            groundstation.set(sentence)
        elif (sentence.sentence_type == 'GGA' and groundstation.valid_date()
              and commas == 14):

            # this sentence has the groundstation timestamp, lat, lon, elevation
            groundstation.set(sentence)

    conn.commit()
    conn.close()

    print("%s" % list(aircraft_seen.keys()))

    groundstation.report()

    return
예제 #26
0
 def __init__(self,
              rate_controlled=False,
              pitch_range = 45,
              yaw_range = 180,
              zero_yaw = 270, # yaw direction at startup
              zero_pitch = 10, # pitch at startup
              turn_rate=20 # servo max turn rate in degrees/sec
              ):
     Aircraft.__init__(self)
     self.rate_controlled = rate_controlled
     self.turn_rate = turn_rate
     self.last_time = time.time()
     self.pitch_range = pitch_range
     self.yaw_range = yaw_range
     self.zero_yaw = zero_yaw
     self.zero_pitch = zero_pitch
     self.verbose = False
     self.last_debug = time.time()
     self.pitch_current = 0
     self.yaw_current = 0
예제 #27
0
    def __init__(self):
        Aircraft.__init__(self)
        self.max_rpm = 1200
        self.have_new_time = False
        self.have_new_imu = False
        self.have_new_pos = False

        topics = {
            "/clock": (self.clock_cb, rosgraph_msgs.Clock),
            "/iris/imu": (self.imu_cb, sensor_msgs.Imu),
            "/iris/vehicle_local_position": (self.pos_cb, px4.vehicle_local_position),
        }

        rospy.init_node("ArduPilot", anonymous=True)
        for topic in topics.keys():
            (callback, msgtype) = topics[topic]
            rospy.Subscriber(topic, msgtype, callback)

        self.motor_pub = rospy.Publisher("/iris/command/motor_speed", mav_msgs.CommandMotorSpeed, queue_size=1)
        self.last_time = 0
예제 #28
0
def game_Runner():

    pygame.init()  # Initialize

    game_settings = Setting()
    screen = pygame.display.set_mode(
        (game_settings.screen_width, game_settings.screen_height))
    pygame.display.set_caption("Aircraft Game")

    # create an aircraft
    aircraft = Aircraft(game_settings, screen)
    missiles = Group()

    # loop of processing
    while True:

        function.check_events(game_settings, screen, aircraft, missiles)
        aircraft.update()
        missiles.update()

        function.update_screen(game_settings, screen, aircraft, missiles)
예제 #29
0
    def __init__(self,
                 frame='+',
                 hover_throttle=0.45,
                 terminal_velocity=15.0,
                 frame_height=0.1,
                 mass=1.5):
        Aircraft.__init__(self)
        self.motors = build_motors(frame)
        self.motor_speed = [0.0] * len(self.motors)
        self.mass = mass  # Kg
        self.hover_throttle = hover_throttle
        self.terminal_velocity = terminal_velocity
        self.terminal_rotation_rate = 4 * radians(360.0)
        self.frame_height = frame_height

        # scaling from total motor power to Newtons. Allows the copter
        # to hover against gravity when each motor is at hover_throttle
        self.thrust_scale = (self.mass * self.gravity) / (len(self.motors) *
                                                          self.hover_throttle)

        self.last_time = self.time_now
예제 #30
0
 def __init__(self,
              onoff=False,
              yawrate=9.0,
              pitchrate=1.0,
              pitch_range = 45,
              yaw_range = 170,
              zero_yaw = 270, # yaw direction at startup
              zero_pitch = 10 # pitch at startup
              ):
     Aircraft.__init__(self)
     self.onoff = onoff
     self.yawrate = yawrate
     self.pitchrate = pitchrate
     self.last_time = time.time()
     self.pitch_range = pitch_range
     self.yaw_range = yaw_range
     self.zero_yaw = zero_yaw
     self.zero_pitch = zero_pitch
     self.verbose = False
     self.last_debug = time.time()
     self.pitch_current = 0
     self.yaw_current = 0
예제 #31
0
    def load_data(filename):
        aircraft_dict = {}
        with open(os.path.join("", "clean_files", filename),
                  "rt",
                  encoding="utf8") as f:

            reader = csv.reader(f)

            for row in reader:
                aircraft_code = row[0]
                # remove cr
                aircraft_dict[aircraft_code] =\
                    Aircraft(row[0], row[1], row[2], row[3], row[4])
        return aircraft_dict
예제 #32
0
    def __init__(self):
        Aircraft.__init__(self)
        self.max_rpm = 1200
        self.have_new_time = False
        self.have_new_imu = False
        self.have_new_pos = False

        topics = {
            "/clock": (self.clock_cb, rosgraph_msgs.Clock),
            "/iris/imu": (self.imu_cb, sensor_msgs.Imu),
            "/iris/vehicle_local_position":
            (self.pos_cb, px4.vehicle_local_position),
        }

        rospy.init_node('ArduPilot', anonymous=True)
        for topic in topics.keys():
            (callback, msgtype) = topics[topic]
            rospy.Subscriber(topic, msgtype, callback)

        self.motor_pub = rospy.Publisher('/iris/command/motor_speed',
                                         mav_msgs.CommandMotorSpeed,
                                         queue_size=1)
        self.last_time = 0
예제 #33
0
 def __init__(
         self,
         onoff=False,
         yawrate=9.0,
         pitchrate=1.0,
         pitch_range=45,
         yaw_range=170,
         zero_yaw=270,  # yaw direction at startup
         zero_pitch=10  # pitch at startup
 ):
     Aircraft.__init__(self)
     self.onoff = onoff
     self.yawrate = yawrate
     self.pitchrate = pitchrate
     self.last_time = time.time()
     self.pitch_range = pitch_range
     self.yaw_range = yaw_range
     self.zero_yaw = zero_yaw
     self.zero_pitch = zero_pitch
     self.verbose = False
     self.last_debug = time.time()
     self.pitch_current = 0
     self.yaw_current = 0
예제 #34
0
    def __init__(self, frame='+',
                 hover_throttle=0.65,
                 terminal_velocity=40.0,
                 frame_height=0.1,
                 hover_lean=8.0,
                 yaw_zero=0.1,
                 rotor_rot_accel=radians(20),
                 mass=2.13):
        Aircraft.__init__(self)
        self.mass = mass # Kg
        self.hover_throttle = hover_throttle
        self.terminal_velocity = terminal_velocity
        self.terminal_rotation_rate = 4*radians(360.0)
        self.frame_height = frame_height
        self.last_time = time.time()
        self.roll_rate_max = radians(1400)
        self.pitch_rate_max = radians(1400)
        self.yaw_rate_max = radians(1400)
        self.rsc_setpoint = 0.8
        self.thrust_scale = (self.mass * self.gravity) / self.hover_throttle
        self.rotor_rot_accel=rotor_rot_accel

        # calculate lateral thrust ratio for tail rotor
        self.tail_thrust_scale = sin(radians(hover_lean)) * self.thrust_scale / yaw_zero
예제 #35
0
 def __init__(self, path, fromdate=None):
     self.flex_start = 0
     self.flex_end = 0
     date_regexp = re.compile(r'\d{1,2}/\d{1,2}/\d{4}\s\d{1,2}:\d{1,2}')
     self.aclist = []
     import pandas as pd
     df = pd.read_csv(path, sep=',', header=0)
     df["ACTUAL_ARRIVAL_DT"] = pandas.to_datetime(df["ACTUAL_ARRIVAL_DT"],
                                                  dayfirst=True)
     df["ACTUAL_DEPARTURE_DT"] = pandas.to_datetime(
         df["ACTUAL_DEPARTURE_DT"], dayfirst=True)
     arr = df.sort_values(by="ACTUAL_DEPARTURE_DT")
     for row in arr.values:
         if 'XXX' in row[7:8]:
             continue
         if row[3] == row[4]:
             continue
         if fromdate is not None:
             if row[3].value // 10**9 < datetime.datetime.strptime(
                     fromdate, "%d/%m/%Y").timestamp():
                 continue
         self.aclist.append(
             Aircraft(row[8],
                      row[7],
                      row[3].value // 10**9,
                      row[4].value // 10**9,
                      debug=False,
                      flight_type_code=row[9]))
         if self.flex_start == 0:
             self.flex_start = row[3].value // 10**9
             self.flex_end = row[4].value // 10**9
         else:
             if row[3].value // 10**9 < self.flex_start:
                 self.flex_start = row[3].value // 10**9
             if row[4].value // 10**9 > self.flex_end:
                 self.flex_end = row[4].value // 10**9
예제 #36
0
 def __init__(self, max_ammo, base_damage):
     Aircraft.__init__(self, max_ammo, base_damage)
예제 #37
0
class TestScheduler(unittest.TestCase):

    Config.params["simulator"]["test_mode"] = True
    Config.params["simulation"]["time_unit"] = 30

    #     (G1)
    #      |
    #      | <3647.9 ft, 12.2 mins>
    #      |
    #     (S1)-----<2456.7 ft, 8:11 mins>-----(RANWAY.start)
    #      |
    #      | <3647.9 ft, 12.2 mins>
    #      |
    #     (G2)

    g1 = Node("G1", {"lat": 47.812000, "lng": -122.079057})
    g2 = Node("G2", {"lat": 47.832000, "lng": -122.079057})
    s1 = Spot("S1", {"lat": 47.822000, "lng": -122.079057})
    runway_start = RunwayNode({"lat": 47.822000, "lng": -122.069057})

    a1 = Aircraft("A1", None, g1, State.stop)
    a2 = Aircraft("A2", None, g2, State.stop)
    a3 = Aircraft("A3", None, g2, State.stop)

    a4 = Aircraft("A4", None, s1, State.stop)
    a5 = Aircraft("A5", None, s1, State.stop)

    class AirportMock():

        def __init__(self, simulation, aircraft1, aircraft2):
            self.aircrafts = [aircraft1, aircraft2]
            self.aircraft1 = aircraft1
            self.aircraft2 = aircraft2

        def apply_schedule(self, schedule):
            for aircraft, itinerary in schedule.itineraries.items():
                if aircraft == self.aircraft1:
                    self.aircraft1.set_itinerary(itinerary)
                else:
                    self.aircraft2.set_itinerary(itinerary)

        def set_quiet(self, logger):
            self.aircraft1.logger = logger
            self.aircraft2.logger = logger

        def tick(self):
            self.aircraft1.tick()
            self.aircraft2.tick()

        @property
        def conflicts(self):
            if self.aircraft1.location == self.aircraft2.location:
                return [Conflict(None, [self.aircraft1, self.aircraft2])]
            return []

        @property
        def next_conflicts(self):
            if self.aircraft1.itinerary is None or\
               self.aircraft2.itinerary is None:
                return []
            if self.aircraft1.itinerary.next_target is None or\
               self.aircraft2.itinerary.next_target is None:
                return []
            if self.aircraft1.itinerary.next_target == \
               self.aircraft2.itinerary.next_target:
                return [Conflict(None, [self.aircraft1, self.aircraft2])]
            return []

    class RunwayMock():

        def __init__(self, runway_start):
            self.runway_start = runway_start

        @property
        def start(self):
            return self.runway_start

    class ScenarioMock():

        def __init__(self, g1, g2, s1, runway_start):
            self.runway = TestScheduler.RunwayMock(runway_start)
            self.g1, self.g2, self.s1 = g1, g2, s1

        def get_flight(self, aircraft):
            if aircraft.callsign == "A1":
                return DepartureFlight(
                    "A1", None, None, self.g1, self.s1, self.runway,
                    time(2, 36), time(2, 36)
                )
            elif aircraft.callsign == "A2":
                return DepartureFlight(
                    "A2", None, None, self.g2, self.s1, self.runway,
                    time(2, 36, 30), time(2, 36, 30)
                )
            elif aircraft.callsign == "A3":
                return DepartureFlight(
                    "A3", None, None, self.g2, self.s1, self.runway,
                    time(2, 36, 1), time(2, 36, 1)
                )
            elif aircraft.callsign == "A4":
                return DepartureFlight(
                    "A4", None, None, self.g2, self.s1, self.runway,
                    time(2, 36, 1), time(2, 36, 1)
                )
            elif aircraft.callsign == "A5":
                return DepartureFlight(
                    "A5", None, None, self.g2, self.s1, self.runway,
                    time(2, 36, 2), time(2, 36, 2)
                )

    class RouteMock():

        def __init__(self, nodes):
            self.nodes = nodes

    class RoutingExpertMock():

        def __init__(self, g1, g2, s1, runway_start):
            self.g1, self.g2, self.s1 = g1, g2, s1
            self.runway_start = runway_start

        def get_shortest_route(self, src, dst):

            if src == self.g1 and dst == self.runway_start:
                return TestScheduler.RouteMock([self.g1, self.s1,
                                                self.runway_start])

            if src == self.g2 and dst == self.runway_start:
                return TestScheduler.RouteMock([self.g2, self.s1,
                                                self.runway_start])

            if src == self.s1 and dst == self.runway_start:
                return TestScheduler.RouteMock([self.s1, self.runway_start])

            else:
                raise Exception("Unsupported routing query")

    class SimulationMock():

        def __init__(self, a1, a2, g1, g2, s1, runway_start):
            self.airport = TestScheduler.AirportMock(self, a1, a2)
            self.scenario = TestScheduler.ScenarioMock(
                g1, g2, s1, runway_start)
            self.routing_expert = TestScheduler.RoutingExpertMock(
                g1, g2, s1, runway_start)
            self.clock = Clock()
            self.clock.now = time(2, 30)

        def set_quiet(self, logger):
            self.airport.set_quiet(logger)

        def remove_aircrafts(self):
            pass

        def pre_tick(self):
            pass

        def tick(self):
            self.clock.tick()
            self.airport.tick()

        def post_tick(self):
            pass

        @property
        def now(self):
            return self.clock.now

        @property
        def copy(self):
            s = deepcopy(self)
            s.set_quiet(logging.getLogger("QUIET_MODE"))
            return s

    def test_deterministic_scheduler_with_one_conflict(self):

        Config.params["scheduler"]["name"] = "deterministic_scheduler"

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            self.a1, self.a3, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a3 has an early departure time, so it goes first
        self.assertTrue(self.a1 in schedule.itineraries)
        self.assertTrue(self.a3 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a1]
        iti2 = schedule.itineraries[self.a3]

        self.assertEqual(iti1.targets[0], self.g1)
        self.assertEqual(iti1.targets[1], self.s1)
        self.assertEqual(iti1.targets[2], self.runway_start)

        self.assertEqual(iti2.targets[0], self.g2)
        self.assertEqual(iti2.targets[1], self.g2)
        self.assertEqual(iti2.targets[2], self.s1)
        self.assertEqual(iti2.targets[3], self.runway_start)

    def test_deterministic_scheduler_with_one_unsolvable_conflict(self):

        # Sets two aircraft standing at the same node
        self.a4.location = self.s1
        self.a5.location = self.s1

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            self.a4, self.a5, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a3 has an early departure time, so it goes first
        self.assertTrue(self.a4 in schedule.itineraries)
        self.assertTrue(self.a5 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a4]
        iti2 = schedule.itineraries[self.a5]

        self.assertEqual(schedule.n_unsolvable_conflicts, 0)

        self.assertEqual(iti1.targets[0], self.s1)
        self.assertEqual(iti1.targets[1], self.runway_start)

        self.assertEqual(iti2.targets[0], self.s1)
        self.assertEqual(iti2.targets[1], self.s1)
        self.assertEqual(iti2.targets[2], self.runway_start)
import numpy as np

from aircraft import Aircraft
from atmosphere import Atmosphere, Wind
from constants import Constants
import sim_setup

from Planes.B737 import B737
from Planes.C172 import C172
from Planes.T38 import T38

# Initialization of objects used in overall sim architecture
SIM = sim_setup.Sim_Parameters()
CONSTANTS = Constants()
Atmosphere = Atmosphere()
plane1 = Aircraft()

####################################################################################################
# BEGIN INPUT FIELDS
####################################################################################################

# Modify simulation parameters
SIM.START_TIME = 0.0
SIM.END_TIME = 2000.0
SIM.DELTA_T = 2

# Modify aircraft inital conditions

# Choose airplane type - B737, C172, T38
plane1.design = B737()
예제 #39
0
        m += 1

    return heading_differences


######################Scenario###############################################
target_1 = Target("target_1", 1, 100, 370,
                  100)  #(name, location, speed, heading, power)
target_2 = Target("target_2", 5, 100, 900, 100)
target_3 = Target("target_3", 9, 100, 90, 100)
target_4 = Target("target_4", 4, 100, 270, 100)

print("number of targets is: ", Target.number_of_targets)
print("number of targets is: ", Target.number_of_targets, file=f)

aircraft_1 = Aircraft("aircraft_1", 365, 100, 10000,
                      0)  #(name, heading, speed, altitude, ownship_location)

target_list = Target.target_list
#target_list = [target_1, target_2, target_3, target_4]

#print(target_list, file = f)

target_names = [o.name for o in target_list]
target_locations = [o.location for o in target_list]
target_powers = [o.power for o in target_list]
target_speeds = [o.speed for o in target_list]
target_headings = [o.heading for o in target_list]

beam_width = 5.0
half_power_beam_width = beam_width / 2
예제 #40
0
파일: quadsim.py 프로젝트: yschaeff/quadsim
	pygame.draw.rect(screen, blue, (mx-quad.radius*ppm, my, 2*quad.radius*ppm, quad.beamwidth*ppm+1))
	## draw forces
	for i in range(quad.motors):
		pygame.draw.line(screen, red, (mx-quad.motor_pos[i][0]*ppm, my),
			(mx-quad.motor_pos[i][0]*ppm,my-quad.target_force[i][1]*fscale), 5)
		pygame.draw.line(screen, green, (mx-quad.motor_pos[i][0]*ppm, my),
			(mx-quad.motor_pos[i][0]*ppm, my-quad.current_force[i][1]*fscale), 3)
		pygame.draw.line(screen, green, (mx, my), (mx, my-ppm), 3)

## Simulation initialization
t = time()*SPEED
dt = 1.0/FPS
t_sim = t
world = World(G, AIR_DENSITY)
sim = QuadSimulator(SIMULATIONS_PER_SECOND)
quad = Aircraft(RADIUS, MASS, MAX_THRUST, ADJUST_RATE, GYRO_SIGMA, ACC_SIGMA)
controller  = Controller(quad, world, CONTROLLER_CYCLE_TIME, ACRO_MODE)

pygame.init()
font_obj = pygame.font.SysFont("monospace", 25)
screen = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
backdrop = draw_backdrop((WIN_WIDTH, WIN_HEIGHT), PIXELS_PER_METER)

while True:
	#collect user input
	for event in pygame.event.get():
		if event.type == QUIT:
			pygame.quit()
			sys.exit()

	keys = pygame.key.get_pressed()
예제 #41
0
    def test_tick_with_delay(self):

        itinerary = deepcopy(self.itinerary_template)

        aircraft = Aircraft("F1", "M1", self.n1, State.stop)
        aircraft.set_location(self.n1)
        self.assertEqual(aircraft.state, State.stop)

        # Stop state
        aircraft.tick()
        self.assertEqual(aircraft.itinerary, None)

        # Moving state
        aircraft.set_itinerary(itinerary)
        self.assertTrue(aircraft.itinerary)
        self.assertEqual(aircraft.state, State.moving)
        self.assertEqual(aircraft.itinerary.current_target, self.n1)

        # targets: n1 - n2 - n3
        aircraft.add_uncertainty_delay()
        # targets: n1 - n1 - n2 - n3

        aircraft.tick()
        # targets: n1 - n2 - n3
        self.assertEqual(aircraft.itinerary.current_target, self.n1)

        aircraft.add_uncertainty_delay()
        # targets: n1 - n1 - n2 - n3
        self.assertEqual(aircraft.itinerary.current_target, self.n1)

        aircraft.tick()
        # targets: n1 - n2 - n3
        self.assertEqual(aircraft.itinerary.current_target, self.n1)

        aircraft.tick()
        # targets: n2 - n3
        self.assertEqual(aircraft.itinerary.current_target, self.n2)
예제 #42
0
    def test_tick(self):

        itinerary = deepcopy(self.itinerary_template)

        aircraft = Aircraft("F1", "M1", self.n1, State.stop)
        aircraft.set_location(self.n1)
        self.assertEqual(aircraft.state, State.stop)

        # Stop state
        aircraft.tick()
        self.assertEqual(aircraft.itinerary, None)

        # Moving state
        aircraft.set_itinerary(itinerary)
        self.assertTrue(aircraft.itinerary)
        self.assertEqual(aircraft.state, State.moving)
        self.assertEqual(aircraft.itinerary.current_target, self.n1)

        aircraft.tick()
        self.assertEqual(aircraft.itinerary.current_target, self.n2)

        aircraft.tick()
        self.assertEqual(aircraft.itinerary.current_target, self.n3)

        aircraft.tick()
        self.assertTrue(aircraft.itinerary.is_completed)
예제 #43
0
    def test_init(self):

        aircraft = Aircraft("F1", "M1", self.n1, State.unknown)
        aircraft.set_location(self.n1)
        self.assertEqual(aircraft.location, self.n1)
예제 #44
0
    def __init__(self, logger):
        """
        Initialize and create a new HUD.
        """

        self.__last_perf_render__ = None
        self.__logger__ = logger
        self.__view_element_timers = {}
        self.__fps__ = RollingStats('FPS')
        self.__texture_cache_size__ = RollingStats('TextureCacheSize')
        self.__texture_cache_misses__ = RollingStats('TextureCacheMisses')
        self.__texture_cache_purges__ = RollingStats('TextureCachePurges')

        self.render_perf = TaskTimer('Render')
        self.frame_setup = TaskTimer('Setup')
        self.frame_cleanup = TaskTimer('Cleanup')

        self.__frame_timers__ = {
            'Setup': self.frame_setup,
            'Render': self.render_perf,
            'Cleanup': self.frame_cleanup
        }

        self.cache_perf = TaskTimer('Cache')

        self.__fps__.push(0)

        adsb_traffic_address = "ws://{0}/traffic".format(
            CONFIGURATION.stratux_address())
        self.__connection_manager__ = traffic.ConnectionManager(
            adsb_traffic_address)

        self.__backpage_framebuffer__, screen_size = display.display_init(
        )  # args.debug)
        self.__width__, self.__height__ = screen_size

        pygame.mouse.set_visible(False)

        pygame.font.init()
        self.__should_render_perf__ = False

        font_size_std = int(self.__height__ / 10.0)
        font_size_detail = int(self.__height__ / 12.0)
        font_size_loading = int(self.__height__ / 4.0)

        self.__font__ = pygame.font.Font(
            get_absolute_file_path("./assets/fonts/LiberationMono-Bold.ttf"),
            font_size_std)
        self.__detail_font__ = pygame.font.Font(
            get_absolute_file_path("./assets/fonts/LiberationMono-Bold.ttf"),
            font_size_detail)
        self.__loading_font__ = pygame.font.Font(
            get_absolute_file_path(
                "./assets/fonts/LiberationMono-Regular.ttf"),
            font_size_loading)
        self.__show_boot_screen__()

        self.__aircraft__ = Aircraft(self.__logger__)

        self.__pixels_per_degree_y__ = int(
            (self.__height__ / CONFIGURATION.get_degrees_of_pitch()) *
            CONFIGURATION.get_pitch_degrees_display_scaler())

        self.__ahrs_not_available_element__ = self.__build_ahrs_hud_element(
            ahrs_not_available.AhrsNotAvailable)

        self.__hud_views__ = self.__build_hud_views()

        self.__view_index__ = 0

        logger = None

        if self.__logger__ is not None:
            logger = self.__logger__.logger

        self.web_server = restful_host.HudServer()
        RecurringTask("rest_host",
                      0.1,
                      self.web_server.run,
                      start_immediate=False)
        RecurringTask("purge_old_traffic",
                      10.0,
                      self.__purge_old_reports__,
                      start_immediate=False)
        RecurringTask("update_traffic",
                      0.1,
                      self.__update_traffic_reports__,
                      start_immediate=True)
        RecurringTask("update_aithre",
                      5.0,
                      self.__update_aithre__,
                      start_immediate=True)