Пример #1
0
    def AddTraffic(self, idx, home, rng, brng, alt, speed, heading, crate,
                   transmitter="GroundTruth",delay=0.0):
        """
        Add a simulated virtual traffic vehicle to the simulation environment
        :param idx: traffic vehicle id
        :param home: home position (lat [deg], lon [deg], alt [m])
        :param rng: starting distance from home position [m]
        :param brng: starting bearing from home position [deg], 0 is North
        :param alt: starting altitude [m]
        :param speed: traffic speed [m/s]
        :param heading: traffic heading [deg], 0 is North
        :param crate: traffic climbrate [m/s]
        :param transmitter: A Transmitter to send V2V position data,
        ex: "ADS-B" or "GroundTruth", or None for no Transmitter
        """
        tx = rng*np.sin(brng*np.pi/180)
        ty = rng*np.cos(brng*np.pi/180)
        tz = alt
        tvx = speed*np.sin(heading*np.pi/180)
        tvy = speed*np.cos(heading*np.pi/180)
        tvz = crate
        traffic = UamVtolSim(idx, home, tx, ty, tz, tvx, tvy, tvz)
        traffic.InputCommand(heading, speed, crate)
        traffic.delay = delay
        self.tfList.append(traffic)

        # Create a transmitter for V2V communications
        traffic.transmitter = get_transmitter(transmitter, idx, self.comm_channel)

        return traffic
Пример #2
0
    def AddIcarousInstance(self, ic, delay=0, time_limit=1000,
                           transmitter="GroundTruth", receiver="GroundTruth"):
        """
        Add an Icarous instance to the simulation environment
        :param ic: An Icarous instance
        :param delay: Time to delay before starting mission (s)
        :param time_limit: Time limit to fly before shutting vehicle down (s)
        :param transmitter: A Transmitter to send V2V position data,
        ex: "ADS-B" or "GroundTruth", or None for no transmitter
        :param receiver: A Receiver to get V2V position data,
        ex: "ADS-B" or "GroundTruth", or None for no receiver
        """
        self.icInstances.append(ic)
        self.icStartDelay.append(delay)
        self.icTimeLimit.append(time_limit)

        # Create a transmitter and receiver for V2V communications
        ic.transmitter = get_transmitter(transmitter, ic.vehicleID, self.comm_channel)
        ic.receiver = get_receiver(receiver, ic.vehicleID, self.comm_channel)

        # Set simulation home position
        if self.home_gps == [0, 0, 0]:
            self.home_gps = ic.home_pos

        if self.verbose > 0:
            print(ic.callsign)
            print("\ttransmitter:", ic.transmitter.description)
            print("\treceiver:", ic.receiver.description)
Пример #3
0
    def AddGroundSystem(self, gs, transmitter="GroundTruth", receiver="GroundTruth"):
        """
        Add a GroundSystem instance to the simulation environment
        (A ground-based system that interacts with vehicles by transmitting/receiving messages)
        :param gs: A GroundSystem instance
        :param transmitter: A Transmitter to send V2V position data,
        ex: "ADS-B" or "GroundTruth", or None for no transmitter
        :param receiver: A Receiver to get V2V position data,
        ex: "ADS-B" or "GroundTruth", or None for no receiver
        """
        self.gsInstances.append(gs)

        # Create a transmitter and receiver for V2V communications
        gs.transmitter = get_transmitter(transmitter, gs.id, self.comm_channel)
        gs.receiver = get_receiver(receiver, gs.id, self.comm_channel)
Пример #4
0
    def __init__(self, logfile, channel, delay=0):
        """
        Initialize traffic log replay
        :param logfile: filename for csv traffic log containing columns for:
            time, vehicleID, lat, lon, alt, vN, vE, vD, [position uncertainty, velocity uncertainty]
            Properly formatted csv traffic logs can be generated from tlog, json, or daa
            log files using the read_traffic.py tool in SIRIUS
        :param channel: communication channel to replay traffic messages on
        :param delay: number of seconds to wait before starting log replay
        """
        self.delay = delay
        self.transmitter = get_transmitter("GroundTruth", "TrafficReplay", channel)

        # Read position updates from csv file
        self.position_updates = pd.read_csv(logfile, index_col="time")
        self.position_updates.sort_index(inplace=True)
        self.position_updates.index -= self.position_updates.index[0]

        self.current_time = None