资源简介
光流传感器源代码,以及环境配置的说明,代码详细
代码片段和文件信息
#!/usr/bin/env python
# parse and construct FlightGear NET FDM packets
# Andrew Tridgell November 2011
# released under GNU GPL version 2 or later
import struct math
class fgFDMError(Exception):
‘‘‘fgFDM error class‘‘‘
def __init__(self msg):
Exception.__init__(self msg)
self.message = ‘fgFDMError: ‘ + msg
class fgFDMVariable(object):
‘‘‘represent a single fgFDM variable‘‘‘
def __init__(self index arraylength units):
self.index = index
self.arraylength = arraylength
self.units = units
class fgFDMVariableList(object):
‘‘‘represent a list of fgFDM variable‘‘‘
def __init__(self):
self.vars = {}
self._nextidx = 0
def add(self varname arraylength=1 units=None):
self.vars[varname] = fgFDMVariable(self._nextidx arraylength units=units)
self._nextidx += arraylength
class fgFDM(object):
‘‘‘a flightgear native FDM parser/generator‘‘‘
def __init__(self):
‘‘‘init a fgFDM object‘‘‘
self.FG_NET_FDM_VERSION = 24
self.pack_string = ‘>I 4x 3d 6f 11f 3f 2f I 4I 4f 4f 4f 4f 4f 4f 4f 4f 4f I 4f I 3I 3f 3f 3f I i f 10f‘
self.values = [0]*98
self.FG_MAX_ENGINES = 4
self.FG_MAX_WHEELS = 3
self.FG_MAX_TANKS = 4
# supported unit mappings
self.unitmap = {
(‘radians‘ ‘degrees‘) : math.degrees(1)
(‘rps‘ ‘dps‘) : math.degrees(1)
(‘feet‘ ‘meters‘) : 0.3048
(‘fps‘ ‘mps‘) : 0.3048
(‘knots‘ ‘mps‘) : 0.514444444
(‘knots‘ ‘fps‘) : 0.514444444/0.3048
(‘fpss‘ ‘mpss‘) : 0.3048
(‘seconds‘ ‘minutes‘) : 60
(‘seconds‘ ‘hours‘) : 3600
}
# build a mapping between variable name and index in the values array
# note that the order of this initialisation is critical - it must
# match the wire structure
self.mapping = fgFDMVariableList()
self.mapping.add(‘version‘)
# position
self.mapping.add(‘longitude‘ units=‘radians‘) # geodetic (radians)
self.mapping.add(‘latitude‘ units=‘radians‘) # geodetic (radians)
self.mapping.add(‘altitude‘ units=‘meters‘) # above sea level (meters)
self.mapping.add(‘agl‘ units=‘meters‘) # above ground level (meters)
# attitude
self.mapping.add(‘phi‘ units=‘radians‘) # roll (radians)
self.mapping.add(‘theta‘ units=‘radians‘) # pitch (radians)
self.mapping.add(‘psi‘ units=‘radians‘) # yaw or true heading (radians)
self.mapping.add(‘alpha‘ units=‘radians‘) # angle of attack (radians)
self.mapping.add(‘beta‘ units=‘radians‘) # side slip angle (radians)
# Velocities
self.mapping.add(‘phidot‘ units=‘rps‘) # roll rate (radians/sec)
self.mapping.add(‘thetadot‘ units=‘rps‘) # pitch rate (radians/sec)
self.ma
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 619 2015-09-04 23:47 Flow-master\Flow-master\.gitignore
....... 99 2015-09-04 23:47 Flow-master\Flow-master\.gitmodules
....... 2213 2015-09-04 23:47 Flow-master\Flow-master\.travis.yml
....... 3173 2015-09-04 23:47 Flow-master\Flow-master\bareme
....... 3479 2015-09-04 23:47 Flow-master\Flow-master\bareme
文件 203 2015-09-04 23:47 Flow-master\Flow-master\cmake\test.sh
....... 805 2015-09-04 23:47 Flow-master\Flow-master\cmake\Toolchain-arm-none-eabi.cmake
....... 9195 2015-09-04 23:47 Flow-master\Flow-master\CMakeLists.txt
....... 705 2015-09-04 23:47 Flow-master\Flow-master\Flow.sublime-project
....... 258 2015-09-04 23:47 Flow-master\Flow-master\Images\px4flow-v1.prototype
....... 258 2015-09-04 23:47 Flow-master\Flow-master\Images\px4flow-v2.prototype
....... 2514 2015-09-04 23:47 Flow-master\Flow-master\inc\no_warnings.h
....... 10572 2015-09-04 23:47 Flow-master\Flow-master\Makefile
....... 3358 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 3294 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 220 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 337 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 798 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 944 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 3294 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 7829 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 2302 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 186 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 186 2015-09-04 23:47 Flow-master\Flow-master\makefiles\bareme
....... 12281 2015-09-04 23:47 Flow-master\Flow-master\makefiles\firmware.mk
....... 4684 2015-09-04 23:47 Flow-master\Flow-master\makefiles\library.mk
....... 7469 2015-09-04 23:47 Flow-master\Flow-master\makefiles\module.mk
....... 2557 2015-09-04 23:47 Flow-master\Flow-master\makefiles\README.txt
....... 3817 2015-09-04 23:47 Flow-master\Flow-master\makefiles\setup.mk
....... 1968 2015-09-04 23:47 Flow-master\Flow-master\mavli
............此处省略702个文件信息
评论
共有 条评论