mavexpression.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 '''
3 mavlink expression evaluation functions
4 
5 Copyright Andrew Tridgell 2011
6 Released under GNU GPL version 3 or later
7 '''
8 
9 import os
10 
11 # these imports allow for mavgraph and mavlogdump to use maths expressions more easily
12 from math import *
13 from .mavextra import *
14 
15 '''
16 Support having a $HOME/.pymavlink/mavextra.py for extra graphing functions
17 '''
18 home = os.getenv('HOME')
19 if home is not None:
20  extra = os.path.join(home, '.pymavlink', 'mavextra.py')
21  if os.path.exists(extra):
22  import imp
23  mavuser = imp.load_source('pymavlink.mavuser', extra)
24  from pymavlink.mavuser import *
25 
26 def evaluate_expression(expression, vars):
27  '''evaluation an expression'''
28  try:
29  v = eval(expression, globals(), vars)
30  except NameError:
31  return None
32  except ZeroDivisionError:
33  return None
34  return v


mavlink
Author(s): Lorenz Meier
autogenerated on Sun Apr 7 2019 02:06:02