My Subscriber isn't picking up TurtleBot3's scans
Using ROS2 Dashing, running on the Dashing Docker environment, and using Tmux to run multiple nodes in the same console. I setup my TurtleBot3 installation and prepared things for simulation.
I can run
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
And this command shows messages being published
ros2 topic echo /scan
But after this I built a node in a separate package, which is unable to subscribe to /scan
. This is the MVCE:
void topic_callback(const sensor_msgs::msg::LaserScan::ConstSharedPtr msg)
{
std::cout << "Got something!" << std::endl;
}
int main(int argc, char *argv[]) {
rclcpp::init(argc, argv);
auto node = rclcpp::Node::make_shared("whateverName");
rclcpp::Subscription<sensor_msgs::msg::LaserScan>::SharedPtr subscription_ = node->create_subscription<sensor_msgs::msg::LaserScan>("/scan", 10, std::bind(&topic_callback, std::placeholders::_1));
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}
Running this node prints nothing. What am I doing wrong here?
Check what QoS the scan is published under. You may need to use the sensor data WoS setting.