⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup_dgps.py

📁 在linux系统下开发的GPS接收程序,具有良好的图形操作界面.
💻 PY
字号:
#!/usr/env python#------------------------------------------------------------------------------# dgps_setup.py : estimate the position of a DGPS reference station##	- programmed by Boyoon Jung (boyoon@robotics.usc.edu)#------------------------------------------------------------------------------import uspp.usppimport sysimport time# GPS classclass NovatelGPS:    """    Novatel GPS device driver.    """        def __init__(self, device, baudrate):	"""	initialize communication.	"""	# open a serial port	self.serial = uspp.SerialPort(device, None, baudrate)	# send a command	self.serial.write('log com1 bestposa ontime 1\r\n')    def __del__(self):	"""	finalize communication.	"""	self.serial.write('log com1 bestposa once\r\n')    def update(self):	"""	parse a single sentence.	"""	# read out a garbage	while 1:	    sentence = self.serial.read(1);	    if sentence == '#':		break;	# read a sentence	sentence = ''	while 1:	    sentence += self.serial.read(1);	    if sentence[-1] == '\r':		sentence = sentence[:-10]	# no checksum info		break;	# parse the sentence	tokens = sentence.split(';')[1].split(',')	self.status = tokens[0]	self.latitude = tokens[2]	self.longitude = tokens[3]	self.altitude = tokens[4]	self.std_lat = tokens[7]	self.std_lon = tokens[8]	self.std_alt = tokens[9]    def fix(self):	"""	fix the position of the reference station.	"""	# change the interface mode of com2	self.serial.write('interfacemode com2 none rtcm\r\n')	# fix the position	self.serial.write('fix position ' + self.latitude +				      ' ' + self.longitude +				      ' ' + self.altitude + '\r\n')	# make it generate RTCM messages	self.serial.write('dgpsrxid auto\r\n')	self.serial.write('log com2 rtcm1 ontime 2\r\n')	self.serial.write('log com2 rtcm3 ontime 5\r\n')	self.serial.write('log com2 rtcm9 ontime 2\r\n')# main functionif __name__ == '__main__':    # load default settings    device = '/dev/ttyS0'    baudrate = 9600    # process the command line arguments    if len(sys.argv) > 2: device = sys.argv[1]    if len(sys.argv) > 3: baudrate = int(sys.argv[2])    # initialize communication    gps = NovatelGPS(device, baudrate)    # wait until the GPS receiver is initialized    try:	sys.stderr.write('Initializing GPS receiver ')	while 1:	    sys.stderr.write('.')	    gps.update()	    if gps.status == 'SOL_COMPUTED':		sys.stderr.write(' Done.\n\n');		break;    except:	print "Fail to initialize GPS receiver."	sys.exit(0)    # print the information    try:	while 1:	    gps.update()	    print 'Pose = (' + gps.latitude + ',' \			     + gps.longitude + ',' \			     + gps.altitude \		+ ') STD = (' + gps.std_lat + ',' \			      + gps.std_lon + ',' \			      + gps.std_alt + ')'    except:	gps.fix()	print	print 'Position is fixed to'	print '    Latitude  : ' + gps.latitude	print '    Longitude : ' + gps.longitude	print '    Altitude  : ' + gps.altitude	print

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -