- Operating System:
Windows 10
- Installation type:
binaries
- Version or commit hash:
dashing
- DDS implementation:
Fast-RTPS
- Client library (if applicable):
rclcpp
Steps to reproduce issue
I have a modified listener/talker example, where I send around a double value.
listener_node.cpp
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "demo/listener.hpp"
int main(int argc, char ** argv)
{
setvbuf(stdout, nullptr, _IONBF, BUFSIZ);
printf("Initialize communications\n");
rclcpp::init(argc, argv);
printf("Initialize communications - done\n");
printf("Create node\n");
auto node = std::make_shared<demo::Listener>();
printf("Create node - done\n");
printf("Spin\n");
rclcpp::spin(node);
printf("Spin - done\n");
printf("Shutdown\n");
rclcpp::shutdown();
printf("Shutdown - done\n");
return 0;
}
listener.cpp
#include "demo/listener.hpp"
#include <functional>
namespace demo {
Listener::Listener() : Node("listener") {
this->sub_ = this->create_subscription<std_msgs::msg::Float64>("comm_topic", 1000, std::bind(&Listener::callback, this, std::placeholders::_1));
}
void Listener::callback(std_msgs::msg::Float64::SharedPtr msg) {
RCLCPP_INFO(this->get_logger(), "Received %f", msg->data);
}
Listener::~Listener() {
}
}
listener.hpp
#ifndef DEMO__LISTENER_HPP_
#define DEMO__LISTENER_HPP_
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float64.hpp"
#include "demo/visibility_control.h"
namespace demo {
class Listener : public rclcpp::Node {
public:
explicit Listener();
virtual ~Listener();
void callback(std_msgs::msg::Float64::SharedPtr msg);
private:
rclcpp::Subscription<std_msgs::msg::Float64>::SharedPtr sub_;
};
} // namespace demo
#endif // DEMO__LISTENER_HPP_
publisher_node.cpp
#include <memory>
#include <thread>
#include <chrono>
#include "rclcpp/rclcpp.hpp"
#include "demo/publisher.hpp"
int main(int argc, char ** argv)
{
setvbuf(stdout, nullptr, _IONBF, BUFSIZ);
printf("Initialize communications\n");
rclcpp::init(argc, argv);
printf("Initialize communications - done\n");
printf("Create node\n");
auto node = std::make_shared<demo::Publisher>();
printf("Create node - done\n");
printf("Sleeping\n");
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
printf("Sleeping - done\n");
printf("Start\n");
node->start();
printf("Start - done\n");
printf("Spin\n");
rclcpp::spin(node);
printf("Spin - done\n");
printf("Shutdown\n");
rclcpp::shutdown();
printf("Shutdown - done\n");
return 0;
}
publisher.cpp
#include "demo/publisher.hpp"
namespace demo {
Publisher::Publisher() : Node("publisher") {
this->pub_ = this->create_publisher<std_msgs::msg::Float64>("comm_topic");
}
void Publisher::start() {
std_msgs::msg::Float64 msg;
//rclcpp::WallRate loop_rate(10);
while (true) {
msg.data = this->counter_;
RCLCPP_INFO(this->get_logger(), "Publishing %f", this->counter_);
this->pub_->publish(msg);
this->counter_ += 0.01;
//loop_rate.sleep();
}
}
Publisher::~Publisher() {
}
}
publisher.hpp
#ifndef DEMO__PUBLISHER_HPP_
#define DEMO__PUBLISHER_HPP_
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float64.hpp"
#include "demo/visibility_control.h"
namespace demo {
class Publisher : public rclcpp::Node {
public:
explicit Publisher();
virtual ~Publisher();
void start();
private:
rclcpp::Publisher<std_msgs::msg::Float64>::SharedPtr pub_;
rclcpp::TimerBase::SharedPtr timer_;
double counter_;
};
} // namespace demo
#endif // DEMO__PUBLISHER_HPP_
Expected behavior
The listener will receive either all messages or if he can't process them fast enough some will fall out of the queue.
Actual behavior
The publisher works as expected - just keeps publishing messages.
The listener STOPS after receiving some messages (random amount). The log message from the callback won't be displayed anymore.
Additional information
- Is this a known bug?
- If I use a smaller frequency (10Hz), the listener seems to work properly. With a higher frequency (1000Hz) or (100Hz) the same problem occurs.
Windows 10
binaries
dashing
Fast-RTPS
rclcpp
Steps to reproduce issue
I have a modified listener/talker example, where I send around a double value.
listener_node.cpp
listener.cpp
listener.hpp
publisher_node.cpp
publisher.cpp
publisher.hpp
Expected behavior
The listener will receive either all messages or if he can't process them fast enough some will fall out of the queue.
Actual behavior
The publisher works as expected - just keeps publishing messages.
The listener STOPS after receiving some messages (random amount). The log message from the callback won't be displayed anymore.
Additional information