I see this code in the course:
def shutdownhook(self):
# works better than the rospy.is_shutdown()
self.ctrl_c = True
Could you explain the pros and cons between 2 ways to handle if shutdown happens?
I see this code in the course:
def shutdownhook(self):
# works better than the rospy.is_shutdown()
self.ctrl_c = True
Could you explain the pros and cons between 2 ways to handle if shutdown happens?
Hello @NguyenDuyDuc, I hope the following explanation will make it clear for you.
Using rospy.is_shutdown()
:
Pros:
rospy.is_shutdown()
is a method provided by ROS, and it’s considered the standard way to check if a ROS node should shut down. It’s part of the ROS API and is familiar to most ROS developers.Cons:
rospy.is_shutdown()
may not be checked frequently enough, leading to a delay in detecting a shutdown signal.Then lets come to self.ctrl_c
flag.
Pros:
Cons:
self.ctrl_c
in this case), and it requires careful placement in your code to be effective.Regards,
Hamdi
Thank you so much
It is very clear and helpful
You are welcome, I wish best of luck for you
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.