Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 '''
00022 @author: Sammy Pfeiffer
00023
00024 Script that tries to load initially private motions
00025 (in the case of working in PAL premises)
00026 and if the package is not found loads the default
00027 public ones
00028 '''
00029
00030 from rospkg import RosPack, ResourceNotFound
00031 from rosparam import upload_params
00032 from yaml import load
00033
00034 PRIVATE_PKG_NAME = 'reemc_motions_proprietary'
00035 PUBLIC_PKG_NAME = 'reemc_bringup'
00036
00037 PRIVATE_CONFIG_YAML = 'reemc_motions.yaml'
00038 PUBLIC_CONFIG_YAML = 'reemc_motions.yaml'
00039
00040 def load_params_from_yaml(complete_file_path):
00041 '''Gets the params from a yaml file given the complete path of the
00042 file and uploads those to the param server.
00043 This is convenience function as rosparam.load_file does not
00044 give this functionality as found here:
00045 http://answers.ros.org/question/169866/load-yaml-with-code/'''
00046 f = open(complete_file_path, 'r')
00047 yamlfile = load(f)
00048 f.close()
00049 upload_params('/', yamlfile )
00050
00051 if __name__ == '__main__':
00052 rp = RosPack()
00053 print "Loading public motions from: " + PUBLIC_PKG_NAME
00054 pub_pkg_path = rp.get_path(PUBLIC_PKG_NAME)
00055 pub_config_yaml = PUBLIC_CONFIG_YAML
00056 pub_full_path = pub_pkg_path + '/config/' + pub_config_yaml
00057 load_params_from_yaml(pub_full_path)
00058 print "Trying to find private package: " + PRIVATE_PKG_NAME
00059 try:
00060 pkg_path = rp.get_path(PRIVATE_PKG_NAME)
00061 config_yaml = PRIVATE_CONFIG_YAML
00062 full_path = pkg_path + '/config/' + config_yaml
00063 print "Loading params from: " + full_path
00064 load_params_from_yaml(full_path)
00065 except ResourceNotFound:
00066 print "Not found, only using public motions."
00067
00068 print "Finished."
00069