Beispiel #1
0
 def forward_heartbeat(self, msg_class, msg_name, sender, message):
     hb = HeartBeat()
     hb.ParseFromString(message)
     # TELEMETRY_STATUS message
     msg = PprzMessage("ground", "TELEMETRY_STATUS")
     values = [
         str(self.aircraft_id), "no_id", "0.02", "0", "0", "0.0", "0", "0",
         "0", "0", "0", "9999.0"
     ]
     msg.set_values(values)
     self.interface.send(msg)
Beispiel #2
0
    def on_ivy_msg(self, agent, *larg):
        """ Split ivy message up into the separate parts
        Basically parts/args in string are separated by space, but char array can also contain a space:
        |f,o,o, ,b,a,r| in old format or "foo bar" in new format
        """
        # return if no callback is set
        if self.callback is None:
            return

        # first split on array delimiters
        l = re.split('([|\"][^|\"]*[|\"])', larg[0])
        # strip spaces and filter out emtpy strings
        l = [str.strip(s) for s in l if str.strip(s) is not '']
        data = []
        for s in l:
            # split non-array strings further up
            if '|' not in s and '"' not in s:
                data += s.split(' ')
            else:
                data.append(s)
        # ignore ivy message with less than 3 elements
        if len(data) < 3:
            return

        # check which message class it is
        # pass non-telemetry messages with ac_id 0
        if data[0] in ["sim", "ground_dl", "dl"]:
            if self.verbose:
                print("ignoring message " + larg[0])
                sys.stdout.flush()
            return
        elif data[0] in ["ground"]:
            msg_class = data[0]
            msg_name = data[1]
            ac_id = 0
            values = list(filter(None, data[2:]))
        else:
            try:
                ac_id = int(data[0])
            except ValueError:
                if self.verbose:
                    print("ignoring message " + larg[0])
                    sys.stdout.flush()
                return
            msg_class = "telemetry"
            msg_name = data[1]
            values = list(filter(None, data[2:]))
        msg = PprzMessage(msg_class, msg_name)
        msg.set_values(values)
        self.callback(ac_id, msg)
    def on_ivy_msg(self, agent, *larg):
        """ Split ivy message up into the separate parts
        Basically parts/args in string are separated by space, but char array can also contain a space:
        |f,o,o, ,b,a,r| in old format or "foo bar" in new format
        """
        # return if no callback is set
        if self.callback is None:
            return

        # first split on array delimiters
        l = re.split('([|\"][^|\"]*[|\"])', larg[0])
        # strip spaces and filter out emtpy strings
        l = [str.strip(s) for s in l if str.strip(s) is not '']
        data = []
        for s in l:
            # split non-array strings further up
            if '|' not in s and '"' not in s:
                data += s.split(' ')
            else:
                data.append(s)
        # ignore ivy message with less than 3 elements
        if len(data) < 3:
            return

        # check which message class it is
        # pass non-telemetry messages with ac_id 0
        if data[0] in ["sim", "ground_dl", "dl"]:
            if self.verbose:
                print("ignoring message " + larg[0])
                sys.stdout.flush()
            return
        elif data[0] in ["ground"]:
            msg_class = data[0]
            msg_name = data[1]
            ac_id = 0
            values = list(filter(None, data[2:]))
        else:
            try:
                ac_id = int(data[0])
            except ValueError:
                if self.verbose:
                    print("ignoring message " + larg[0])
                    sys.stdout.flush()
                return
            msg_class = "telemetry"
            msg_name = data[1]
            values = list(filter(None, data[2:]))
        msg = PprzMessage(msg_class, msg_name)
        msg.set_values(values)
        self.callback(ac_id, msg)
Beispiel #4
0
 def forward_position(self, msg_class, msg_name, sender, message):
     pos = Position()
     pos.ParseFromString(message)
     # FLIGHT_PARAM message
     msg = PprzMessage("ground", "FLIGHT_PARAM")
     values = [
         str(self.aircraft_id), "0.0", "0.0",
         str(pos.hdg),
         str(pos.lat),
         str(pos.lon),
         str(pos.vground), "0.0",
         str(pos.alt),
         str(pos.vz),
         str(pos.relalt), "0.0", "0", "0.0"
     ]
     msg.set_values(values)
     self.interface.send(msg)
Beispiel #5
0
	def codeRecognized (self, data):
		print data
		if data == '1':
			coords = 1
			print "Dropzone 1"
		elif data == '2':
			coords = 2
			print "Dropzone 2"
		elif data == '3':
			coords = 3
			print "Dropzone 3"
		else:
			print data
			return
		print('Going to: ', coords)
		pprzmsg = PprzMessage("ground", "DL_SETTING")
		pprzmsg.set_values([self.ac_id, self.waypoint_id, coords])
		self.interface.send(pprzmsg)