config_parser.py
Go to the documentation of this file.
1 import os.path
2 import numpy as np
3 import yaml
4 import roslib.message
5 import tf.transformations as trans
6 from rospy_message_converter import message_converter
7 _to_msg = message_converter.convert_dictionary_to_ros_message
8 _type_name = 'visualization_msgs/InteractiveMarker'
9 
10 def _include(loader, node):
11  if node.value[0] != '/':
12  file_name = os.path.join(os.path.dirname(loader.name), node.value)
13  else:
14  file_name = node.value
15  with file(file_name) as inputfile:
16  return yaml.load(inputfile)
17 
18 def _to_quat(loader, node):
19  val = [float(v.value) for v in node.value]
20  quat = trans.quaternion_from_euler(*val)
21  return {'x': quat[0], 'y': quat[1], 'z': quat[2], 'w': quat[3]}
22 
23 def _to_uint(loader, node):
24  msgclass = roslib.message.get_message_class(node.value[0].value)
25  return getattr(msgclass, node.value[1].value)
26 
27 yaml.add_constructor("!include", _include)
28 yaml.add_constructor("!euler", _to_quat)
29 yaml.add_constructor("!enum", _to_uint)
30 yaml.add_constructor("!degrees", lambda loader, node: np.deg2rad(float(node.value)))
31 
33  config = yaml.load(s)
34  for k, v in config.items():
35  config[k]['interactive_marker'] = _to_msg(_type_name, v['interactive_marker'])
36  return config
37 
38 def load(file_name):
39  with open(file_name) as f:
40  return load_from_string(f.read())


ez_interactive_marker
Author(s):
autogenerated on Mon Jun 10 2019 13:15:06