-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGINT handling #476
Comments
This seems to be an issue with Any thoughts, @ygoumaz ? Other thing to try maybe can be add a |
Adding the In PythonPlugin.cpp void PythonPlugin::stop() {
PyObject_CallMethod(mPyPlugin, "stop", "");
std::cout << "PythonPlugin::stop" << std::endl;
// PyErr_Print();
std::cout << "PythonPlugin::stop::print" << std::endl;
Py_Finalize();
std::cout << "PythonPlugin::stop::finalize" << std::endl;
} the Python method def stop(self):
self.__node.get_logger().info('stopping')
self.__node.destroy_node()
sys.exit(0) In WebotsNode.cpp int WebotsNode::step() {
if (gShutdownSignalReceived && !mWaitingForUrdfRobotToBeRemoved) {
mRemoveUrdfRobotPublisher->publish(mRemoveUrdfRobotMessage);
mWaitingForUrdfRobotToBeRemoved = true;
}
const int result = wb_robot_step(mStep);
if (result == -1) {
// Check if the plugin is actually an instance of PythonPlugin
for (std::shared_ptr<PluginInterface> plugin : mPlugins) {
std::shared_ptr<webots_ros2_driver::PythonPlugin> pythonPlugin = std::dynamic_pointer_cast<webots_ros2_driver::PythonPlugin>(plugin);
if(pythonPlugin) {
std::cout << "stopssss" << std::endl;
pythonPlugin->stop(); // stop only for python plugins
}
}
return result;
}
for (std::shared_ptr<PluginInterface> plugin : mPlugins)
plugin->step();
return result;
} Using this code in Driver.cpp std::shared_ptr<webots_ros2_driver::WebotsNode> node = std::make_shared<webots_ros2_driver::WebotsNode>(robotName);
node->init();
RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation.");
while (true) {
if (node->step() == -1)
break;
rclcpp::spin_some(node);
}
std::cout << "outlook" << std::endl;
// rclcpp::spin_some(node);
// std::cout << "last spin" << std::endl;
RCLCPP_INFO(node->get_logger(), "Controller successfully disconnected from robot in Webots simulation.");
std::cout << "shutting down" << std::endl;
rclcpp::shutdown();
std::cout << "clean" << std::endl;
wb_robot_cleanup();
std::cout << "return" << std::endl;
return 0; However, the print trace reach until UPDATED |
Regarding issue #655, I will implement a shutdown handler in the launch file that will clean all other started nodes, excluding Webots, and then respawn them. However, before proceeding with this implementation in Iron, I am awaiting the merge of #760. Regarding this issue, I believe your approach is correct. While I haven't examined it in depth yet, you could potentially invoke |
I will test the In this regard, the Python API seems to require a more in depth examination. |
Still related to #788. |
Bug Description
when trying to stop a running launch file via CTRL+C the ros driver does not terminate cleanly.
We encountered this issue when writing a C++ plugin which utilizes RAII and found out that objects which are created inside the C++ plugin are not properly destructed.
Steps to Reproduce
mkdir -p ~/dev_ws/src/; cd ~/dev_ws/src; git clone --recursive https://github.com/cyberbotics/webots_ros2.git; cd ..
colcon build --symlink-install
source install/local_setup.bash; ros2 launch webots_ros2_tesla robot_launch.py
Error:
[ERROR] [ros2_supervisor.py-2]: process has died [pid 413862, exit code -2, cmd '/home/philpolt/ros/webots_shutdown_issue/install/webots_ros2_driver/lib/webots_ros2_driver/ros2_supervisor.py --ros-args'].
Expected behavior
The signal SIGINT should be properly handled inside the driver node. The launch file process
ros2_supervisor.py-2
should finish cleanly!System
The text was updated successfully, but these errors were encountered: