KeyBinding.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # This class handles key bindings. It is used to both hold the data structure of key bindings, and publishing the
00003 # messages bound to the keys to the bound subscribed topic.
00004 
00005 import roslib
00006 import rospy
00007 
00008 class KeyBinding:
00009     '''
00010     This is the data structure that supports key binding information. It holds a relation between a button,
00011     a message, and a topic. This key will eventually be used to send the desired message to the corresponding topic.
00012     '''
00013 
00014     def __init__(self, key, message, subscribed_topic, info):
00015         '''
00016         :param key: A keyboard button.
00017         :param message: A ROS message ready to be published.
00018         :param subscribed_topic: A ROS topic open for message publication.
00019         This is the basic constructor method for the KeyBinding class.
00020         '''
00021         self.key = key
00022         self.message = message
00023         self.subscribed_topic = subscribed_topic
00024         self.info = info
00025     def get_info(self):
00026         '''
00027 
00028         :return:
00029         '''
00030         return self.info
00031 
00032     def get_key(self):
00033         '''
00034         :return self._key: A string representing the key to this binding.
00035         This method allows public access to the key of the present binding.
00036         '''
00037         return self.key
00038 
00039     def get_message(self):
00040         '''
00041         :return self._message: A string representing the bound message.
00042         This method allows public access to the message content.
00043         '''
00044         return self.message
00045 
00046     def get_subscribed_topic(self):
00047         '''
00048         :return self._subscribed_topic: A string representing the bound subscribed topic.
00049         This method allows public access to the subscribed topic.
00050         '''
00051         return self.subscribed_topic
00052 
00053     def publish_message(self):
00054         '''
00055         :return None:
00056         This method publishes the bound message to the subscribed topic.
00057         '''
00058         pub = rospy.Publisher(self.subscribed_topic,type(self.message),queue_size=10)
00059         pub.publish(self.get_message())


tele_dir
Author(s): Rodrigo Delgado , Steffan Wiche
autogenerated on Thu Jun 6 2019 17:32:56