mavexpression.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 '''
00003 mavlink expression evaluation functions
00004 
00005 Copyright Andrew Tridgell 2011
00006 Released under GNU GPL version 3 or later
00007 '''
00008 
00009 import os
00010 
00011 # these imports allow for mavgraph and mavlogdump to use maths expressions more easily
00012 from math import *
00013 from .mavextra import *
00014 
00015 '''
00016 Support having a $HOME/.pymavlink/mavextra.py for extra graphing functions
00017 '''
00018 home = os.getenv('HOME')
00019 if home is not None:
00020     extra = os.path.join(home, '.pymavlink', 'mavextra.py')
00021     if os.path.exists(extra):
00022         import imp
00023         mavuser = imp.load_source('pymavlink.mavuser', extra)
00024         from pymavlink.mavuser import *
00025 
00026 def evaluate_expression(expression, vars):
00027     '''evaluation an expression'''
00028     try:
00029         v = eval(expression, globals(), vars)
00030     except NameError:
00031         return None
00032     except ZeroDivisionError:
00033         return None
00034     return v


mavlink
Author(s): Lorenz Meier
autogenerated on Thu Jun 6 2019 19:01:57