I figured it out:
Since I was porting the code from ROS1, they initiated their node like this:
class OPEN_VRnode
{
public:
OPEN_VRnode(int rate);
~OPEN_VRnode();
bool Init();
void Run();
void Shutdown();
bool setOriginCB(const std::shared_ptr<std_srvs::srv::Empty::Request> req, std::shared_ptr<std_srvs::srv::Empty::Response> res);
void set_feedback(const sensor_msgs::msg::JoyFeedback::ConstPtr msg);
rclcpp::Node:: nh_;
VRInterface vr_;
...
OPEN_VRnode::OPEN_VRnode(int rate)
: loop_rate_(rate)
, nh_("open_vr_node")
, vr_()
, world_offset_({0, 0, 0})
, world_yaw_(0)
{
But this resulted in no shared_ptr
being created, so then later in the code when I ran rclcpp::spin_some(nh_.get_shared_from_this());
there was no valid shared ptr to pass to spin_some.
Fixed the issue by changing nh_
to nh_ptr_
and the type from rclcpp::Node
to rclcpp::Node::SharedPtr
and then initializing it in the class constructor.
Full code can be found on my repository:
https://github.com/NU-Haptics-Lab/ope...
just a note to anyone reading this in the future: that failure code is a generic Windows failure code.