0
$\begingroup$

I have a ROS node that seems to exit immediately or not even run at all. I have test print statements before the main loop and it never seems to get to that point. roscore is running and no error messages appear in the terminal window.

#include <ros/ros.h>
#include <iostream>

#define ROS_LOOP_RATE 2000

int main(int argc, char* argv[])
{

    std::cout << "TEST1\n";
    ros::init(argc, argv, "network_wdg_node");

    std::cout << "TEST2\n";
    ros::NodeHandle wdgNodeHandle("~");

    std::cout << "TEST3\n";
    ros::Rate loop_rate(ROS_LOOP_RATE);

    std::cout << "TEST4\n";

    while(ros::ok())
    {
        std::cout << "INSIDE LOOP\n";
        ros::spinOnce();
        loop_rate.sleep();
    }
    return 0;
}

Here's my terminal output:

[rosrun] Looking in catkin libexec dirs: 
/home/catkin_ws/devel/lib/test
/home/catkin_ws/devel/share/test
/home/catkin_ws/src/test
[rosrun] Looking in rospack dir: /home/catkin_ws/src/test
[rosrun] Searching for network_wdg_node with permissions /111
[rosrun] Running  /home/catkin_ws/devel/lib/network_wdg/test_node

I can't seem to figure out why the node doesn't start running or even get to the first debug statement.

$\endgroup$
2
  • $\begingroup$ Can you add your file structure? And maybe the relevant contents of your CMakeLists? And you're just running the node with rosrun? You could always run an strace -p <pid> on the process and see what it's doing, if anything. $\endgroup$ Feb 11, 2020 at 15:18
  • 1
    $\begingroup$ I solved/figure out the issue. I was running "rosrun test_node test_node" when it was just building an executable named "node". It was my fault for not reading CMakeLists closely enough. $\endgroup$ Feb 16, 2020 at 21:59

1 Answer 1

1
$\begingroup$

I don't have the ability to promote the above comment where the OP confirms the answer:

I solved/figure out the issue. I was running "rosrun test_node test_node" when it was just building an executable named "node". It was my fault for not reading CMakeLists closely enough

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.