RAPP Platform  v0.6.0
RAPP Platform is a collection of ROS nodes and back-end processes that aim to deliver ready-to-use generic services to robots
 All Classes Namespaces Files Functions Variables Macros
rapp_utilities.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 
4 #Copyright 2015 RAPP
5 
6 #Licensed under the Apache License, Version 2.0 (the "License");
7 #you may not use this file except in compliance with the License.
8 #You may obtain a copy of the License at
9 
10  #http://www.apache.org/licenses/LICENSE-2.0
11 
12 #Unless required by applicable law or agreed to in writing, software
13 #distributed under the License is distributed on an "AS IS" BASIS,
14 #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #See the License for the specific language governing permissions and
16 #limitations under the License.
17 
18 import sys
19 import os
20 import inspect
21 import rospy
22 
23 
24 ## @class RappUtilities
25 # @brief Provides various utility functionalities
26 class RappUtilities(object):
27 
28  def __init__(self):
29  pass
30 
31  ## @brief Prints ROS log messages with the specified verbosity.
32  @staticmethod
33  def rapp_print(var, verbosity='DEBUG'):
34 
35  callerframerecord = inspect.stack()[1]
36 
37  frame = callerframerecord[0]
38  info = inspect.getframeinfo(frame)
39 
40  if verbosity == 'DEBUG':
41  rospy.logdebug('[ FILE: ' + os.path.basename(info.filename) + \
42  ', FUNCTION: ' + info.function + ', LINE: ' + str(info.lineno) + \
43  ' ]: ' + str(var) )
44  elif verbosity == 'INFO':
45  rospy.loginfo('[ FILE: ' + os.path.basename(info.filename) + \
46  ', FUNCTION: ' + info.function + ', LINE: ' + str(info.lineno) + \
47  ' ]: ' + str(var) )
48  elif verbosity == 'WARN':
49  rospy.logwarn('[ FILE: ' + os.path.basename(info.filename) + \
50  ', FUNCTION: ' + info.function + ', LINE: ' + str(info.lineno) + \
51  ' ]: ' + str(var) )
52  elif verbosity == 'ERROR':
53  rospy.logerr('[ FILE: ' + os.path.basename(info.filename) + \
54  ', FUNCTION: ' + info.function + ', LINE: ' + str(info.lineno) + \
55  ' ]: ' + str(var) )
56  elif verbosity == 'FATAL':
57  rospy.logfatal('[ FILE: ' + os.path.basename(info.filename) + \
58  ', FUNCTION: ' + info.function + ', LINE: ' + str(info.lineno) + \
59  ' ]: ' + str(var) )
Provides various utility functionalities.
def rapp_print
Prints ROS log messages with the specified verbosity.