RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
320 stars 70 forks source link

A way to get the list of topics and their types #816

Closed RalphCodesTheInternet closed 2 years ago

RalphCodesTheInternet commented 2 years ago

With rclpy and rclcpp there are ways you can get a list of all the topics and their types. I could not find a way of doing it with rclnodejs. It would be a great feature to add

wayneparrott commented 2 years ago

See the Node#getTopicNamesAndTypes() method http://robotwebtools.org/rclnodejs/docs/0.20.0/Node.html

I believe this is equivalent to using ros2 cli: ros2 topic list ros2 topic info <topic> ros2 topic type <typename>

//edited Also check out this example for exposure to additional useful api: https://github.com/RobotWebTools/rclnodejs/blob/develop/example/ros-graph-example.js I confirmed that while this example includes it's own publishers, subscribers and services, the api provides access to the full ros graph.

RalphCodesTheInternet commented 2 years ago

This is exactly what I was looking for. Thank you so much!