You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Example using spin_some might throw exception #266
The examples in this repository are besides the ROS2 tutorials the first place to learn ROS2. Therefore, many public repositories, for instance of universities or research institutes, contain code that uses exactly the same procedures as shown here.
The minimal_publisher example shows how to use rclcpp::spin_some. However, as pointed out in ros2/rclcpp#1066, rclcpp::spin_some will throw an exception if the program received a SIGINT and processed the shutdown after checking rclcpp::ok(), but before constructing the SingleThreadedExecutor in rclcpp::spin_some. This behaviour can easily be triggered by:
while (rclcpp::ok())
{
std::this_thread::sleep_for(std::chrono::seconds(1));
rclcpp::spin_some(ros_node);
}
I also recently have the issue of ros2/rclcpp#1066, and the fix I found out is something similar to luym11@26dfef3.
Is this the correct way to do this? I thought that ROS should already have a signal handler such that I do not need to override it like this.
Thanks!
Activity
fujitatomoya commentedon Apr 22, 2020
suggest to put spin_some in a try-catch block in example code, i guess.
fujitatomoya commentedon Apr 24, 2020
@hdino
are you gonna make a PR on this?
hidmic commentedon May 7, 2020
@hdino friendly ping.
spin_some might throw exception.(ros2#266)
fujitatomoya commentedon May 14, 2020
@hdino @hidmic
could you take a look at #270?
spin_some might throw exception.(#266) (#270)
luym11 commentedon Jun 24, 2021
I also recently have the issue of ros2/rclcpp#1066, and the fix I found out is something similar to luym11@26dfef3.
Is this the correct way to do this? I thought that ROS should already have a signal handler such that I do not need to override it like this.
Thanks!
A way to fix this