ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

roscpp: Node doesn't stop totally

asked 2022-01-23 08:45:58 -0500

Mackou gravatar image

updated 2022-01-23 08:47:18 -0500

Hello everyone, I am trying to exit my C++ node correctly but the process doesn't exit totally, here's the log I get :

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.12
 * /sekonix_camera_ut/calib_dir_path: /home/nvidia/cros...
 * /sekonix_camera_ut/config_path: /home/nvidia/cros...
 * /sekonix_camera_ut/framerate: 30

NODES
  /
    sekonix_camera_ut (sekonix_camera_ut/sekonix_camera_ut_node)

auto-starting new master
process[master]: started with pid [11422]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 8ad859d8-7c5a-11ec-8688-00044bf6558a
process[rosout-1]: started with pid [11441]
started core service [/rosout]
process[sekonix_camera_ut-2]: started with pid [11444]
[sekonix_camera_ut-2] process has finished cleanly
log file: /home/nvidia/.ros/log/8ad859d8-7c5a-11ec-8688-00044bf6558a/sekonix_camera_ut-2*.log

And after that the process hangs and doesn't exit.

And here's the C++ code :

int main(int argc, char** argv)
{
  ros::init(argc, argv, "sekonix_camera_ut");
  ros::NodeHandle nh("~");
  return 0;
}

Any idea why the node hangs and doesn't exit ?

Thanks !

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2022-01-24 11:59:53 -0500

Mackou gravatar image

Thanks to @gvdhoorn for finding the solution.

I used roslaunch to start the node without required="true" which means thatroslaunch` did not exit.

edit flag offensive delete link more
0

answered 2022-01-23 16:50:51 -0500

miura gravatar image

Perhaps adding a call to ros::shutdown() would help.

int main(int argc, char** argv)
{
  ros::init(argc, argv, "sekonix_camera_ut");
  ros::NodeHandle nh("~");
  ros::shutodnw();  // added
  return 0;
}

ref: http://wiki.ros.org/roscpp/Overview/I...

edit flag offensive delete link more

Comments

1

It's possible the OP confuses roslaunch not exiting (which is expected if there is no required="true") with the sekonix_camera_ut node exiting.

roslaunch "hangs" because it's still monitoring and providing the other parts of ROS. The sekonix_camera_ut node however has completely shut down.

gvdhoorn gravatar image gvdhoorn  ( 2022-01-24 02:45:07 -0500 )edit

@gvdhoorn Yes you are right I missed that ! Thanks !

Mackou gravatar image Mackou  ( 2022-01-24 11:58:29 -0500 )edit

@gvdhoorm Thank you. You are right, I was confusing the two.

miura gravatar image miura  ( 2022-01-24 17:13:13 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-01-23 08:45:58 -0500

Seen: 177 times

Last updated: Jan 24 '22