0
$\begingroup$

Rosanswers logo

I want to publish message while roscore is closing. I tried to use rospy.on_shutdown but it didn't work. In wiki it says "Messages are not guaranteed to be published." for on_shutdown. I am coding with python. How can i do that?


Originally posted by anonymous60874 on ROS Answers with karma: 1 on 2022-11-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Once the communication system is shutting down, it's too late to publish a message reliably via the communication system. You will want to design your system to communicate prior to shutting down the node.

A simple analogy to this is that you want to say goodbye after someone has hung up the phone. It's not going to work well. You want to have an expected exchange prior to hanging up the phone.


Originally posted by tfoote with karma: 58457 on 2022-11-22

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by anonymous60874 on 2022-11-22:
So, i can't publish message during the roscore closing right? Isn't there any way to publish message without design my system and if i have to design my system, how can i do that?

Comment by tfoote on 2022-11-22:
Just to be clear, roscore and rospy are different things. roscore is remote, rospy is local. When rospy.on_shutdown is called that's to tell you that the connections are being shutdown and you cannot expect to communicate any more. You're asking to do something that the callback is explicitly informing you that you can't do anymore. I suspect that on_shutdown is not the right thing to use for your use case. This is more likey an X-Y problem, but without knowing your use case I can't help much more.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.