error: ‘WaitSet’ is not a member of ‘rclcpp’

asked 2022-01-04 08:00:47 -0500

Tianchaohuo gravatar image

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.

edit retag flag offensive close merge delete

Comments

Try adding: #include "rclcpp/wait_set.hpp"

osilva gravatar image osilva  ( 2022-01-04 14:21:18 -0500 )edit

try it before, but doesn't work. And I notice that "rclcpp/rclcpp.hpp" file already include "rclcpp/wait_set.hpp".

Tianchaohuo gravatar image Tianchaohuo  ( 2022-01-04 18:55:47 -0500 )edit

How did you install ROS 2?

christophebedard gravatar image christophebedard  ( 2022-01-07 09:36:27 -0500 )edit
Tianchaohuo gravatar image Tianchaohuo  ( 2022-01-09 05:34:51 -0500 )edit

did you install ROS 2 using other methods previously?

christophebedard gravatar image christophebedard  ( 2022-01-10 12:17:19 -0500 )edit