error: ‘WaitSet’ is not a member of ‘rclcpp’
Hi,
when I try to use wait_set in my code copied from this link:
#include <rclcpp/rclcpp.hpp>
rclcpp::WaitSet wait_set;
wait_set.add_subscription(subscription);
auto ret = wait_set.wait(std::chrono::seconds(10));
if (ret.kind() == rclcpp::WaitResultKind::Ready) {
std_msgs::msg::String msg;
rclcpp::MessageInfo info;
auto ret_take = subscription->take(msg, info);
if (ret_take) {
RCLCPP_INFO(this->get_logger(), "got message: %s", msg.data.c_str());
} else {
RCLCPP_ERROR(this->get_logger(), "no message received");
}
} else {
RCLCPP_ERROR(this->get_logger(), "couldn't wait for message");
}
I face a problem : error: ‘WaitSet’ is not a member of ‘rclcpp’ rclcpp::WaitSet wait_set;`
How can I solve this problem? thanks in advance.
Try adding:
#include "rclcpp/wait_set.hpp"
try it before, but doesn't work. And I notice that "rclcpp/rclcpp.hpp" file already include "rclcpp/wait_set.hpp".
How did you install ROS 2?
I follow the official instruction
did you install ROS 2 using other methods previously?