def __init__(self, uav, app, linkMgr): super().__init__() self.app = app self.uav = uav self.linkMgr = linkMgr self._vehicle = None self.marker_create = False self.uav_lat = None self.uav_lng = None self.message_recieved = 0 self.js_result = None # connect mode choose self.connect_type = uav['type'] if self.connect_type == 0: self.uav_name = uav['name'] self.ip = uav['ip'] self.port = uav['port'] self.icon = uav['icon'] self.network = '.'.join(self.ip.split('.')[:-1]) + '.0' self.mav = mavutil.mavlink_connection('network:' + self.network, ip_list=[self.ip], port=self.port) # type: mavutil.mavfile elif self.connect_type == 1: self.uav_name = uav['name'] self.ip = uav['ip'] self.port = uav['port'] self.icon = uav['icon'] self.mav = mavutil.mavlink_connection( 'udp:' + self.ip + ':' + str(self.port)) # type: mavutil.mavfile else: print('error: unknow connect_type: ', self.connect_type) return # ----- # Vehicle class attributes # self._firmwareType = 3 # MAV_AUTOPILOT_ARDUPILOTMEGA 3 # self._supportsMissionItemInt = False # ----- self.start()
import xlwt if __name__ == '__main__': with open('.cfg', 'r') as f: for line in f: if line.startswith('<StatusCenter>'): line = f.readline().strip() import sys sys.path.append(line) from parse import mavutil file_name = 'waypoints_201712261521' mf = mavutil.mavlink_connection(file_name + '.pcap', ip_list=['192.168.4.1']) xls = xlwt.Workbook() sheet = xls.add_sheet('sample') borders = xlwt.Borders() borders.left = 1 borders.right = 1 borders.top = 1 borders.bottom = 1 borders.left_colour = 1 borders.right_colour = 1 borders.top_colour = 1 borders.bottom_colour = 1
import sys sys.path.append('..') from parse import mavutil if __name__ == '__main__': mf = mavutil.mavlink_connection('../data/waypoints_201712261521.pcap', ip_list=['192.168.4.1']) file = open('misson_msg_buffer.txt', 'w') m = mf.recv_msg() ms = [] index = 1 while True: if m.get_msgId() in [x for x in range(39, 48)]: ms.append(m) file.write( '%4d:\t%3d\t%s %s\n' % (index, m.get_srcSystem(), m.get_type(), m.get_msgbuf())) index += 1 try: m = mf.recv_msg() except Exception as e: print(e) break
def __del__(self): self.udpCliSock.close() def msg_x_y(m, x, y): return mf.mav.gps_raw_int_encode(m.time_usec, m.fix_type, m.lat + x, m.lon + y, m.alt, m.eph, m.epv, m.vel, m.cog, m.satellites_visible) if __name__ == '__main__': #app = scApplication(sys.argv) #app.initForNormalAppBoot() mf = mavutil.mavlink_connection('data/test.pcap', ip_list=['192.168.1.4']) b = b"\xfe\x1e\x18\x01\x01\x18\x00\x00\x00\x00\x00\x00\x00\x00\x933\xc5\r\x84\xca\x8aC\x96&\x02\x00\x0f'\xff\xff\x00\x00\x00\x00\x01\x00|\xd6" b_heartbeat = b'\xfe\t{\x01\x01\x00\x00\x00\x00\x00\x02\x03Q\x03\x03"\r' m = mf.mav.decode(bytearray(b)) m_heartbeat = mf.mav.decode(bytearray(b_heartbeat)) m_t = m us = udp_send() N = 100000 #- 99999 for i in range(N): n1 = 10 n2 = 100 if i % n1 == 0: m1 = msg_x_y(m, i * 5, i * 5)
import sys sys.path.append('..') from parse import mavutil if __name__ == '__main__': mav = mavutil.mavlink_connection('udp:192.168.42.1:14550')
if line.startswith('<FileName>'): line = f.readline().strip() # type: str if line.endswith('.pcap'): line = line[0:-5] file_name = line if line.startswith('<IP>'): line = f.readline().strip() # type: str IP = line if line.startswith('<port>'): line = f.readline().strip() # type: str port = line mf = mavutil.mavlink_connection(file_name + '.pcap', ip_list=[IP], port=eval(port)) xls = xlwt.Workbook() sheet = xls.add_sheet('sample') borders = xlwt.Borders() borders.left = 1 borders.right = 1 borders.top = 1 borders.bottom = 1 borders.left_colour = 1 borders.right_colour = 1 borders.top_colour = 1 borders.bottom_colour = 1
from parse import mavutil from capture.udp_file import multi_mav_udp import sys, time, random def requestDataStream(mavfile, stream, start_stop=1, rate=10): # MAV_DATA_STREAM stream msg = mavfile.mav.request_data_stream_encode( 1, # target_system 1, # target_component stream, # req_stream_id rate, # req_message_rate start_stop # start_stop : 1 to start sending, 0 to stop sending. (uint8_t) ) mavfile.mav.send(msg) if __name__ == '__main__': ip = '192.168.1.2' port = 14555 mf = mavutil.mavlink_connection('udp:' + ip + ':' + str(port)) print('requestDataStream(mf, 1)') print('requestDataStream(mf, 1, 0)') l = [1, 2, 3, 6, 10, 11, 12] print(l)