ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
@jschornak gave the right solution for your specific issue, but I just wanted to add another suggestion that would prevent this: use lambdas instead of std::bind
(or boost::bind
). With that your subscription would look like:
subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
"/camera/depth/color/points",
10,
[this](sensor_msgs::msg::PointCloud2::SharedPtr msg) { topic_callback(msg); }
);
Actually for small callbacks that allows you to implement the logic right there in place without the need of creating a separate method and pass pointers to it around:
subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
"/camera/depth/color/points",
10,
[this](sensor_msgs::msg::PointCloud2::SharedPtr msg) {
RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data);
}
);