def ExchangeArrivalTimes(self): """ Exchange V2V communications between the Icarous instances """ arrTimes = [] log = [] for ic in self.icInstances: if ic.arrTime is not None: arrTimes.append(ic.arrTime) for arr in arrTimes: fid = arr.intersectionID if fid <= 0: continue avail = False for g in log: if fid == g[0].intersectionID: avail = True g.append(arr) if not avail: log.append([arr]) for lg in log: if len(lg) == 0: continue datalog = LogData() datalog.intersectionID = lg[0].intersectionID datalog.nodeRole = 1 datalog.totalNodes = len(lg) mg = MergerData * MAX_NODES datalog.log = mg(*lg) for ic in self.icInstances: if ic.arrTime is None: continue if ic.arrTime.intersectionID == datalog.intersectionID: ic.InputMergeLogs(datalog, self.commDelay)
def ExchangeV2VData(self): """ Exchange V2V communications between the Icarous instances """ # Transmit all V2V data for ic in self.icInstances: # Do not broadcast if running SBN if "SBN" in ic.apps: continue if not ic.missionStarted or ic.missionComplete: continue # broadcast position data to all other vehicles in the airspace tfdata = V2Vdata("INTRUDER", { "callsign": ic.callsign, "pos": ic.position, "vel": ic.velocity }) ic.transmitter.transmit(self.current_time, ic.position, tfdata) # Gather logs to be exchanged for merging activity log = {} for ic in self.icInstances: if ic.arrTime is not None: intsid = ic.arrTime.intersectionID if intsid in log.keys(): log[intsid].append(ic.arrTime) else: log[intsid] = [ic.arrTime] # Transmit all merger log data for lg in log: datalog = LogData() datalog.intersectionID = log[lg][0].intersectionID datalog.nodeRole = 1 datalog.totalNodes = len(log[lg]) mg = MergerData * MAX_NODES datalog.log = mg(*log[lg]) for ic in self.icInstances: # Do not broadcast if running SBN if "SBN" in ic.apps: continue mergelog = V2Vdata("MERGER", datalog) ic.transmitter.transmit(self.current_time, ic.position, mergelog) # Receive all V2V data for ic in self.icInstances: if not ic.missionStarted or ic.missionComplete: continue received_msgs = ic.receiver.receive(self.current_time, ic.position) data = [m.data for m in received_msgs] ic.InputV2VData(data) self.comm_channel.flush()
def __init__(self, initialPos, simtype="UAS_ROTOR", vehicleID = 0, fasttime = True, verbose=0,callsign = "SPEEDBIRD", monitor="DAIDALUS", daaConfig="data/DaidalusQuadConfig.txt"): self.fasttime = fasttime self.callsign = callsign self.verbose = verbose self.home_pos = [initialPos[0], initialPos[1], initialPos[2]] self.traffic = [] if simtype == "UAM_VTOL": self.ownship = VehicleSim(vehicleID,0.0,0.0,0.0,0.0,0.0,0.0) else: from quadsim import QuadSim self.ownship = QuadSim() self.vehicleID = vehicleID self.Cog = Cognition(callsign) self.Guidance = Guidance(GuidanceParam()) self.Geofence = GeofenceMonitor([3,2,2,20,20]) self.Trajectory = Trajectory(callsign) self.tfMonitor = TrafficMonitor(callsign,daaConfig,False,monitor) self.Merger = Merger(callsign,vehicleID) # Aircraft data self.flightplan1 = [] self.etaFP1 = False self.etaFP2 = False self.flightplan2 = [] self.controlInput = [0.0,0.0,0.0] self.fenceList = [] self.guidanceMode = GuidanceMode.NOOP # Merger self.arrTime = None self.logLatency = 0 self.prevLogUpdate = 0 self.mergerLog = LogData() self.position = self.home_pos self.velocity = [0.0,0.0,0.0] self.trkgsvs = [0.0,0.0,0.0] self.localPos = [] self.ownshipLog = {"t": [], "position": [], "velocityNED": [], "positionNED": [], "trkbands": [], "gsbands": [], "altbands": [], "vsbands": [], "localPlans": [], "localFences": [], "commandedVelocityNED": []} self.trafficLog = {} self.emergbreak = False if self.fasttime: self.currTime = 0 else: self.currTime = time.time() self.numSecPlan = 0 self.plans = [] self.fences = [] self.mergeFixes = [] self.localPlans = [] self.localFences= [] self.localMergeFixes = [] self.daa_radius = 0 self.startSent = False self.nextWP1 = 1 self.nextWP2 = 1 self.numFences = 0 self.resSpeed = 0 self.defaultWPSpeed = 1 self.missionComplete = False self.fphases = -1 self.land = False self.activePlan = "Plan0" self.windFrom = 0 self.windSpeed = 0
def __init__(self, home_pos, callsign="SPEEDBIRD", vehicleID=0, verbose=1, logRateHz=5, fasttime=True, simtype="UAS_ROTOR", monitor="DAIDALUS", daaConfig="data/DaidalusQuadConfig.txt"): """ Initialize pycarous :param fasttime: when fasttime is True, simulation will run in fasttime :param simtype: string defining vehicle model: UAS_ROTOR, UAM_VTOL, ... :param monitor: string defining DAA module: DAIDALUS, ACAS, ... :param daaConfig: DAA module configuration file Other parameters are defined in parent class, see IcarousInterface.py """ super().__init__(home_pos, callsign, vehicleID, verbose) self.simType = "pycarous" self.fasttime = fasttime if self.fasttime: self.currTime = 0 else: self.currTime = time.time() # Initialize vehicle sim if simtype == "UAM_VTOL": from vehiclesim import UamVtolSim self.ownship = UamVtolSim(self.vehicleID, home_pos) elif simtype == "UAS_ROTOR": from vehiclesim import QuadSim self.ownship = QuadSim(self.vehicleID, home_pos) elif simtype == "UAM_SPQ": from vehiclesim import SixPassengerQuadSim self.ownship = SixPassengerQuadSim(self.vehicleID, home_pos) # Initialize ICAROUS apps self.Cog = Cognition(self.callsign) self.Guidance = Guidance(GuidanceParam()) self.Geofence = GeofenceMonitor([3, 2, 2, 20, 20]) self.Trajectory = Trajectory(self.callsign) self.tfMonitor = TrafficMonitor(self.callsign, daaConfig, False, monitor) self.Merger = Merger(self.callsign, self.vehicleID) # Merger data self.arrTime = None self.logLatency = 0 self.prevLogUpdate = 0 self.mergerLog = LogData() self.localMergeFixes = [] # Fligh plan data self.flightplan1 = [] self.flightplan2 = [] self.etaFP1 = False self.etaFP2 = False self.nextWP1 = 1 self.nextWP2 = 1 self.plans = [] self.localPlans = [] self.activePlan = "Plan0" self.numSecPlan = 0 # Geofence data self.fences = [] self.localFences= [] self.numFences = 0 # Other aircraft data self.guidanceMode = GuidanceMode.NOOP self.emergbreak = False self.daa_radius = 0 self.turnRate = 0 self.fphases = -1 self.land = False self.ditch = False self.loopcount = 0 #teste self.fp = []