ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

marney's profile - activity

2020-11-03 16:30:56 -0500 received badge  Famous Question (source)
2020-06-24 15:15:42 -0500 received badge  Famous Question (source)
2020-06-22 21:07:16 -0500 received badge  Notable Question (source)
2020-05-26 01:59:25 -0500 received badge  Famous Question (source)
2020-04-22 15:54:50 -0500 received badge  Notable Question (source)
2020-02-04 20:14:23 -0500 commented question ros2 how to implement subscription using RCL

Thank you so much for a comment. Actually, I try to make client library in other language by wrapping RCL, so I submitte

2020-02-04 20:06:24 -0500 received badge  Enthusiast
2020-02-03 08:15:11 -0500 received badge  Popular Question (source)
2020-01-31 05:29:57 -0500 asked a question ros2 how to implement subscription using RCL

ros2 how to implement subscription using RCL I am studying RCL. I wrote this code and made a simple subscriber. I'd like

2020-01-22 09:42:35 -0500 received badge  Popular Question (source)
2020-01-16 23:43:38 -0500 asked a question creation hundreds of nodes

creation hundreds of nodes Now, I try to create many nodes and investigate behavior. Here is the code to create any numb

2020-01-16 21:11:18 -0500 commented answer how to implement multiple subscribers simply

Thank you so much for reply. I could test the case in multiple nodes you could also consider creating 1 node and add

2020-01-16 20:35:07 -0500 received badge  Supporter (source)
2020-01-16 20:31:21 -0500 marked best answer how to implement multiple subscribers simply

I am studying ROS2 dashing. I 'd like to create many simple subscribers which subscribe same topic and test CPU performance. Now I am trying as follws. This is a example which two subscribers run. I'd like to test a case in which ,for example, 100 subscribers are running. Is there any better way to realize multiple such ? Thanks.

//subnodes.hpp
#include <rclcpp/rclcpp.hpp>
#include <std_msgs/msg/int16.hpp>

class MinimalSubscriber1:public rclcpp::Node{
private:
    rclcpp::Subscription<std_msgs::msg::Int16>::SharedPtr subscription_;
    void topic_callback_(const std_msgs::msg::Int16::SharedPtr msg);
public:
    MinimalSubscriber1();
};

class MinimalSubscriber2:public rclcpp::Node{
private:
    rclcpp::Subscription<std_msgs::msg::Int16>::SharedPtr subscription_;
    void topic_callback_(const std_msgs::msg::Int16::SharedPtr msg);
public:
    MinimalSubscriber2();
};

//subnodes.cpp
#include <rclcpp/rclcpp.hpp>
#include <std_msgs/msg/int16.hpp>
#include "subnodes.hpp"

void MinimalSubscriber1::topic_callback_(const std_msgs::msg::Int16::SharedPtr msg){
    RCLCPP_INFO(this->get_logger(), "No.1 heard:%d",msg->data);
}
 MinimalSubscriber1::MinimalSubscriber1()
:Node("minimal_subscriber_test1"){
    subscription_ = this->create_subscription<std_msgs::msg::Int16>(
        "testtopic",
        std::bind(&MinimalSubscriber1::topic_callback_,this,std::placeholders::_1)
    );
}

void MinimalSubscriber2::topic_callback_(const std_msgs::msg::Int16::SharedPtr msg){
    RCLCPP_INFO(this->get_logger(), "No.2 heard:%d",msg->data);
}
 MinimalSubscriber2::MinimalSubscriber2()
:Node("minimal_subscriber_test2"){
    subscription_ = this->create_subscription<std_msgs::msg::Int16>(
        "testtopic",
        std::bind(&MinimalSubscriber2::topic_callback_,this,std::placeholders::_1)
    );
}

//main.cpp
#include <rclcpp/rclcpp.hpp>
#include "subnodes.hpp"

int main(int argc,char*argv[]){
  rclcpp::init(argc,argv);
  rclcpp::executors::SingleThreadedExecutor exec;

  auto node1 = std::make_shared<MinimalSubscriber1>();
  auto node2 = std::make_shared<MinimalSubscriber2>();
  exec.add_node(node1);
  exec.add_node(node2);
  exec::spin();
  rclcpp::shutdown();
  return 0;
}
2020-01-16 20:31:21 -0500 received badge  Scholar (source)
2020-01-16 04:09:23 -0500 received badge  Notable Question (source)
2020-01-13 10:25:27 -0500 received badge  Popular Question (source)
2020-01-13 01:51:58 -0500 asked a question how to implement multiple subscribers simply

how to implement multiple subscribers simply I am studying ROS2 dashing. I 'd like to create many simple subscribers wh

2020-01-13 01:51:58 -0500 asked a question how to implement multiple subscribers simply

how to implement multiple subscribers simply I am studying ROS2 dashing. I 'd like to create many simple subscribers wh