8 from opcua
import Server, ua
15 def nextname(hierachy, index_of_last_processed):
18 counter = index_of_last_processed + 1
19 while counter < len(hierachy):
20 output += hierachy[counter]
23 except Exception
as e:
24 rospy.logerr(
"Error encountered ", e)
28 pinged, unpinged = rosnode.rosnode_ping_all()
30 master = rosgraph.Master(rosnode.ID)
32 rosnode.cleanup_master_blacklist(master, unpinged)
41 rospy.init_node(
"rosopcua")
43 self.server.set_endpoint(
"opc.tcp://0.0.0.0:21554/")
44 self.server.set_server_name(
"ROS ua Server")
47 uri_topics =
"http://ros.org/topics" 49 uri_services =
"http://ros.org/services" 50 uri_actions =
"http://ros.org/actions" 51 idx_topics = self.server.register_namespace(uri_topics)
52 idx_services = self.server.register_namespace(uri_services)
53 idx_actions = self.server.register_namespace(uri_actions)
55 objects = self.server.get_objects_node()
57 topics_object = objects.add_object(idx_topics,
"ROS-Topics")
58 services_object = objects.add_object(idx_services,
"ROS-Services")
59 actions_object = objects.add_object(idx_actions,
"ROS_Actions")
60 while not rospy.is_shutdown():
64 idx_topics, idx_actions, topics_object, actions_object)
71 rospy.logdebug(
"Reached ServiceCheck for name " + name)
73 rospy.logdebug(
"Found name: " + str(self.
servicesDict[service].parent.nodeid.Identifier))
74 if self.
servicesDict[service].parent.nodeid.Identifier == name:
75 rospy.logdebug(
"Found match for name: " + name)
80 rospy.logdebug(
"Reached TopicCheck for name " + name)
82 rospy.logdebug(
"Found name: " + str(self.
topicsDict[topic].parent.nodeid.Identifier))
83 if self.
topicsDict[topic].parent.nodeid.Identifier == name:
84 rospy.logdebug(
"Found match for name: " + name)
89 rospy.logdebug(
"Reached ActionCheck for name " + name)
91 rospy.logdebug(
"Found name: " + str(self.
actionsDict[topic].parent.nodeid.Identifier))
92 if self.
actionsDict[topic].parent.nodeid.Identifier == name:
93 rospy.logdebug(
"Found match for name: " + name)
102 if __name__ ==
"__main__":
def refresh_services(namespace_ros, server, servicesdict, idx, services_object_opc)
def nextname(hierachy, index_of_last_processed)
def find_topics_node_with_same_name(self, name, idx)
def find_service_node_with_same_name(self, name, idx)
def refresh_topics_and_actions(namespace_ros, server, topicsdict, actionsdict, idx_topics, idx_actions, topics, actions)
def find_action_node_with_same_name(self, name, idx)
def own_rosnode_cleanup()