Skip to content

Conversation

@wayneparrott
Copy link
Collaborator

The ros-graph-example.js demonstrates use of the Node api for accessing ROS2 graph info. When executed the example creates 4 nodes: a publisher node, a subscription node, a service node and a ros-info node that outputs detail of the other 3 nodes to stdout.

@wayneparrott wayneparrott requested a review from minggangw July 14, 2021 18:10
@wayneparrott
Copy link
Collaborator Author

Example output:

$ node example/ros-graph-example.js
This example creates the following nodes and outputs the corresponding ROS2 graph:
  publisher_node
  subscriber_node
  service_node
  ros_graph_display_node
NODES
[
  'publisher_node',
  'subscriber_node',
  'service_node',
  'ros_graph_display_node'
]
[
  { name: 'publisher_node', namespace: '/ns1' },
  { name: 'subscriber_node', namespace: '/ns1' },
  { name: 'service_node', namespace: '/ns1' },
  { name: 'ros_graph_display_node', namespace: '/ns1' }
]
TOPICS & TYPES
[
  {
    name: '/ns1/parameter_events',
    types: [ 'rcl_interfaces/msg/ParameterEvent' ]
  },
  { name: '/ns1/topic', types: [ 'std_msgs/msg/String' ] },
  { name: '/rosout', types: [ 'rcl_interfaces/msg/Log' ] }
]
SERVICES & TYPES
[
  {
    name: '/ns1/add_two_ints',
    types: [ 'example_interfaces/srv/AddTwoInts' ]
  },
  {
    name: '/ns1/publisher_node/describe_parameters',
    types: [ 'rcl_interfaces/srv/DescribeParameters' ]
  },
  {
    name: '/ns1/publisher_node/get_parameters',
    types: [ 'rcl_interfaces/srv/GetParameters' ]
  },
  {
    name: '/ns1/publisher_node/list_parameters',
    types: [ 'rcl_interfaces/srv/ListParameters' ]
  },
  {
    name: '/ns1/publisher_node/set_parameters',
    types: [ 'rcl_interfaces/srv/SetParameters' ]
  },
  {
    name: '/ns1/publisher_node/set_parameters_atomically',
    types: [ 'rcl_interfaces/srv/SetParametersAtomically' ]
  },
  {
    name: '/ns1/ros_graph_display_node/describe_parameters',
    types: [ 'rcl_interfaces/srv/DescribeParameters' ]
  },
  {
    name: '/ns1/ros_graph_display_node/get_parameters',
    types: [ 'rcl_interfaces/srv/GetParameters' ]
  },
  {
    name: '/ns1/ros_graph_display_node/list_parameters',
    types: [ 'rcl_interfaces/srv/ListParameters' ]
  },
  {
    name: '/ns1/ros_graph_display_node/set_parameters',
    types: [ 'rcl_interfaces/srv/SetParameters' ]
  },
  {
    name: '/ns1/ros_graph_display_node/set_parameters_atomically',
    types: [ 'rcl_interfaces/srv/SetParametersAtomically' ]
  },
  {
    name: '/ns1/service_node/describe_parameters',
    types: [ 'rcl_interfaces/srv/DescribeParameters' ]
  },
  {
    name: '/ns1/service_node/get_parameters',
    types: [ 'rcl_interfaces/srv/GetParameters' ]
  },
  {
    name: '/ns1/service_node/list_parameters',
    types: [ 'rcl_interfaces/srv/ListParameters' ]
  },
  {
    name: '/ns1/service_node/set_parameters',
    types: [ 'rcl_interfaces/srv/SetParameters' ]
  },
  {
    name: '/ns1/service_node/set_parameters_atomically',
    types: [ 'rcl_interfaces/srv/SetParametersAtomically' ]
  },
  {
    name: '/ns1/subscriber_node/describe_parameters',
    types: [ 'rcl_interfaces/srv/DescribeParameters' ]
  },
  {
    name: '/ns1/subscriber_node/get_parameters',
    types: [ 'rcl_interfaces/srv/GetParameters' ]
  },
  {
    name: '/ns1/subscriber_node/list_parameters',
    types: [ 'rcl_interfaces/srv/ListParameters' ]
  },
  {
    name: '/ns1/subscriber_node/set_parameters',
    types: [ 'rcl_interfaces/srv/SetParameters' ]
  },
  {
    name: '/ns1/subscriber_node/set_parameters_atomically',
    types: [ 'rcl_interfaces/srv/SetParametersAtomically' ]
  }
]
PUBLISHERS BY NODE
[
  {
    "node": {
      "name": "publisher_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/parameter_events",
        "types": [
          "rcl_interfaces/msg/ParameterEvent"
        ]
      },
      {
        "name": "/ns1/topic",
        "types": [
          "std_msgs/msg/String"
        ]
      },
      {
        "name": "/rosout",
        "types": [
          "rcl_interfaces/msg/Log"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "subscriber_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/parameter_events",
        "types": [
          "rcl_interfaces/msg/ParameterEvent"
        ]
      },
      {
        "name": "/rosout",
        "types": [
          "rcl_interfaces/msg/Log"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "service_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/parameter_events",
        "types": [
          "rcl_interfaces/msg/ParameterEvent"
        ]
      },
      {
        "name": "/rosout",
        "types": [
          "rcl_interfaces/msg/Log"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "ros_graph_display_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/parameter_events",
        "types": [
          "rcl_interfaces/msg/ParameterEvent"
        ]
      },
      {
        "name": "/rosout",
        "types": [
          "rcl_interfaces/msg/Log"
        ]
      }
    ]
  }
]
SUBSCRIPTIONS BY NODE
[
  {
    "node": {
      "name": "publisher_node",
      "namespace": "/ns1"
    },
    "info": []
  },
  {
    "node": {
      "name": "subscriber_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/topic",
        "types": [
          "std_msgs/msg/String"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "service_node",
      "namespace": "/ns1"
    },
    "info": []
  },
  {
    "node": {
      "name": "ros_graph_display_node",
      "namespace": "/ns1"
    },
    "info": []
  }
]
SERVICES BY NODE
[
  {
    "node": {
      "name": "publisher_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/publisher_node/describe_parameters",
        "types": [
          "rcl_interfaces/srv/DescribeParameters"
        ]
      },
      {
        "name": "/ns1/publisher_node/get_parameters",
        "types": [
          "rcl_interfaces/srv/GetParameters"
        ]
      },
      {
        "name": "/ns1/publisher_node/list_parameters",
        "types": [
          "rcl_interfaces/srv/ListParameters"
        ]
      },
      {
        "name": "/ns1/publisher_node/set_parameters",
        "types": [
          "rcl_interfaces/srv/SetParameters"
        ]
      },
      {
        "name": "/ns1/publisher_node/set_parameters_atomically",
        "types": [
          "rcl_interfaces/srv/SetParametersAtomically"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "subscriber_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/subscriber_node/describe_parameters",
        "types": [
          "rcl_interfaces/srv/DescribeParameters"
        ]
      },
      {
        "name": "/ns1/subscriber_node/get_parameters",
        "types": [
          "rcl_interfaces/srv/GetParameters"
        ]
      },
      {
        "name": "/ns1/subscriber_node/list_parameters",
        "types": [
          "rcl_interfaces/srv/ListParameters"
        ]
      },
      {
        "name": "/ns1/subscriber_node/set_parameters",
        "types": [
          "rcl_interfaces/srv/SetParameters"
        ]
      },
      {
        "name": "/ns1/subscriber_node/set_parameters_atomically",
        "types": [
          "rcl_interfaces/srv/SetParametersAtomically"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "service_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/add_two_ints",
        "types": [
          "example_interfaces/srv/AddTwoInts"
        ]
      },
      {
        "name": "/ns1/service_node/describe_parameters",
        "types": [
          "rcl_interfaces/srv/DescribeParameters"
        ]
      },
      {
        "name": "/ns1/service_node/get_parameters",
        "types": [
          "rcl_interfaces/srv/GetParameters"
        ]
      },
      {
        "name": "/ns1/service_node/list_parameters",
        "types": [
          "rcl_interfaces/srv/ListParameters"
        ]
      },
      {
        "name": "/ns1/service_node/set_parameters",
        "types": [
          "rcl_interfaces/srv/SetParameters"
        ]
      },
      {
        "name": "/ns1/service_node/set_parameters_atomically",
        "types": [
          "rcl_interfaces/srv/SetParametersAtomically"
        ]
      }
    ]
  },
  {
    "node": {
      "name": "ros_graph_display_node",
      "namespace": "/ns1"
    },
    "info": [
      {
        "name": "/ns1/ros_graph_display_node/describe_parameters",
        "types": [
          "rcl_interfaces/srv/DescribeParameters"
        ]
      },
      {
        "name": "/ns1/ros_graph_display_node/get_parameters",
        "types": [
          "rcl_interfaces/srv/GetParameters"
        ]
      },
      {
        "name": "/ns1/ros_graph_display_node/list_parameters",
        "types": [
          "rcl_interfaces/srv/ListParameters"
        ]
      },
      {
        "name": "/ns1/ros_graph_display_node/set_parameters",
        "types": [
          "rcl_interfaces/srv/SetParameters"
        ]
      },
      {
        "name": "/ns1/ros_graph_display_node/set_parameters_atomically",
        "types": [
          "rcl_interfaces/srv/SetParametersAtomically"
        ]
      }
    ]
  }
]

@coveralls
Copy link

coveralls commented Jul 14, 2021

Coverage Status

Coverage remained the same at 90.62% when pulling 59847db on wayneparrott:ros-graph-example into 8ebe705 on RobotWebTools:develop.

Copy link
Member

@minggangw minggangw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@minggangw minggangw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines 1 to 2
// foo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove these lines? Please go ahead to merge it when it's done, thanks!

@wayneparrott wayneparrott merged commit 8ba8cbc into RobotWebTools:develop Jul 16, 2021
@wayneparrott wayneparrott deleted the ros-graph-example branch July 16, 2021 18:47
minggangw pushed a commit that referenced this pull request Jul 19, 2021
* new example to output ros2 graph details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants