diff --git a/include/dynamic_graph_bridge/ros.hpp b/include/dynamic_graph_bridge/ros.hpp index bbf1e0ec2d2aa5fcb7af071e18c64ccd41c1036f..53405988ea1384c6ac7c4b892f209bff474fb937 100644 --- a/include/dynamic_graph_bridge/ros.hpp +++ b/include/dynamic_graph_bridge/ros.hpp @@ -67,6 +67,11 @@ typedef std_srvs::srv::Empty EmptyServiceType; */ RosNodePtr get_ros_node(std::string node_name); + +size_t ros_executor_get_nb_threads(); + +void ros_display_list_of_nodes(); + /** * @brief Add a ros node to the global executor. * diff --git a/src/ros.cpp b/src/ros.cpp index c306efc9f3ecd6b40b2decb3401d364a97f8403f..dd07121311fa3ca552aed772a2513ce079b5bf8c 100644 --- a/src/ros.cpp +++ b/src/ros.cpp @@ -131,6 +131,13 @@ class Executor { } } + /** + * @brief Return the number of threads + */ + size_t get_number_of_threads() { + return ros_executor_.get_number_of_threads(); + } + private: /** * @brief Thread callback function @@ -204,6 +211,7 @@ std::string executable_name() { #endif } + /** * @brief Private function that allow us to initialize ROS only once. */ @@ -273,6 +281,23 @@ void ros_shutdown() { // rclcpp::shutdown(); } +size_t ros_executor_get_nb_threads() { + return get_ros_executor()->get_number_of_threads(); +} + +void ros_display_list_of_nodes() { + GlobalListOfRosNodeType::iterator ros_node_it = + GLOBAL_LIST_OF_ROS_NODE.begin(); + while(ros_node_it!=GLOBAL_LIST_OF_ROS_NODE.end()) { + RCLCPP_INFO(rclcpp::get_logger("dynamic_graph_bridge"), + "ros_display_list_of_nodes: %s/%s", + ros_node_it->second->get_namespace(), + ros_node_it->second->get_name()); + ros_node_it++; + } + +} + void ros_clean() { ros_stop_spinning(); GlobalListOfRosNodeType::iterator ros_node_it =