The BridgeSubscriber will subscribe to ROS topics specified in the configuration file and then port the data to the machine tool adapter. More...
Public Member Functions | |
def | __init__ |
Constructor for a BridgeSubscriber. | |
def | data_item_conversion |
A conversion function that will convert the ROS message value to the machine tool value. | |
def | setup_topic_data |
This function captures the topic name, type, and member attributes that are required for the ROS subscriber. | |
def | topic_callback |
Callback function that captures the attribute values for a ROS topic. | |
def | topic_listener |
Main ROS subscriber function. | |
Public Attributes | |
adapter | |
adapter_port | |
config | |
data_items | |
di_dict | |
lib_manifests | |
lock | |
member_names | |
member_types | |
msg_parameters | |
msg_text | |
subscribed_list | |
topic_name_list | |
topic_type_list | |
url |
The BridgeSubscriber will subscribe to ROS topics specified in the configuration file and then port the data to the machine tool adapter.
Topics and topic parameters are specified by a configuration file that must be included with the main program during execution. If this file is not provided, the node will terminate with an error message indicating the need for this file.
Command line example:
bridge_subscriber.py -i bridge_subscriber_config.yaml bridge_subscriber.py -input bridge_subscriber_config.yaml
The class contains the following methods:
setup_topic_data -- utilizes introspection to set up class instance variables. topic_callback -- callback function that captures the attribute values for a ROS topic. data_item_conversion -- sets MTConnect adapter value via ROS message CONSTANT value. topic_listener -- ROS subscriber function that launches subscribers.
Definition at line 62 of file bridge_subscriber.py.
def bridge_subscriber.BridgeSubscriber.__init__ | ( | self | ) |
Constructor for a BridgeSubscriber.
Definition at line 64 of file bridge_subscriber.py.
def bridge_subscriber.BridgeSubscriber.data_item_conversion | ( | self, | |
topic_name, | |||
type_name, | |||
msg_data, | |||
msg_text, | |||
constants | |||
) |
A conversion function that will convert the ROS message value to the machine tool value.
The conversion dictionary is provided in the configuration file.
topic_name,: | string defining the name of the ROS topic |
type_name,: | string defining the name of the ROS topic type |
msg_data,: | list of strings defining message attributes |
msg_text,: | string of the entire message text (may be eliminated in future revisions) |
constants,: | list of ROS topic message type CONSTANTS stored as strings |
Definition at line 227 of file bridge_subscriber.py.
This function captures the topic name, type, and member attributes that are required for the ROS subscriber.
This task is completed for each topic specified in the configuration file.
This function then performs a relative import of the topic via the getattr(import_module) function. Data is stored in the following class instance attributes:
self.topic_type_list --> used for module import and msg parameters. self.member_types --> member type, not used in msg parameters, future use. self.member_names --> used for ROS subscriber msg parameters.
Definition at line 125 of file bridge_subscriber.py.
def bridge_subscriber.BridgeSubscriber.topic_callback | ( | self, | |
data, | |||
cb_data | |||
) |
Callback function that captures the attribute values for a ROS topic.
The topic data is stored in a list of tuples, where each tuple is a (attrib_name, attrib_value) pair. To access the integer value of the attribute value, use attrib_value.val.
All data conversions between ROS and MTConnect are stored in the ROS subscriber YAML file. A separate function handles the ROS to MTConnect conversions for generic robot messages.
data,: | callback ROS message data from the ROS subscriber |
cb_data,: | tuple containing the following parameters: |
topic_name,: | string defining the name of the ROS topic |
type_handle,: | class instance of the ROS topic message i.e. <class 'mtconnect_msgs.msg._RobotStates.RobotStates'> |
member_set,: | list of strings defining the attribute members for the message class |
msg_text,: | string of the entire message text (may be eliminated in future revisions) |
Definition at line 175 of file bridge_subscriber.py.
def bridge_subscriber.BridgeSubscriber.topic_listener | ( | self, | |
data | |||
) |
Main ROS subscriber function.
A new thread is created for each callback.
data,: | tuple containing the following parameters: |
topic_name,: | string defining the name of the ROS topic |
type_handle,: | class instance of the ROS topic message i.e. <class 'mtconnect_msgs.msg._RobotStates.RobotStates'> |
member_set,: | list of strings defining the message attributes |
msg_text,: | string of the entire message text (may be eliminated in future revisions) |
Definition at line 253 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 125 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.
Definition at line 64 of file bridge_subscriber.py.