I have a node class shown below and I want to call its setCloud method from another class but it gives me the error:
error: ‘using element_type = class rclcpp::Node’ {aka ‘class rclcpp::Node’} has no member named ‘setCloud’ 422 | node_->setCloud(data);
My Node class:
class ROSNode : public rclcpp::Node
{
public:
ROSNode() : Node("ros_node")
{
msg.header.frame_id = "t";
points_publisher = this->create_publisher<sensor_msgs::msg::PointCloud2>("/t_points", 10);
}
void setCloud(typename pcl::PointCloud<pcl::PointXYZI> cloud)
{
pcl::toROSMsg(cloud, msg);
msg.header.stamp = get_clock()->now();
points_publisher->publish(msg);
};
private:
sensor_msgs::msg::PointCloud2 msg;
rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr points_publisher;
};
Header for the other class:
class testclass{
public:
testclass();
virtual ~testclass();
protected:
ROSNode::SharedPtr node_;
void transmitTargetDataROS(pcl::PointCloud<pcl::PointXYZI> data);
};
Source file for the other class:
testclass::testclass(): node_(std::make_shared<ROSNode>())
{
rclcpp::spin(node_);
}
void testclass::transmitTargetDataROS(pcl::PointCloud<pcl::PointXYZI> data)
{
node_->setCloud(data);
}
I copied only relevant parts from the files.