Main Content

Get Started with ROS 2 Network Analyzer App

Since R2024b

This topic shows how to connect to a ROS 2 network, analyze essential information about all the elements in the network graph such as node name and information about the message between the nodes, and visualize the interaction between the parameters associated with the ROS 2 nodes such as topics, services and actions.

Connect and View ROS 2 Network

  1. Open ROS 2 Network Analyzer app from the Apps tab in MATLAB® toolstrip.

  2. To connect to a ROS 2 network, click Connect from app toolstrip.

    ROS 2 Network Analyzer Connect icon

  3. Provide ROS 2 Domain ID and click Submit. The default domain ID is 0. This opens the network graph in the visualizer.

  4. View the list of different elements in the Network Browser panel and their numbers in the Properties panel along with the Domain ID of the connected ROS 2 network. Select or unselect any of these elements from the Network Browser to view or hide them from the graph.

    Network BrowserProperties

    Node entity shape

    Nodes –– Lists all nodes in the connected ROS 2 network

    ROS 2 Network Analyzer Properties panel

    Topic entity shape

    Topics –– Lists all topics published and subscribed by each node in the connected ROS 2 network

    Service entity shape

    Services –– Lists all services that a node provides (service-server) and for which a node is a client (service-client)

    Action entity shape

    Actions –– Lists all actions that a node provides (action-server) and for which a node is a client (action-client)

  5. Click Refresh to update the ROS 2 network graph with newly added or removed nodes and all the node elements in the Network Browser and Properties respectively.

    ROS 2 Network Analyzer Refresh icon

  6. To fit the network graph to screen width, click Auto Arrange from the app toolstrip.

    ROS 2 Network Analyzer Auto Arrange icon

Interact with Network Graph

  • Zoom in or zoom out by pinching in or pinching out, or click and hold to pan around the graph based on the visual requirements.

  • Use the mini map at the bottom left corner of the visualization window to get a complete overview of a large network, highlighting the currently visible section. You can click anywhere on the mini map to pan around the network graph, ensuring ease of navigation, and choose to view the section you need.

  • Select any element in the visualization graph to view all its details in the Properties panel.

    You can also click and drag these elements across the visualization window for ease of view. To bring the network graph back to its initial view, click Auto Arrange.

    ElementsProperties
    Node

    Properties of node in ROS 2 network graph

    Publisher

    Properties of publisher in ROS 2 network graph

    Subscriber

    Properties of subscriber in ROS 2 network graph

    Topic

    Properties of topic in ROS 2 network graph

    Service

    Properties of service in ROS 2 network graph

    Action

    Properties of action in ROS 2 network graph

  • You can right-click and copy the name of any element from the network graph or any value from the Properties panel and use it as a keyword to search across all elements in a big network.

Filter and Search Elements

ROS 2 Network Analyzer Search tab

  • Select or clear these filters to view or remove them from the network graph.

    Filter OptionsDescriptions
    Unreachable Nodes

    This constitutes of nodes that:

    • Do not publish or subscribe to a topic.

    • Do not act as service server or service caller.

    • Do not act as action server or action requester.

    Dead SinkThis constitutes of topics which have subscribers and no publishers.
    Leaf TopicsThis constitutes of topics which have publishers and no subscribers.
    Default Topics

    This constitutes of default topics related to ROS 2 network:

    • /parameters_events

    • /rosout

    Default Services

    This constitutes of default services related to ROS 2 network:

    • /describe_parameters

    • /get_parameter_types

    • /get_parameters

    • /list_parameters

    • /set_parameters

    • /set_parameters_atomically

    Action Topics and Action Services

    This constitutes of default topics and services related to actions in the ROS 2 network:

    • /_action/send_goal

    • /_action/get_result

    • /_action/cancel_goal

    • /_action/status

    • /_action/feedback

  • Search –– Use this option to search for elements containing one or all of the specified inputs. Use comma-separated keywords and press ENTER to trigger the search. To remove the applied search filter and bring the network graph to its original view, clear the text in the search bar and press ENTER. You can also right click and copy name to choose keywords for searching elements across a big network, as discussed in the Interact with Network Graph section.

Arrange Network Layout

ROS 2 Network Analyzer Layout tab

  • Layout –– Use this feature to arrange the network graph layout using one of these options.

    NameDescriptionApplicationsView
    klayHierarchical layout that creates an organized arrangement of graph elements while minimizing crossings and ensuring readability.

    klay layout minimizes edge crossings where multiple elements in the network graph originate from a single element.

    Use this approach to efficiently organize the graph to enhance readability and structure.

    dagreDirected layout that creates an inverted V shape of the graph elements and their edges from one level to the next.

    dagre layout respects flow of information or progression through stages when elements in the network graph have a clear flow direction.

    Use this approach to clearly visualize the directional relationships and dependencies between elements.

    breadthfirstHierarchical layout that organizes the graph elements according to the levels generated by running a breadth-first search on the graph.

    breadthfirst layout arranges graph elements level by level or layer by layer from a specified root element when there is a large graph that can lead to excessive overlap between the elements.

    Use this approach to horizontally align all elements at the same depth from the root, which makes it useful for understanding breadth or depth within a graph's structure.

    coseForced-directed layout that emphasizes on group and tree structures to minimize edge crossings and evenly distributes graph elements.

    cose layout emphasizes element groupings in the graph through spatial proximity, particularly effective for compound graphs that have nested structures.

    Use this layout to visually distinguish clusters and relationships between graph elements within complex networks.

    circleGeometric layout that organizes the graph elements into a circle. By default, the elements are placed clockwise from the 12 o’clock position, in the order that they are passed to the layout.

    circle layout places graph elements equidistantly along the circumference of a circle and highlight the density of edges connected to different elements, especially when the edges are made semitransparent.

    Use this approach to visualize the overall connectivity and identifying patterns or clusters based on the concentration of edges within the graph.

    gridDefault layout that easily shows all elements in the graph by positioning all of them at the origin.

    grid layout visually verifies that the graph has correctly loaded, and the graph elements are organized n a structured and uniform manner.

    Use this layout to quickly identify anomalies in the data or layout issues, making it easier to ensure the integrity and completeness of the graph's visualization.

    concentricGeometric layout that organizes the elements into concentric circles, based on the specified metrics such as hierarchy level or connectivity degree, placing elements with the highest metric values in the innermost circle and descending their metric values with each outward circle.

    concentric layout highlights the relative importance of the elements when a clear visualization of hierarchical levels or layers around a central point is required.

    Use this layout to effectively emphasize the centrality and hierarchical structure within a network, facilitating an intuitive understanding of the relationships and importance among the graph elements.

  • Namespace –– Use this option to organize the nodes, topics, services, and actions into clusters or groups based on their namespace, which perform similar functions but operate in different contexts or areas of the application.

    A namespace is a hierarchical prefix extracted from the names of nodes, topics, services, and actions to logically organize and classify the components within these elements into clusters or groups. These clusters can be nested within each other, allowing for multiple levels of organization. The depth of the namespace determines the level of granularity in the clustering.

Export Network Snapshot

To export the ROS 2 network graph snapshot as an image, click Export on the app toolstrip.

ROS 2 Network Analyzer Export icon

Example

Create and Visualize ROS 2 Network for Robot Navigation

This example shows how to set up a basic ROS 2 network for robot navigation and visualize all the node information using the ROS 2 Network analyzer app.

Define the action type, topic type, service type, and domain ID to initialize a ROS 2 network for robot navigation.

actionType = 'control_msgs/PointHead';
topicType = 'geometry_msgs/Twist';
svcType = 'nav_msgs/GetMap';
domainId = 0;

Create a ROS 2 node for Turtlebot robot with the specified domain ID.

turtleBotNode = ros2node('/turtle_bot_node', domainId);

Initialize an action server to handle path following requests.

actionServer = ros2actionserver(turtleBotNode,'/path_follow',actionType, ...
                ExecuteGoalFcn=@(~,~,~,defaultResult) deal(defaultResult, true));

Open the ROS 2 Network Analyzer app from Apps tab in MATLAB® toolstrip to visualize the ROS 2 network.

You will see that the Unreachable Nodes, 'Dead Sink' and 'Leaf Topic' filters are checked by default. Check the remaining filters too to have a comprehensive view of the ROS 2 network.

Create a ROS 2 node for the GPS sensor and set up a service server that responds with GPS location data.

gpsNode = ros2node('/gps_sensor_node',domainId);
srv = ros2svcserver(gpsNode,'/get_gps_location',svcType,@(~,resp)resp);

Create a ROS 2 node for handling the path planning tasks with the specified domain ID.

plannerNode = ros2node('/path_planner_node',domainId);

Establish a service client to obtain GPS locations on the planner node and an action client to send the path following requests.

svcClient = ros2svcclient(plannerNode,'/get_gps_location',svcType);
actClient = ros2actionclient(plannerNode, '/path_follow',actionType);

Create a subscriber to listen for velocity commands to control the robot's movement.

sub = ros2subscriber(plannerNode,'/cmd_vel',topicType);

Set up a publisher for sending commands over the '/cmd_vel' topic.

pub = ros2publisher(turtleBotNode,'/cmd_vel',topicType);

Now open the ROS 2 Network Analyzer app interface and click Refresh to visualize the updated ROS 2 network.

Use the minimap to pan around the network graph for better visibility of the default services related to the /turle_bot_node. You can also click and drag these elements across the visualization window for ease of view. To bring the network graph back to its initial view, click Auto Arrange.

To search for all elements using a specific keyword such as turtle, enter turtle in the Search box and press ENTER. You can also enter multiple comma-separated keywords to visualize elements related to all the specified keywords.

To group all the elements into clusters or groups based on their namespace, use Namespace. The depth of the namespace determines the level of granularity in the clustering. For example, Namespace field set to 1 organizes all the elements into 3 clusters — /turtle_bot_node, /path_follow, /path_planner_node.

To increase the granularity in clustering, set Namespace to a higher value such as 2. This adds another level of granularity with a nested cluster such as /path_follow_action under /path_follow.

Limitations

  • Quality of Services(QoS) information is available for topics only.

  • QoS history is not retrievable.

See Also

Apps