Cannot create a rclcpp::spin function
Hi all,
I am having a trouble in publishing and subscribing the node at the same time. More specifically, I am having an issue to pass the shared_ptr to the rclcpp::spin function. Here is my function inside my class:
void OdomNode::update()
{
//std::shared_ptr<rclcpp::Node> _for_spin = std::make_shared<rclcpp::Node>(*this);
while(rclcpp::ok())
{
this->loop();
this->_loop_rate.sleep();
rclcpp::spin(*this);
}
}
As you can see, the object itself inherits from rclcpp::Node class and this is a node instance. I have tried to use the first (uncommented) choice but it would not compile saying that the variable is private in this context (not sure what private there exactly). I have also tried to pass shared_from_this but during the runtime it crashes saying that it is a bad_weak_ptr.