示例#1
0
 def main(self, *, args):
     with NodeStrategy(args) as node:
         node_names = get_node_names(node=node, include_hidden_nodes=True)
     if args.node_name in (n.full_name for n in node_names):
         with DirectNode(args) as node:
             print(args.node_name)
             subscribers = get_subscriber_info(
                 node=node, remote_node_name=args.node_name)
             print('  Subscribers:')
             print_names_and_types(subscribers)
             publishers = get_publisher_info(
                 node=node, remote_node_name=args.node_name)
             print('  Publishers:')
             print_names_and_types(publishers)
             services = get_service_info(node=node,
                                         remote_node_name=args.node_name)
             print('  Services:')
             print_names_and_types(services)
             actions_servers = get_action_server_info(
                 node=node, remote_node_name=args.node_name)
             print('  Action Servers:')
             print_names_and_types(actions_servers)
             actions_clients = get_action_client_info(
                 node=node, remote_node_name=args.node_name)
             print('  Action Clients:')
             print_names_and_types(actions_clients)
     else:
         return "Unable to find node '" + args.node_name + "'"
示例#2
0
 def main(self, *, args):
     with NodeStrategy(args) as node:
         node_names = get_node_names(
             node=node, include_hidden_nodes=args.include_hidden)
     count = [n.full_name for n in node_names].count(args.node_name)
     if count > 1:
         print(INFO_NONUNIQUE_WARNING_TEMPLATE.format(
             num_nodes=count, node_name=args.node_name),
               file=sys.stderr)
     if count > 0:
         with DirectNode(args) as node:
             print(args.node_name)
             subscribers = get_subscriber_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Subscribers:')
             print_names_and_types(subscribers)
             publishers = get_publisher_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Publishers:')
             print_names_and_types(publishers)
             service_servers = get_service_server_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Service Servers:')
             print_names_and_types(service_servers)
             service_clients = get_service_client_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Service Clients:')
             print_names_and_types(service_clients)
             actions_servers = get_action_server_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Action Servers:')
             print_names_and_types(actions_servers)
             actions_clients = get_action_client_info(
                 node=node,
                 remote_node_name=args.node_name,
                 include_hidden=args.include_hidden)
             print('  Action Clients:')
             print_names_and_types(actions_clients)
     else:
         return "Unable to find node '" + args.node_name + "'"
示例#3
0
    def ros2node(self, domain_id):
        """
        'ros2 node list' fetched from ros2cli and more
        """
        print("Exploring ROS_DOMAIN_ID: " + str(domain_id) + ' for nodes')
        os.environ['ROS_DOMAIN_ID'] = str(domain_id)

        with NodeStrategy("-a") as node:
            node_names = get_node_names(node=node, include_hidden_nodes="-a")

        nodes = sorted(n.full_name for n in node_names)
        output_node = {}
        for nodo in nodes:
            # # Abstractions from helper2
            # output_node = ROS2node()
            # output_node.name = nodo
            # output_node.domain_id = domain_id
            # output_node.namespace = output_node.name[:(output_node.name.rfind("/") + 1)] # fetch the substring until the last "/"

            # Abstractions using a list[dict] as defined above (see self.processed_nodes):
            #output_node = {"name": nodo, "domain": domain_id}
            #output_node["namespace"] = output_node["name"][:(output_node["name"].rfind("/") + 1)] # fetch the substring until the last "/"

            with DirectNode(nodo) as node:
                if str(nodo) != '/_ros2cli_daemon_0':
                    output_node[nodo] = {
                        'domain':
                        domain_id,
                        'subscribers':
                        get_subscriber_info(node=node, remote_node_name=nodo),
                        'publishers':
                        get_publisher_info(node=node, remote_node_name=nodo),
                        'services':
                        get_service_info(node=node, remote_node_name=nodo),
                        'actionservers':
                        get_action_server_info(node=node,
                                               remote_node_name=nodo),
                        'actionclient':
                        get_action_client_info(node=node,
                                               remote_node_name=nodo)
                    }
        self.processed_nodes.append(output_node)
示例#4
0
def get_node_subscriptions(node_name):
    """ Returns a list of topic names that are being subscribed by the specified node """
    subscribers = get_subscriber_info(node=_node, remote_node_name=node_name)
    return [subscriber.name for subscriber in subscribers]